[clang] Karikari (PR #67253)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 23 21:03:11 PDT 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 186a4b3b657878ae2aea23caf684b6e103901162 4e3adab12b509610d81502bb640accbaea39b9f9 -- llvm/include/llvm/ExecutionEngine/Orc/IRPartitionLayer.h llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h llvm/include/llvm/ExecutionEngine/Orc/ReOptimizeLayer.h llvm/include/llvm/ExecutionEngine/Orc/RedirectionManager.h llvm/lib/ExecutionEngine/Orc/IRPartitionLayer.cpp llvm/lib/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.cpp llvm/lib/ExecutionEngine/Orc/ReOptimizeLayer.cpp llvm/lib/ExecutionEngine/Orc/RedirectionManager.cpp llvm/unittests/ExecutionEngine/Orc/JITLinkRedirectionManagerTest.cpp llvm/unittests/ExecutionEngine/Orc/ReOptimizeLayerTest.cpp clang/include/clang/Interpreter/Interpreter.h clang/lib/CodeGen/CoverageMappingGen.cpp clang/lib/Interpreter/IncrementalExecutor.cpp clang/lib/Interpreter/IncrementalExecutor.h clang/lib/Interpreter/Interpreter.cpp compiler-rt/lib/orc/common.h compiler-rt/lib/orc/elfnix_platform.cpp compiler-rt/lib/orc/elfnix_platform.h llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp llvm/lib/ExecutionEngine/Orc/Core.cpp llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp llvm/lib/ExecutionEngine/Orc/LLJIT.cpp llvm/tools/lli/lli.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Interpreter/Interpreter.h b/clang/include/clang/Interpreter/Interpreter.h
index 5b0b59ace493..1d0fc9c49345 100644
--- a/clang/include/clang/Interpreter/Interpreter.h
+++ b/clang/include/clang/Interpreter/Interpreter.h
@@ -102,7 +102,7 @@ public:
const ASTContext &getASTContext() const;
ASTContext &getASTContext();
const CompilerInstance *getCompilerInstance() const;
- llvm::Expected<llvm::orc::LLLazyJIT&> getExecutionEngine();
+ llvm::Expected<llvm::orc::LLLazyJIT &> getExecutionEngine();
llvm::Expected<PartialTranslationUnit &> Parse(llvm::StringRef Code);
llvm::Error Execute(PartialTranslationUnit &T);
diff --git a/clang/lib/Interpreter/IncrementalExecutor.cpp b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 9fa76e33d837..954acedb3278 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//
#include "IncrementalExecutor.h"
- #include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTContext.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/CodeGen/ModuleBuilder.h"
#include "clang/CodeGen/ObjectFilePCHContainerOperations.h"
@@ -24,13 +24,12 @@
#include "clang/Frontend/TextDiagnosticBuffer.h"
#include "clang/Lex/PreprocessorOptions.h"
-#include "llvm/Bitcode/BitcodeReader.h"
-#include "llvm/Bitcode/BitcodeWriter.h"
-#include "llvm/Linker/Linker.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Driver/Driver.h"
#include "clang/Interpreter/PartialTranslationUnit.h"
+#include "llvm/Bitcode/BitcodeReader.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
@@ -40,22 +39,23 @@
#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/Module.h"
+#include "llvm/Linker/Linker.h"
+#include "llvm/Support/Host.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/TargetSelect.h"
-#include "llvm/Support/Host.h"
+#include "llvm/Analysis/CGSCCPassManager.h"
#include "llvm/Analysis/CallGraph.h"
-#include "llvm/Passes/PassBuilder.h"
-#include "llvm/Passes/StandardInstrumentations.h"
#include "llvm/Analysis/CallGraphSCCPass.h"
#include "llvm/Analysis/LoopAnalysisManager.h"
-#include "llvm/Analysis/CGSCCPassManager.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/RegionPass.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/ExecutionEngine/Orc/ReOptimizeLayer.h"
#include "llvm/IR/PassManager.h"
+#include "llvm/Passes/PassBuilder.h"
+#include "llvm/Passes/StandardInstrumentations.h"
using namespace llvm;
@@ -79,7 +79,8 @@ static std::string buildOrcRTBasename(const llvm::Triple &TT, bool AddArch) {
return (Prefix + Twine("orc_rt") + ArchAndEnv + Suffix).str();
}
-static std::string findOrcRuntimePath(const std::vector<const char *> &ClangArgv) {
+static std::string
+findOrcRuntimePath(const std::vector<const char *> &ClangArgv) {
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
TextDiagnosticBuffer *DiagsBuffer = new TextDiagnosticBuffer;
@@ -109,7 +110,8 @@ static std::string findOrcRuntimePath(const std::vector<const char *> &ClangArgv
return "";
}
-static void Optimize(TargetMachine* TM, Triple TargetTriple, llvm::Module& M, StringRef PassPipeline) {
+static void Optimize(TargetMachine *TM, Triple TargetTriple, llvm::Module &M,
+ StringRef PassPipeline) {
LoopAnalysisManager LAM;
FunctionAnalysisManager FAM;
CGSCCAnalysisManager CGAM;
@@ -120,8 +122,7 @@ static void Optimize(TargetMachine* TM, Triple TargetTriple, llvm::Module& M, St
PrintPassOptions PrintPassOpts;
PrintPassOpts.Verbose = false;
PrintPassOpts.SkipAnalyses = false;
- StandardInstrumentations SI(M.getContext(), false,
- false, PrintPassOpts);
+ StandardInstrumentations SI(M.getContext(), false, false, PrintPassOpts);
SI.registerCallbacks(PIC, &MAM);
PipelineTuningOptions PTO;
@@ -139,33 +140,32 @@ static void Optimize(TargetMachine* TM, Triple TargetTriple, llvm::Module& M, St
PB.registerLoopAnalyses(LAM);
PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
-
auto MPM = PB.buildPerModuleDefaultPipeline(OptimizationLevel::O2);
- //MPM.printPipeline(dbgs(), [](StringRef x){return x;});
+ // MPM.printPipeline(dbgs(), [](StringRef x){return x;});
MPM.run(M, MAM);
}
-std::unique_ptr<llvm::Module> CloneModuleToContext(llvm::Module& Src, LLVMContext& Ctx) {
- SmallVector<char, 1> ClonedModuleBuffer;
+std::unique_ptr<llvm::Module> CloneModuleToContext(llvm::Module &Src,
+ LLVMContext &Ctx) {
+ SmallVector<char, 1> ClonedModuleBuffer;
- std::set<GlobalValue *> ClonedDefsInSrc;
- ValueToValueMapTy VMap;
- auto Tmp = CloneModule(Src, VMap);
+ std::set<GlobalValue *> ClonedDefsInSrc;
+ ValueToValueMapTy VMap;
+ auto Tmp = CloneModule(Src, VMap);
- BitcodeWriter BCWriter(ClonedModuleBuffer);
+ BitcodeWriter BCWriter(ClonedModuleBuffer);
- BCWriter.writeModule(*Tmp);
- BCWriter.writeSymtab();
- BCWriter.writeStrtab();
+ BCWriter.writeModule(*Tmp);
+ BCWriter.writeSymtab();
+ BCWriter.writeStrtab();
- MemoryBufferRef ClonedModuleBufferRef(
- StringRef(ClonedModuleBuffer.data(), ClonedModuleBuffer.size()),
- "cloned module buffer");
+ MemoryBufferRef ClonedModuleBufferRef(
+ StringRef(ClonedModuleBuffer.data(), ClonedModuleBuffer.size()),
+ "cloned module buffer");
- auto ClonedModule = cantFail(
- parseBitcodeFile(ClonedModuleBufferRef, Ctx));
- ClonedModule->setModuleIdentifier(Src.getName());
- return ClonedModule;
+ auto ClonedModule = cantFail(parseBitcodeFile(ClonedModuleBufferRef, Ctx));
+ ClonedModule->setModuleIdentifier(Src.getName());
+ return ClonedModule;
}
auto EPC = cantFail(llvm::orc::SelfExecutorProcessControl::Create(
@@ -185,13 +185,16 @@ IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC,
// Enable debugging of JIT'd code (only works on JITLink for ELF and MachO).
Builder.setEnableDebuggerSupport(true);
- Builder.setObjectLinkingLayerCreator([&](llvm::orc::ExecutionSession &ES,
- const llvm::Triple &TT) {
- auto L = std::make_unique<llvm::orc::ObjectLinkingLayer>(ES, ES.getExecutorProcessControl().getMemMgr());
- return L;
- });
+ Builder.setObjectLinkingLayerCreator(
+ [&](llvm::orc::ExecutionSession &ES, const llvm::Triple &TT) {
+ auto L = std::make_unique<llvm::orc::ObjectLinkingLayer>(
+ ES, ES.getExecutorProcessControl().getMemMgr());
+ return L;
+ });
- Builder.setPlatformSetUp(llvm::orc::ExecutorNativePlatform("/home/sunho/dev/llvm-project/build/lib/clang/18/lib/x86_64-unknown-linux-gnu/liborc_rt.a"));
+ Builder.setPlatformSetUp(llvm::orc::ExecutorNativePlatform(
+ "/home/sunho/dev/llvm-project/build/lib/clang/18/lib/"
+ "x86_64-unknown-linux-gnu/liborc_rt.a"));
if (auto JitOrErr = Builder.create())
Jit = std::move(*JitOrErr);
@@ -202,16 +205,20 @@ IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC,
Jit->getReOptimizeLayer().setReoptimizeFunc(
[&](ReOptimizeLayer &Parent, ReOptMaterializationUnitID MUID,
- unsigned CurVerison, ResourceTrackerSP OldRT, const std::vector<std::pair<uint32_t,uint64_t>>& Profile, ThreadSafeModule &TSM) {
+ unsigned CurVerison, ResourceTrackerSP OldRT,
+ const std::vector<std::pair<uint32_t, uint64_t>> &Profile,
+ ThreadSafeModule &TSM) {
TSM.withModuleDo([&](llvm::Module &M) {
- dbgs() << "Optimizing ---------------" << "\n";
- dbgs() << "before: " << "\n";
+ dbgs() << "Optimizing ---------------"
+ << "\n";
+ dbgs() << "before: "
+ << "\n";
dbgs() << M << "\n";
std::set<uint64_t> ToLink;
DenseMap<uint32_t, std::vector<StringRef>> ProfileData;
-
+
for (auto [CID, F] : Profile) {
if (Parent.FuncAddrToMU.count(ExecutorAddr(F))) {
auto [MUID, Name] = Parent.FuncAddrToMU[ExecutorAddr(F)];
@@ -224,65 +231,71 @@ IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC,
}
for (auto MUID : ToLink) {
- auto& State = Parent.getMaterializationUnitState(MUID);
- State.getThreadSafeModule().withModuleDo([&](llvm::Module& NM) {
+ auto &State = Parent.getMaterializationUnitState(MUID);
+ State.getThreadSafeModule().withModuleDo([&](llvm::Module &NM) {
auto NNM = CloneModuleToContext(NM, M.getContext());
- for (auto& F : *NNM) {
- if (F.isDeclaration()) continue;
+ for (auto &F : *NNM) {
+ if (F.isDeclaration())
+ continue;
F.setVisibility(GlobalValue::HiddenVisibility);
}
Linker::linkModules(M, std::move(NNM));
});
}
- for (auto& F : M) {
- if (F.isDeclaration()) continue;
- for (auto& B : F) {
- std::vector<CallInst*> Insts;
- for (auto& I : B) {
- if (auto* Call = dyn_cast<CallInst>(&I)) {
+ for (auto &F : M) {
+ if (F.isDeclaration())
+ continue;
+ for (auto &B : F) {
+ std::vector<CallInst *> Insts;
+ for (auto &I : B) {
+ if (auto *Call = dyn_cast<CallInst>(&I)) {
if (Call->isIndirectCall()) {
Insts.push_back(Call);
}
}
}
- for (auto* Call : Insts) {
+ for (auto *Call : Insts) {
IRBuilder<> IRB(Call);
- auto* a = Call->getMetadata("call_id");
- if (!a) continue;
- auto* VAM = cast<ValueAsMetadata>(cast<MDNode>(a)->getOperand(0));
+ auto *a = Call->getMetadata("call_id");
+ if (!a)
+ continue;
+ auto *VAM =
+ cast<ValueAsMetadata>(cast<MDNode>(a)->getOperand(0));
int CallID = cast<ConstantInt>(VAM->getValue())->getSExtValue();
- std::vector<std::pair<BasicBlock*, Value*>> Dones;
- Instruction* IP = Call;
- std::vector<Value*> Args(Call->arg_begin(), Call->arg_end());
+ std::vector<std::pair<BasicBlock *, Value *>> Dones;
+ Instruction *IP = Call;
+ std::vector<Value *> Args(Call->arg_begin(), Call->arg_end());
for (auto Name : ProfileData[CallID]) {
- Value *Cmp = IRB.CreateICmpEQ(Call->getCalledOperand(), M.getFunction(Name));
+ Value *Cmp = IRB.CreateICmpEQ(Call->getCalledOperand(),
+ M.getFunction(Name));
Instruction *IfPart, *ElsePart;
SplitBlockAndInsertIfThenElse(Cmp, IP, &IfPart, &ElsePart);
IRBuilder<> Builder(IfPart);
- CallInst* Res = Builder.CreateCall(M.getFunction(Name), Args);
+ CallInst *Res = Builder.CreateCall(M.getFunction(Name), Args);
InlineFunctionInfo IFI;
InlineFunction(*Res, IFI);
Dones.push_back({IfPart->getParent(), Res});
IP = ElsePart;
}
IRBuilder<> Builder(IP);
- Builder.CreateCall(Call->getFunctionType(), Call->getCalledOperand(), Args);
+ Builder.CreateCall(Call->getFunctionType(),
+ Call->getCalledOperand(), Args);
if (!Call->getFunctionType()->getReturnType()->isVoidTy()) {
-
}
Call->eraseFromParent();
}
}
}
- dbgs() << "inlined: " << "\n";
+ dbgs() << "inlined: "
+ << "\n";
dbgs() << M << "\n";
Optimize(nullptr, Jit->getTargetTriple(), M, "default<O2>");
- dbgs() << "after: " << "\n";
+ dbgs() << "after: "
+ << "\n";
dbgs() << M << "\n";
-
});
return Error::success();
});
diff --git a/compiler-rt/lib/orc/common.h b/compiler-rt/lib/orc/common.h
index 9d54255b4a14..f34229a61534 100644
--- a/compiler-rt/lib/orc/common.h
+++ b/compiler-rt/lib/orc/common.h
@@ -20,7 +20,7 @@
/// This macro should be used to define tags that will be associated with
/// handlers in the JIT process, and call can be used to define tags f
#define ORC_RT_JIT_DISPATCH_TAG(X) \
-ORC_RT_INTERFACE char X; \
+ ORC_RT_INTERFACE char X; \
char X = 0;
/// Opaque struct for external symbols.
diff --git a/compiler-rt/lib/orc/elfnix_platform.cpp b/compiler-rt/lib/orc/elfnix_platform.cpp
index cdf65d14bfea..9eb1004b7953 100644
--- a/compiler-rt/lib/orc/elfnix_platform.cpp
+++ b/compiler-rt/lib/orc/elfnix_platform.cpp
@@ -16,8 +16,8 @@
#include "error.h"
#include "wrapper_function_utils.h"
-#include <iostream>
#include <algorithm>
+#include <iostream>
#include <map>
#include <mutex>
#include <sstream>
@@ -91,8 +91,8 @@ using ReoptimizeParam = SPSSequence<SPSTuple<uint32_t, uint64_t>>;
std::vector<std::pair<uint32_t, uint64_t>> SerealizeProfile(uint64_t MUID) {
std::vector<std::pair<uint32_t, uint64_t>> Res;
- for (auto& [CallID, CountMap] : CallProfiles[MUID]) {
- for (auto [FuncPtr, _ ] : CountMap) {
+ for (auto &[CallID, CountMap] : CallProfiles[MUID]) {
+ for (auto [FuncPtr, _] : CountMap) {
std::cout << "EECHIII:" << FuncPtr << "\n";
Res.push_back({CallID, FuncPtr});
}
@@ -100,22 +100,22 @@ std::vector<std::pair<uint32_t, uint64_t>> SerealizeProfile(uint64_t MUID) {
return Res;
}
-ORC_RT_INTERFACE void __orc_rt_increment_call_count(uint64_t MUID, uint32_t CallID, void* FuncPtr) {
- CallProfiles[MUID][CallID][(uint64_t)FuncPtr] ++;
+ORC_RT_INTERFACE void
+__orc_rt_increment_call_count(uint64_t MUID, uint32_t CallID, void *FuncPtr) {
+ CallProfiles[MUID][CallID][(uint64_t)FuncPtr]++;
}
ORC_RT_INTERFACE void __orc_rt_reoptimize(uint64_t MUID, uint32_t CurVersion) {
auto Profiles = SerealizeProfile(MUID);
Error Err2 = Error::success();
if (auto Err =
- WrapperFunction<SPSError(uint64_t, uint32_t, ReoptimizeParam)>::call(&__orc_rt_reoptimize_tag, Err2,
- MUID, CurVersion, Profiles))
+ WrapperFunction<SPSError(uint64_t, uint32_t, ReoptimizeParam)>::call(
+ &__orc_rt_reoptimize_tag, Err2, MUID, CurVersion, Profiles))
return;
if (Err2)
return;
}
-
class ELFNixPlatformRuntimeState {
private:
struct AtExitEntry {
@@ -264,7 +264,6 @@ void *ELFNixPlatformRuntimeState::dlopen(std::string_view Path, int Mode) {
}
}
-
auto H = dlopenInitialize(Path, Mode);
if (!H) {
DLFcnError = toString(H.takeError());
diff --git a/compiler-rt/lib/orc/elfnix_platform.h b/compiler-rt/lib/orc/elfnix_platform.h
index 6b63b4d7d7a0..c0d82b200d24 100644
--- a/compiler-rt/lib/orc/elfnix_platform.h
+++ b/compiler-rt/lib/orc/elfnix_platform.h
@@ -29,7 +29,8 @@ ORC_RT_INTERFACE int __orc_rt_elfnix_jit_dlclose(void *dso_handle);
ORC_RT_INTERFACE void *__orc_rt_elfnix_jit_dlsym(void *dso_handle,
const char *symbol);
-ORC_RT_INTERFACE void __orc_rt_increment_call_count(uint64_t MUID, uint32_t CallID, void* FuncPtr);
+ORC_RT_INTERFACE void
+__orc_rt_increment_call_count(uint64_t MUID, uint32_t CallID, void *FuncPtr);
ORC_RT_INTERFACE void __orc_rt_reoptimize(uint64_t MUID, uint32_t CurVersion);
namespace __orc_rt {
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
index ed79d15cfee7..d9045673412c 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
@@ -15,12 +15,12 @@
#include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
-#include "llvm/ExecutionEngine/Orc/ReOptimizeLayer.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/IRPartitionLayer.h"
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
+#include "llvm/ExecutionEngine/Orc/ReOptimizeLayer.h"
#include "llvm/ExecutionEngine/Orc/ThreadSafeModule.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ThreadPool.h"
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/ReOptimizeLayer.h b/llvm/include/llvm/ExecutionEngine/Orc/ReOptimizeLayer.h
index 01a616481f5e..76e75ad5aee5 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/ReOptimizeLayer.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/ReOptimizeLayer.h
@@ -42,7 +42,9 @@ public:
/// terminated.
using ReOptimizeFunc = unique_function<Error(
ReOptimizeLayer &Parent, ReOptMaterializationUnitID MUID,
- unsigned CurVersion, ResourceTrackerSP OldRT, const std::vector<std::pair<uint32_t, uint64_t>>& Profile, ThreadSafeModule &TSM)>;
+ unsigned CurVersion, ResourceTrackerSP OldRT,
+ const std::vector<std::pair<uint32_t, uint64_t>> &Profile,
+ ThreadSafeModule &TSM)>;
ReOptimizeLayer(ExecutionSession &ES, IRLayer &BaseLayer,
RedirectableSymbolManager &RM)
@@ -85,16 +87,20 @@ public:
// Create IR reoptimize request fucntion call.
static void createReoptimizeCall(Module &M, Instruction &IP,
- ReOptMaterializationUnitID MUID, uint32_t CurVersion);
+ ReOptMaterializationUnitID MUID,
+ uint32_t CurVersion);
// Create IR reoptimize request fucntion call.
- static void createFucnCountCall(Module &M, Instruction &IP, ReOptMaterializationUnitID MUID, uint32_t CallID, Value* FuncPtr);
+ static void createFucnCountCall(Module &M, Instruction &IP,
+ ReOptMaterializationUnitID MUID,
+ uint32_t CallID, Value *FuncPtr);
Error handleRemoveResources(JITDylib &JD, ResourceKey K) override;
void handleTransferResources(JITDylib &JD, ResourceKey DstK,
ResourceKey SrcK) override;
- DenseMap<ExecutorAddr, std::pair<ReOptMaterializationUnitID,StringRef>> FuncAddrToMU;
+ DenseMap<ExecutorAddr, std::pair<ReOptMaterializationUnitID, StringRef>>
+ FuncAddrToMU;
class ReOptMaterializationUnitState {
public:
ReOptMaterializationUnitState() = default;
@@ -150,9 +156,9 @@ public:
ThreadSafeModule TSM);
private:
-
void rt_reoptimize(SendErrorFn SendResult, ReOptMaterializationUnitID MUID,
- uint32_t CurVersion, const std::vector<std::pair<uint32_t,uint64_t>>& Profile);
+ uint32_t CurVersion,
+ const std::vector<std::pair<uint32_t, uint64_t>> &Profile);
static Expected<Constant *>
createReoptimizeArgBuffer(Module &M, ReOptMaterializationUnitID MUID,
diff --git a/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp b/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp
index 75af2c82c6ae..b466c08ecbb3 100644
--- a/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp
@@ -85,8 +85,8 @@ CompileOnDemandLayer::getPerDylibResources(JITDylib &TargetD) {
auto I = DylibResources.find(&TargetD);
if (I == DylibResources.end()) {
- auto &ImplD =
- cantFail(getExecutionSession().createJITDylib(TargetD.getName() + ".impl"));
+ auto &ImplD = cantFail(
+ getExecutionSession().createJITDylib(TargetD.getName() + ".impl"));
JITDylibSearchOrder NewLinkOrder;
TargetD.withLinkOrderDo([&](const JITDylibSearchOrder &TargetLinkOrder) {
NewLinkOrder = TargetLinkOrder;
diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp
index 7fefa0b22f12..94a9c990120d 100644
--- a/llvm/lib/ExecutionEngine/Orc/Core.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -2230,9 +2230,9 @@ ExecutionSession::lookup(ArrayRef<JITDylib *> SearchOrder, StringRef Name,
Error ExecutionSession::registerJITDispatchHandlers(
JITDylib &JD, JITDispatchHandlerAssociationMap WFs) {
- auto TagAddrs = lookup({{&JD, JITDylibLookupFlags::MatchAllSymbols}},
- SymbolLookupSet::fromMapKeys(
- WFs, SymbolLookupFlags::RequiredSymbol));
+ auto TagAddrs = lookup(
+ {{&JD, JITDylibLookupFlags::MatchAllSymbols}},
+ SymbolLookupSet::fromMapKeys(WFs, SymbolLookupFlags::RequiredSymbol));
if (!TagAddrs)
return TagAddrs.takeError();
@@ -2273,7 +2273,8 @@ void ExecutionSession::runJITDispatchHandler(SendResultFunction SendResult,
if (F)
(*F)(std::move(SendResult), ArgBuffer.data(), ArgBuffer.size());
else {
- dbgs() << "dispatch failed" << "\n";
+ dbgs() << "dispatch failed"
+ << "\n";
assert(false);
SendResult(shared::WrapperFunctionResult::createOutOfBandError(
("No function registered for tag " +
diff --git a/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
index 19efdbbb403f..3e0b20aa4587 100644
--- a/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
@@ -333,7 +333,7 @@ void ELFNixPlatform::getInitializersBuildSequencePhase(
auto ISItr = InitSeqs.find(InitJD.get());
if (ISItr != InitSeqs.end()) {
FullInitSeq.emplace_back(ISItr->second);
- //InitSeqs.erase(ISItr);
+ // InitSeqs.erase(ISItr);
ISItr->second.InitSections.clear();
}
}
diff --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
index 616b8a40d345..38cc56d4d286 100644
--- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
@@ -11,12 +11,12 @@
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
#include "llvm/ExecutionEngine/Orc/COFFPlatform.h"
#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
-#include "llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h"
#include "llvm/ExecutionEngine/Orc/DebuggerSupportPlugin.h"
#include "llvm/ExecutionEngine/Orc/ELFNixPlatform.h"
#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"
#include "llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
+#include "llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h"
#include "llvm/ExecutionEngine/Orc/MachOPlatform.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
@@ -1299,9 +1299,12 @@ LLLazyJIT::LLLazyJIT(LLLazyJITBuilderState &S, Error &Err) : LLJIT(S, Err) {
return;
}
- RSManager = cantFail(JITLinkRedirectableSymbolManager::Create(*ES, *dyn_cast<ObjectLinkingLayer>(&getObjLinkingLayer()), getMainJITDylib()));
+ RSManager = cantFail(JITLinkRedirectableSymbolManager::Create(
+ *ES, *dyn_cast<ObjectLinkingLayer>(&getObjLinkingLayer()),
+ getMainJITDylib()));
- ROLayer = std::make_unique<ReOptimizeLayer>(*ES, *InitHelperTransformLayer, *RSManager);
+ ROLayer = std::make_unique<ReOptimizeLayer>(*ES, *InitHelperTransformLayer,
+ *RSManager);
cantFail(ROLayer->reigsterRuntimeFunctions(*getPlatformJITDylib()));
diff --git a/llvm/lib/ExecutionEngine/Orc/ReOptimizeLayer.cpp b/llvm/lib/ExecutionEngine/Orc/ReOptimizeLayer.cpp
index 08f644a8fa6e..14f027f80a36 100644
--- a/llvm/lib/ExecutionEngine/Orc/ReOptimizeLayer.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ReOptimizeLayer.cpp
@@ -27,7 +27,9 @@ void ReOptimizeLayer::ReOptMaterializationUnitState::reoptimizeFailed() {
Error ReOptimizeLayer::reigsterRuntimeFunctions(JITDylib &PlatformJD) {
ExecutionSession::JITDispatchHandlerAssociationMap WFs;
- using ReoptimizeSPSSig = shared::SPSError(uint64_t, uint32_t, shared::SPSSequence<shared::SPSTuple<uint32_t, uint64_t>>);
+ using ReoptimizeSPSSig = shared::SPSError(
+ uint64_t, uint32_t,
+ shared::SPSSequence<shared::SPSTuple<uint32_t, uint64_t>>);
WFs[ES.intern("__orc_rt_reoptimize_tag")] =
ES.wrapAsyncWithSPS<ReoptimizeSPSSig>(this,
&ReOptimizeLayer::rt_reoptimize);
@@ -46,34 +48,34 @@ void ReOptimizeLayer::emit(std::unique_ptr<MaterializationResponsibility> R,
}
if (HasNonCallable) {
- dbgs() << "Skipped" << "\n";
- TSM.withModuleDo([&](Module& M) {
- dbgs() << M << "\n";
- });
+ dbgs() << "Skipped"
+ << "\n";
+ TSM.withModuleDo([&](Module &M) { dbgs() << M << "\n"; });
BaseLayer.emit(std::move(R), std::move(TSM));
return;
}
- TSM.withModuleDo([&](Module& M){
- uint32_t ID = 1;
+ TSM.withModuleDo([&](Module &M) {
+ uint32_t ID = 1;
for (auto &F : M) {
if (F.isDeclaration())
continue;
- for (auto &B : F) {
- for (auto &I : B) {
- if (auto* Call = dyn_cast<llvm::CallInst>(&I)) {
- if (Call->isIndirectCall()) {
- LLVMContext& C = Call->getContext();
- Type *I32Ty = Type::getInt32Ty(C);
- Constant *One = ConstantInt::get(I32Ty, ID);
- MDNode* N = MDNode::get(C, llvm::ValueAsMetadata::getConstant(One));
- Call->setMetadata("call_id", N);
- }
+ for (auto &B : F) {
+ for (auto &I : B) {
+ if (auto *Call = dyn_cast<llvm::CallInst>(&I)) {
+ if (Call->isIndirectCall()) {
+ LLVMContext &C = Call->getContext();
+ Type *I32Ty = Type::getInt32Ty(C);
+ Constant *One = ConstantInt::get(I32Ty, ID);
+ MDNode *N =
+ MDNode::get(C, llvm::ValueAsMetadata::getConstant(One));
+ Call->setMetadata("call_id", N);
}
}
}
}
- });
+ }
+ });
auto &MUState = createMaterializationUnitState(TSM);
@@ -84,7 +86,7 @@ void ReOptimizeLayer::emit(std::unique_ptr<MaterializationResponsibility> R,
R->failMaterialization();
return;
}
-
+
if (auto Err =
ProfilerFunc(*this, MUState.getID(), MUState.getCurVersion(), TSM)) {
ES.reportError(std::move(Err));
@@ -114,8 +116,8 @@ void ReOptimizeLayer::emit(std::unique_ptr<MaterializationResponsibility> R,
R->failMaterialization();
return;
}
-
- for (auto [K,V] : (*FinalSymbols)) {
+
+ for (auto [K, V] : (*FinalSymbols)) {
FuncAddrToMU[V.getAddress()] = {MUState.getID(), *K};
}
}
@@ -129,7 +131,8 @@ Error ReOptimizeLayer::reoptimizeIfCallFrequent(ReOptimizeLayer &Parent,
GlobalVariable *Counter = new GlobalVariable(
M, I64Ty, false, GlobalValue::InternalLinkage,
Constant::getNullValue(I64Ty), "__orc_reopt_counter");
- dbgs() << "Adding instrumentation" << "\n";
+ dbgs() << "Adding instrumentation"
+ << "\n";
for (auto &F : M) {
if (F.isDeclaration())
continue;
@@ -146,12 +149,15 @@ Error ReOptimizeLayer::reoptimizeIfCallFrequent(ReOptimizeLayer &Parent,
createReoptimizeCall(M, *SplitTerminator, MUID, CurVersion);
for (auto &B : F) {
- for (auto& I : B) {
- if (auto* Call = dyn_cast<llvm::CallInst>(&I)) {
+ for (auto &I : B) {
+ if (auto *Call = dyn_cast<llvm::CallInst>(&I)) {
if (Call->isIndirectCall()) {
- auto* VAM = cast<ValueAsMetadata>(dyn_cast<MDNode>(Call->getMetadata("call_id"))->getOperand(0));
- int CallID = dyn_cast<ConstantInt>(VAM->getValue())->getSExtValue();
- createFucnCountCall(M, I, MUID, CallID, Call->getCalledOperand());
+ auto *VAM = cast<ValueAsMetadata>(
+ dyn_cast<MDNode>(Call->getMetadata("call_id"))
+ ->getOperand(0));
+ int CallID =
+ dyn_cast<ConstantInt>(VAM->getValue())->getSExtValue();
+ createFucnCountCall(M, I, MUID, CallID, Call->getCalledOperand());
}
}
}
@@ -202,13 +208,13 @@ ReOptimizeLayer::emitMUImplSymbols(ReOptMaterializationUnitState &MUState,
Result[K] = (*ImplSymbols)[V];
}
-
return Result;
}
-void ReOptimizeLayer::rt_reoptimize(SendErrorFn SendResult,
- ReOptMaterializationUnitID MUID,
- uint32_t CurVersion, const std::vector<std::pair<uint32_t,uint64_t>>& Profile) {
+void ReOptimizeLayer::rt_reoptimize(
+ SendErrorFn SendResult, ReOptMaterializationUnitID MUID,
+ uint32_t CurVersion,
+ const std::vector<std::pair<uint32_t, uint64_t>> &Profile) {
auto &MUState = getMaterializationUnitState(MUID);
if (CurVersion < MUState.getCurVersion() || !MUState.tryStartReoptimize()) {
@@ -217,7 +223,7 @@ void ReOptimizeLayer::rt_reoptimize(SendErrorFn SendResult,
}
ThreadSafeModule TSM = cloneToNewContext(MUState.getThreadSafeModule());
- TSM.withModuleDo([&](Module& M) {
+ TSM.withModuleDo([&](Module &M) {
dbgs() << "Reoptimization requested for" << M.getName() << "\n";
});
@@ -263,41 +269,45 @@ Expected<Constant *> ReOptimizeLayer::createReoptimizeArgBuffer(
}
void ReOptimizeLayer::createReoptimizeCall(Module &M, Instruction &IP,
- ReOptMaterializationUnitID MUID, uint32_t CurVersion) {
+ ReOptMaterializationUnitID MUID,
+ uint32_t CurVersion) {
Function *DispatchFunc = M.getFunction("__orc_rt_reoptimize");
if (!DispatchFunc) {
- std::vector<Type *> Args = {IntegerType::get(M.getContext(), 64), IntegerType::get(M.getContext(), 32)};
+ std::vector<Type *> Args = {IntegerType::get(M.getContext(), 64),
+ IntegerType::get(M.getContext(), 32)};
FunctionType *FuncTy =
FunctionType::get(Type::getVoidTy(M.getContext()), Args, false);
DispatchFunc = Function::Create(FuncTy, GlobalValue::ExternalLinkage,
"__orc_rt_reoptimize", &M);
}
- Constant *MUIDConst = ConstantInt::get(
- IntegerType::get(M.getContext(), 64), MUID, false);
- Constant *VersionConst= ConstantInt::get(
- IntegerType::get(M.getContext(), 32), CurVersion, false);
+ Constant *MUIDConst =
+ ConstantInt::get(IntegerType::get(M.getContext(), 64), MUID, false);
+ Constant *VersionConst =
+ ConstantInt::get(IntegerType::get(M.getContext(), 32), CurVersion, false);
IRBuilder<> IRB(&IP);
- (void)IRB.CreateCall(DispatchFunc,
- {MUIDConst, VersionConst});
+ (void)IRB.CreateCall(DispatchFunc, {MUIDConst, VersionConst});
}
// Create IR reoptimize request fucntion call.
-void ReOptimizeLayer::createFucnCountCall(Module &M, Instruction &IP, ReOptMaterializationUnitID MUID, uint32_t CallID, Value* FuncPtr) {
+void ReOptimizeLayer::createFucnCountCall(Module &M, Instruction &IP,
+ ReOptMaterializationUnitID MUID,
+ uint32_t CallID, Value *FuncPtr) {
Function *DispatchFunc = M.getFunction("__orc_rt_increment_call_count");
if (!DispatchFunc) {
- std::vector<Type *> Args = {IntegerType::get(M.getContext(), 64), IntegerType::get(M.getContext(), 32), Type::getInt8PtrTy(M.getContext())};
+ std::vector<Type *> Args = {IntegerType::get(M.getContext(), 64),
+ IntegerType::get(M.getContext(), 32),
+ Type::getInt8PtrTy(M.getContext())};
FunctionType *FuncTy =
FunctionType::get(Type::getVoidTy(M.getContext()), Args, false);
DispatchFunc = Function::Create(FuncTy, GlobalValue::ExternalLinkage,
"__orc_rt_increment_call_count", &M);
}
- Constant *MUIDConst = ConstantInt::get(
- IntegerType::get(M.getContext(), 64), MUID, false);
- Constant *CallIDConst = ConstantInt::get(
- IntegerType::get(M.getContext(), 32), CallID, false);
+ Constant *MUIDConst =
+ ConstantInt::get(IntegerType::get(M.getContext(), 64), MUID, false);
+ Constant *CallIDConst =
+ ConstantInt::get(IntegerType::get(M.getContext(), 32), CallID, false);
IRBuilder<> IRB(&IP);
- (void)IRB.CreateCall(DispatchFunc,
- {MUIDConst, CallIDConst, FuncPtr});
+ (void)IRB.CreateCall(DispatchFunc, {MUIDConst, CallIDConst, FuncPtr});
}
ReOptimizeLayer::ReOptMaterializationUnitState &
``````````
</details>
https://github.com/llvm/llvm-project/pull/67253
More information about the cfe-commits
mailing list