Skip to content

Commit 7ebfcbd

Browse files
authored
Allow for custom code model in clang::Interpreter (#156977)
This is necessary when using ASan, since the larger code size will lead to errors such as: ``` JIT session error: In graph clojure_core-clojure.core$clojure_core_cpp_cast_24538-24543-jitted-objectbuffer, section .eh_frame: relocation target 0x7bffe374b000 (DW.ref.__gxx_personality_v0) is out of range of Delta32 fixup at address 0x7bffe374b000 (<anonymous block> @ 0x7fffebf48158 + 0x13) ``` Previously, `clang::Interpreter` would hard-code the usage of a small code model. With this change, we default to small, but allow for custom values. This related to #102858 and #135401. There is no change to default behavior here. @lhames for review.
1 parent be58794 commit 7ebfcbd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

clang/include/clang/Interpreter/Interpreter.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,13 @@ class Interpreter {
135135
std::string OrcRuntimePath = "";
136136
/// PID of the out-of-process JIT executor.
137137
uint32_t ExecutorPID = 0;
138+
/// An optional code model to provide to the JITTargetMachineBuilder
139+
std::optional<llvm::CodeModel::Model> CM = std::nullopt;
138140

139141
JITConfig()
140142
: IsOutOfProcess(false), OOPExecutor(""), OOPExecutorConnect(""),
141143
UseSharedMemory(false), SlabAllocateSize(0), OrcRuntimePath(""),
142-
ExecutorPID(0) {}
144+
ExecutorPID(0), CM(std::nullopt) {}
143145
};
144146

145147
protected:

clang/lib/Interpreter/Interpreter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,8 @@ llvm::Error Interpreter::CreateExecutor(JITConfig Config) {
647647
auto JTMB = createJITTargetMachineBuilder(TT);
648648
if (!JTMB)
649649
return JTMB.takeError();
650+
if (Config.CM)
651+
JTMB->setCodeModel(Config.CM);
650652
auto JB = IncrementalExecutor::createDefaultJITBuilder(std::move(*JTMB));
651653
if (!JB)
652654
return JB.takeError();

0 commit comments

Comments
 (0)