Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orc C Bindings crash on platforms without lazy loading support #36244

Open
anarazel opened this issue Mar 26, 2018 · 1 comment
Open

Orc C Bindings crash on platforms without lazy loading support #36244

anarazel opened this issue Mar 26, 2018 · 1 comment
Labels
bugzilla Issues migrated from bugzilla orcjit

Comments

@anarazel
Copy link
Contributor

Bugzilla Link 36896
Version trunk
OS Linux
CC @dwblaikie,@lhames

Extended Description

Hi,

Even when not using LLVMOrcAddLazilyCompiledIR() Orc crashes on platforms without indirect stub support. The reason for that is that its constructor dereferences a nullptr functor (IndirectStubsMgrBuilder):

OrcCBindingsStack(TargetMachine &TM,
std::unique_ptr CCMgr,
IndirectStubsManagerBuilder IndirectStubsMgrBuilder)
: ES(SSP), DL(TM.createDataLayout()),
IndirectStubsMgr(IndirectStubsMgrBuilder()), CCMgr(std::move(CCMgr)),

which is invoked by:

LLVMOrcJITStackRef LLVMOrcCreateInstance(LLVMTargetMachineRef TM) {
TargetMachine *TM2(unwrap(TM));

Triple T(TM2->getTargetTriple());

auto CompileCallbackMgr = orc::createLocalCompileCallbackManager(T, 0);
auto IndirectStubsMgrBuilder =
orc::createLocalIndirectStubsManagerBuilder(T);

OrcCBindingsStack *JITStack = new OrcCBindingsStack(
*TM2, std::move(CompileCallbackMgr), IndirectStubsMgrBuilder);

return wrap(JITStack);
}

std::function<std::unique_ptr()>
createLocalIndirectStubsManagerBuilder(const Triple &T) {
switch (T.getArch()) {
default: return nullptr;
...
}

So, if any orc is used on a platform (e.g. powerpc) without stub support, orc can't be used in eager support either.

It's not hard to fix this. We can either make createLocalIndirectSubsManagerBuilder() return orc::LocalIndirectStubsManagerorc::OrcGenericABI>(); or have the C stack not construct IndirectStubsMgr until necessary. Any preference?

I'd be awesome if we could get this fixed for 6.1, this is currently breaking postgres' JIT on PPC.

I'm planning to update the orc unittests so a) they actually test aarch64, given that that should now be fully supported. b) split the tests into indirect / no jit at all capability, so crashes like this can be detected automatically in the future.

@anarazel
Copy link
Contributor Author

I've proposed a fix (thanks also to my colleague Thomas Munro that came up with the same approach) at: https://reviews.llvm.org/D44902

It'd be great if the fix could be backported so it'll be included in 6.1. Not sure if I'd include the test rework though.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla orcjit
Projects
None yet
Development

No branches or pull requests

1 participant