[llvm] [ORC][MCJIT] add RuntimeLibraryInfoWrapper pass to PM (PR #174682)
Wenju He via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 6 19:53:36 PST 2026
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/174682
>From 42a62acb7925b550c9a1009264eca86b36d586e7 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Wed, 7 Jan 2026 03:19:24 +0100
Subject: [PATCH 1/3] [ORC][MCJIT] add RuntimeLibraryInfoWrapper pass to PM
Register RuntimeLibraryInfoWrapper with the pass manager, following the
change in 04c81a99735c, so that codegen in JIT compiler is working correctly.
---
llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp | 6 ++++++
llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp | 7 +++++++
2 files changed, 13 insertions(+)
diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index 5f3067b2a97ea..499ff127dc26d 100644
--- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -8,6 +8,7 @@
#include "MCJIT.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/Analysis/RuntimeLibcallInfo.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/ExecutionEngine/JITEventListener.h"
#include "llvm/ExecutionEngine/MCJIT.h"
@@ -157,6 +158,11 @@ std::unique_ptr<MemoryBuffer> MCJIT::emitObject(Module *M) {
legacy::PassManager PM;
+ const TargetOptions &Options = TM->Options;
+ PM.add(new RuntimeLibraryInfoWrapper(
+ M->getTargetTriple(), Options.ExceptionModel, Options.FloatABIType,
+ Options.EABIVersion, Options.MCOptions.ABIName, Options.VecLib));
+
// The RuntimeDyld will take ownership of this shortly
SmallVector<char, 4096> ObjBufferSV;
raw_svector_ostream ObjStream(ObjBufferSV);
diff --git a/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp b/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
index c4d65af1b57f8..edaf69642c345 100644
--- a/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
@@ -9,6 +9,7 @@
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/Analysis/RuntimeLibcallInfo.h"
#include "llvm/ExecutionEngine/ObjectCache.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
@@ -46,6 +47,12 @@ Expected<SimpleCompiler::CompileResult> SimpleCompiler::operator()(Module &M) {
raw_svector_ostream ObjStream(ObjBufferSV);
legacy::PassManager PM;
+
+ const TargetOptions &Options = TM.Options;
+ PM.add(new RuntimeLibraryInfoWrapper(
+ M.getTargetTriple(), Options.ExceptionModel, Options.FloatABIType,
+ Options.EABIVersion, Options.MCOptions.ABIName, Options.VecLib));
+
MCContext *Ctx;
if (TM.addPassesToEmitMC(PM, Ctx, ObjStream))
return make_error<StringError>("Target does not support MC emission",
>From 990e7804a5e26f59b04346cba0595376a7bc8650 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Wed, 7 Jan 2026 04:48:52 +0100
Subject: [PATCH 2/3] add RuntimeLibraryInfoWrapper in addPassesToEmitMC
---
llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp | 8 ++++++++
llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp | 6 ------
llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp | 7 -------
3 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
index 5d7e2b59c2047..20192c4f9dd3b 100644
--- a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
+++ b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/CodeGenTargetMachineImpl.h"
+#include "llvm/Analysis/RuntimeLibcallInfo.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/BasicTTIImpl.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
@@ -33,6 +34,7 @@
#include "llvm/Target/RegisterTargetPassConfigCallback.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
+
using namespace llvm;
static cl::opt<bool>
@@ -123,6 +125,12 @@ addPassesToGenerateCode(CodeGenTargetMachineImpl &TM, PassManagerBase &PM,
PassConfig->setDisableVerify(DisableVerify);
PM.add(PassConfig);
PM.add(&MMIWP);
+
+ const TargetOptions &Options = TM.Options;
+ PM.add(new RuntimeLibraryInfoWrapper(
+ TM.getTargetTriple(), Options.ExceptionModel, Options.FloatABIType,
+ Options.EABIVersion, Options.MCOptions.ABIName, Options.VecLib));
+
invokeGlobalTargetPassConfigCallbacks(TM, PM, PassConfig);
if (PassConfig->addISelPasses())
diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index 499ff127dc26d..5f3067b2a97ea 100644
--- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -8,7 +8,6 @@
#include "MCJIT.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/Analysis/RuntimeLibcallInfo.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/ExecutionEngine/JITEventListener.h"
#include "llvm/ExecutionEngine/MCJIT.h"
@@ -158,11 +157,6 @@ std::unique_ptr<MemoryBuffer> MCJIT::emitObject(Module *M) {
legacy::PassManager PM;
- const TargetOptions &Options = TM->Options;
- PM.add(new RuntimeLibraryInfoWrapper(
- M->getTargetTriple(), Options.ExceptionModel, Options.FloatABIType,
- Options.EABIVersion, Options.MCOptions.ABIName, Options.VecLib));
-
// The RuntimeDyld will take ownership of this shortly
SmallVector<char, 4096> ObjBufferSV;
raw_svector_ostream ObjStream(ObjBufferSV);
diff --git a/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp b/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
index edaf69642c345..c4d65af1b57f8 100644
--- a/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
@@ -9,7 +9,6 @@
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ADT/SmallVector.h"
-#include "llvm/Analysis/RuntimeLibcallInfo.h"
#include "llvm/ExecutionEngine/ObjectCache.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
@@ -47,12 +46,6 @@ Expected<SimpleCompiler::CompileResult> SimpleCompiler::operator()(Module &M) {
raw_svector_ostream ObjStream(ObjBufferSV);
legacy::PassManager PM;
-
- const TargetOptions &Options = TM.Options;
- PM.add(new RuntimeLibraryInfoWrapper(
- M.getTargetTriple(), Options.ExceptionModel, Options.FloatABIType,
- Options.EABIVersion, Options.MCOptions.ABIName, Options.VecLib));
-
MCContext *Ctx;
if (TM.addPassesToEmitMC(PM, Ctx, ObjStream))
return make_error<StringError>("Target does not support MC emission",
>From 6d209a81edc04c436f969057b0c4a672e4ae990b Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Wed, 7 Jan 2026 04:53:25 +0100
Subject: [PATCH 3/3] undo new line change
---
llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
index 20192c4f9dd3b..fa64dda532799 100644
--- a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
+++ b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
@@ -34,7 +34,6 @@
#include "llvm/Target/RegisterTargetPassConfigCallback.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
-
using namespace llvm;
static cl::opt<bool>
More information about the llvm-commits
mailing list