diff options
Diffstat (limited to 'llvm/lib/ExecutionEngine')
5 files changed, 69 insertions, 38 deletions
diff --git a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp index 12d31f8..2f32346 100644 --- a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp @@ -28,7 +28,7 @@ namespace aarch32 { /// Check whether the given target flags are set for this Symbol. bool hasTargetFlags(Symbol &Sym, TargetFlagsType Flags) { - return static_cast<TargetFlagsType>(Sym.getTargetFlags()) & Flags; + return Sym.getTargetFlags() & Flags; } /// Encode 22-bit immediate value for branch instructions without J1J2 range diff --git a/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp index 1bafed7..75ae80f 100644 --- a/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp +++ b/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp @@ -12,7 +12,6 @@ #include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.h" #include "llvm/ExecutionEngine/Orc/MachOBuilder.h" -#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/BinaryFormat/MachO.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" @@ -64,7 +63,7 @@ public: LLVM_DEBUG({ dbgs() << " Preserving debug section " << Sec.getName() << "\n"; }); - SmallSet<Block *, 8> PreservedBlocks; + SmallPtrSet<Block *, 8> PreservedBlocks; for (auto *Sym : Sec.symbols()) { bool NewPreservedBlock = PreservedBlocks.insert(&Sym->getBlock()).second; diff --git a/llvm/lib/ExecutionEngine/Orc/EPCIndirectionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/EPCIndirectionUtils.cpp index 8e4937d..91a3115 100644 --- a/llvm/lib/ExecutionEngine/Orc/EPCIndirectionUtils.cpp +++ b/llvm/lib/ExecutionEngine/Orc/EPCIndirectionUtils.cpp @@ -169,7 +169,7 @@ Error EPCIndirectStubsManager::createStubs(const StubInitsMap &StubInits) { std::vector<tpctypes::UInt64Write> PtrUpdates; for (auto &SI : StubInits) PtrUpdates.push_back({(*AvailableStubInfos)[ASIdx++].PointerAddress, - static_cast<uint64_t>(SI.second.first.getValue())}); + SI.second.first.getValue()}); return MemAccess.writeUInt64s(PtrUpdates); } default: diff --git a/llvm/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp b/llvm/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp index 19c000e..d460cf6 100644 --- a/llvm/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp +++ b/llvm/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp @@ -14,40 +14,39 @@ namespace llvm { namespace orc { -ThreadSafeModule cloneToContext(const ThreadSafeModule &TSM, - ThreadSafeContext TSCtx, - GVPredicate ShouldCloneDef, - GVModifier UpdateClonedDefSource) { - assert(TSM && "Can not clone null module"); - - if (!ShouldCloneDef) - ShouldCloneDef = [](const GlobalValue &) { return true; }; - - // First copy the source module into a buffer. +static std::pair<std::string, SmallVector<char, 1>> +serializeModule(const Module &M, GVPredicate ShouldCloneDef, + GVModifier UpdateClonedDefSource) { std::string ModuleName; SmallVector<char, 1> ClonedModuleBuffer; - TSM.withModuleDo([&](Module &M) { - ModuleName = M.getModuleIdentifier(); - std::set<GlobalValue *> ClonedDefsInSrc; - ValueToValueMapTy VMap; - auto Tmp = CloneModule(M, VMap, [&](const GlobalValue *GV) { - if (ShouldCloneDef(*GV)) { - ClonedDefsInSrc.insert(const_cast<GlobalValue *>(GV)); - return true; - } - return false; - }); - - if (UpdateClonedDefSource) - for (auto *GV : ClonedDefsInSrc) - UpdateClonedDefSource(*GV); - - BitcodeWriter BCWriter(ClonedModuleBuffer); - BCWriter.writeModule(*Tmp); - BCWriter.writeSymtab(); - BCWriter.writeStrtab(); + + ModuleName = M.getModuleIdentifier(); + std::set<GlobalValue *> ClonedDefsInSrc; + ValueToValueMapTy VMap; + auto Tmp = CloneModule(M, VMap, [&](const GlobalValue *GV) { + if (ShouldCloneDef(*GV)) { + ClonedDefsInSrc.insert(const_cast<GlobalValue *>(GV)); + return true; + } + return false; }); + if (UpdateClonedDefSource) + for (auto *GV : ClonedDefsInSrc) + UpdateClonedDefSource(*GV); + + BitcodeWriter BCWriter(ClonedModuleBuffer); + BCWriter.writeModule(*Tmp); + BCWriter.writeSymtab(); + BCWriter.writeStrtab(); + + return {std::move(ModuleName), std::move(ClonedModuleBuffer)}; +} + +ThreadSafeModule +deserializeModule(std::string ModuleName, + const SmallVector<char, 1> &ClonedModuleBuffer, + ThreadSafeContext TSCtx) { MemoryBufferRef ClonedModuleBufferRef( StringRef(ClonedModuleBuffer.data(), ClonedModuleBuffer.size()), "cloned module buffer"); @@ -63,6 +62,40 @@ ThreadSafeModule cloneToContext(const ThreadSafeModule &TSM, return ThreadSafeModule(std::move(M), std::move(TSCtx)); } +ThreadSafeModule +cloneExternalModuleToContext(const Module &M, ThreadSafeContext TSCtx, + GVPredicate ShouldCloneDef, + GVModifier UpdateClonedDefSource) { + + if (!ShouldCloneDef) + ShouldCloneDef = [](const GlobalValue &) { return true; }; + + auto [ModuleName, ClonedModuleBuffer] = serializeModule( + M, std::move(ShouldCloneDef), std::move(UpdateClonedDefSource)); + + return deserializeModule(std::move(ModuleName), ClonedModuleBuffer, + std::move(TSCtx)); +} + +ThreadSafeModule cloneToContext(const ThreadSafeModule &TSM, + ThreadSafeContext TSCtx, + GVPredicate ShouldCloneDef, + GVModifier UpdateClonedDefSource) { + assert(TSM && "Can not clone null module"); + + if (!ShouldCloneDef) + ShouldCloneDef = [](const GlobalValue &) { return true; }; + + // First copy the source module into a buffer. + auto [ModuleName, ClonedModuleBuffer] = TSM.withModuleDo([&](Module &M) { + return serializeModule(M, std::move(ShouldCloneDef), + std::move(UpdateClonedDefSource)); + }); + + return deserializeModule(std::move(ModuleName), ClonedModuleBuffer, + std::move(TSCtx)); +} + ThreadSafeModule cloneToNewContext(const ThreadSafeModule &TSM, GVPredicate ShouldCloneDef, GVModifier UpdateClonedDefSource) { diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index 08d6c78..d626803 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -654,11 +654,10 @@ bool RuntimeDyldELF::resolveLoongArch64ShortBranch( if (Loc == GlobalSymbolTable.end()) return false; const auto &SymInfo = Loc->second; - Address = - uint64_t(Sections[SymInfo.getSectionID()].getLoadAddressWithOffset( - SymInfo.getOffset())); + Address = Sections[SymInfo.getSectionID()].getLoadAddressWithOffset( + SymInfo.getOffset()); } else { - Address = uint64_t(Sections[Value.SectionID].getLoadAddress()); + Address = Sections[Value.SectionID].getLoadAddress(); } uint64_t Offset = RelI->getOffset(); uint64_t SourceAddress = Sections[SectionID].getLoadAddressWithOffset(Offset); |