Skip to content

Commit

Permalink
compatibility fix for ORC JIT in llvm 14 (#45007)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfanqi authored Apr 18, 2022
1 parent 1600cb9 commit 6f8662b
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,12 @@ class JLDebuginfoPlugin : public ObjectLinkingLayer::Plugin {
continue;
}
auto SecName = Sec.getName().substr(SepPos + 1);
Info.SectionLoadAddresses[SecName] = jitlink::SectionRange(Sec).getStart();
// https://github.com/llvm/llvm-project/commit/118e953b18ff07d00b8f822dfbf2991e41d6d791
#if JL_LLVM_VERSION >= 140000
Info.SectionLoadAddresses[SecName] = jitlink::SectionRange(Sec).getStart().getValue();
#else
Info.SectionLoadAddresses[SecName] = jitlink::SectionRange(Sec).getStart();
#endif
}
return Error::success();
});
Expand All @@ -644,21 +649,30 @@ class JLDebuginfoPlugin : public ObjectLinkingLayer::Plugin {
}

# ifdef LLVM_SHLIB

# if JL_LLVM_VERSION >= 140000
# define EHFRAME_RANGE(name) orc::ExecutorAddrRange name
# define UNPACK_EHFRAME_RANGE(name) \
name.Start.toPtr<uint8_t *>(), \
static_cast<size_t>(name.size())
# else
# define EHFRAME_RANGE(name) JITTargetAddress name##Addr, size_t name##Size
# define UNPACK_EHFRAME_RANGE(name) \
jitTargetAddressToPointer<uint8_t *>(name##Addr), \
name##Size
# endif

class JLEHFrameRegistrar final : public jitlink::EHFrameRegistrar {
public:
Error registerEHFrames(JITTargetAddress EHFrameSectionAddr,
size_t EHFrameSectionSize) override {
Error registerEHFrames(EHFRAME_RANGE(EHFrameSection)) override {
register_eh_frames(
jitTargetAddressToPointer<uint8_t *>(EHFrameSectionAddr),
EHFrameSectionSize);
UNPACK_EHFRAME_RANGE(EHFrameSection));
return Error::success();
}

Error deregisterEHFrames(JITTargetAddress EHFrameSectionAddr,
size_t EHFrameSectionSize) override {
Error deregisterEHFrames(EHFRAME_RANGE(EHFrameSection)) override {
deregister_eh_frames(
jitTargetAddressToPointer<uint8_t *>(EHFrameSectionAddr),
EHFrameSectionSize);
UNPACK_EHFRAME_RANGE(EHFrameSection));
return Error::success();
}
};
Expand Down

0 comments on commit 6f8662b

Please sign in to comment.