[llvm-bugs] [Bug 41595] New: OrcJIT's MaterializationResponsibility fails asserts (also in KaleidoscopeJIT Ch2)

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 24 18:32:48 PDT 2019


            Bug ID: 41595
           Summary: OrcJIT's MaterializationResponsibility fails asserts
                    (also in KaleidoscopeJIT Ch2)
           Product: libraries
           Version: 8.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: OrcJIT
          Assignee: unassignedbugs at nondot.org
          Reporter: fabian.muehlboeck at outlook.com
                CC: 1101.debian at gmail.com, llvm-bugs at lists.llvm.org

Using OrcJIT in llvm 8.0.0 fails very quickly in an assert failure in
MaterializationResponsibility::resolve, which seems to be internal to OrcJIT
and out of the control of the user. Just running Kaleidoscope Ch2 as included
in the source code distribution causes 

    assert(I != SymbolFlags.end() &&
           "Resolving symbol outside this responsibility set");

in lines 399 and 400 of ExecutionEngine/Orc/Core.cpp to fail. In particular,
this seems to reliably happen after entering the second line code, say "5+2"
and "5+2".

Originally, I just tried to compile a function that returns an integer constant
and is marked as having external linkage, which failed in the same function at
lines 407 and 408:

      assert(I->second == KV.second.getFlags() &&
             "Resolving symbol with incorrect flags");

As far as I can tell from the data, "I" has a Flags field whose value is
"Exported | Callable (48 '0')", and "KV" has a Flags field whose value is just
"Callable (32 '0')". After setting up a JIT much like in Kaleidoscope, the
following is all that this code does to produce that error:

auto theModule = llvm::make_unique<llvm::Module>("module", LLVMCONTEXT);

llvm::Function *fun = llvm::Function::Create(llvm::FunctionType::get(INTTYPE,
false), llvm::Function::ExternalLinkage, "testmethod", theModule.get());

BasicBlock *startBlock = BasicBlock::Create(LLVMCONTEXT, "testmethod$start",

IRBuilder<> builder(LLVMCONTEXT);
builder.CreateRet(llvm::ConstantInt::get(INTTYPE, 5, true));
if (verifyFunction(*fun))
        throw "Failed verification";

auto MainSymbol = ExitOnErr(MyJIT::Instance()->lookup("testmethod")); //FAILS
int (*mainmeth)() = (int (*)())(intptr_t)MainSymbol.getAddress();

I'm running Windows 10 and compiled llvm (from the 8.0.0 source tar available
on llvm.org) and the other projects with Visual Studio 2017, and the same
problems happen on two different machines with the same setup.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190425/c9aeba9d/attachment-0001.html>

More information about the llvm-bugs mailing list