<div dir="ltr">Hi Geoff,<br><div><br></div><div>Nothing in that backtrace leaps out at me. Based on the stack trace and description my first guess would be a clang misconfiguration rather than a JIT bug.</div><div><br></div><div>How is that clang invocation being made? Is it from inside a callback from ORC, or is it before you add your module to the JIT?</div><div><br></div><div>-- Lang.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 3, 2020 at 5:41 AM Geoff Levner <<a href="mailto:glevner@gmail.com">glevner@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Here, by the way, is the stack trace leading to the failed assertion.<br>
Note #9: clang::CodeGen::CGOpenMPRuntime::emitForStaticFinish().<br>
<br>
#0  0x00007fb70fa44870 in abort () from /usr/lib64/libc.so.6<br>
#1  0x00007fb70fa3c0e6 in __assert_fail_base () from /usr/lib64/libc.so.6<br>
#2  0x00007fb70fa3c192 in __assert_fail () from /usr/lib64/libc.so.6<br>
#3  0x00007fb715ca1a68 in llvm::CallInst::init (this=0x51f6e10,<br>
FTy=0x51fd280, Func=0x51f6d28, Args=..., Bundles=...,<br>
    NameStr=...) at<br>
/u/geoff/llvmrepo/llvm-project/llvm/lib/IR/Instructions.cpp:453<br>
#4  0x00007fb7116a9e4e in llvm::CallInst::CallInst (this=0x51f6e10,<br>
Ty=0x51fd280, Func=0x51f6d28, Args=..., Bundles=...,<br>
    NameStr=..., InsertBefore=0x0) at<br>
/u/geoff/llvmrepo/llvm-project/llvm/include/llvm/IR/Instructions.h:1681<br>
#5  0x00007fb7116a9cf2 in llvm::CallInst::Create (Ty=0x51fd280,<br>
Func=0x51f6d28, Args=..., Bundles=..., NameStr=...,<br>
    InsertBefore=0x0) at<br>
/u/geoff/llvmrepo/llvm-project/llvm/include/llvm/IR/Instructions.h:1489<br>
#6  0x00007fb71171f1e0 in llvm::IRBuilderBase::CreateCall<br>
(this=0x7fffd4fdaac8, FTy=0x51fd280, Callee=0x51f6d28, Args=...,<br>
    OpBundles=..., Name=..., FPMathTag=0x0) at<br>
/u/geoff/llvmrepo/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2338<br>
#7  0x00007fb71171f2d5 in llvm::IRBuilderBase::CreateCall<br>
(this=0x7fffd4fdaac8, Callee=..., Args=..., OpBundles=..., Name=...,<br>
    FPMathTag=0x0) at<br>
/u/geoff/llvmrepo/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2356<br>
#8  0x00007fb7117124eb in<br>
clang::CodeGen::CodeGenFunction::EmitRuntimeCall (this=0x7fffd4fda9d0,<br>
callee=..., args=...,<br>
    name=...) at<br>
/u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGCall.cpp:4051<br>
#9  0x00007fb7118b601f in<br>
clang::CodeGen::CGOpenMPRuntime::emitForStaticFinish (this=0x4614460,<br>
CGF=..., Loc=...,<br>
    DKind=llvm::omp::OMPD_for) at<br>
/u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp:2875<br>
#10 0x00007fb71197c294 in<br>
clang::CodeGen::CodeGenFunction::<lambda(clang::CodeGen::CodeGenFunction&)>::operator()(clang::CodeGen::CodeGenFunction<br>
&) const (__closure=0x7fffd4fd8340, CGF=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:3048<br>
#11 0x00007fb71199754d in<br>
llvm::function_ref<void(clang::CodeGen::CodeGenFunction&)>::callback_fn<clang::CodeGen::CodeGenFunction::EmitOMPWorksharingLoop(const<br>
clang::OMPLoopDirective&, clang::Expr*, const CodeGenLoopBoundsTy&,<br>
const CodeGenDispatchBoundsTy&)::<lambda(clang::CodeGen::CodeGenFunction&)><br>
>(intptr_t, clang::CodeGen::CodeGenFunction &)<br>
(callable=140736766772032,<br>
    params#0=...) at<br>
/u/geoff/llvmrepo/llvm-project/llvm/include/llvm/ADT/STLExtras.h:186<br>
#12 0x00007fb71199ef91 in llvm::function_ref<void<br>
(clang::CodeGen::CodeGenFunction&)>::operator()(clang::CodeGen::CodeGenFunction&)<br>
const (this=0x7fffd4fd7b40, params#0=...) at<br>
/u/geoff/llvmrepo/llvm-project/llvm/include/llvm/ADT/STLExtras.h:203<br>
#13 0x00007fb71199d79a in<br>
clang::CodeGen::CodeGenFunction::OpenMPCancelExitStack::emitExit(clang::CodeGen::CodeGenFunction&,<br>
llvm::omp::Directive, llvm::function_ref<void<br>
(clang::CodeGen::CodeGenFunction&)>) (this=0x7fffd4fdb678, CGF=...,<br>
    Kind=llvm::omp::OMPD_for, CodeGen=...) at<br>
/u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CodeGenFunction.h:1361<br>
#14 0x00007fb71197d41e in<br>
clang::CodeGen::CodeGenFunction::EmitOMPWorksharingLoop(clang::OMPLoopDirective<br>
const&, clang::Expr*,<br>
llvm::function_ref<std::pair<clang::CodeGen::LValue,<br>
clang::CodeGen::LValue> (clang::CodeGen::CodeGenFunction&,<br>
clang::OMPExecutableDirective const&)> const&,<br>
llvm::function_ref<std::pair<llvm::Value*, llvm::Value*><br>
(clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective<br>
const&, clang::CodeGen::Address, clang::CodeGen::Address)> const&)<br>
(this=0x7fffd4fda9d0, S=...,<br>
    EUB=0x4cb7250, CodeGenLoopBounds=..., CGDispatchBounds=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:3050<br>
#15 0x00007fb71197f746 in emitWorksharingDirective (CGF=..., S=...,<br>
HasCancel=false)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:3335<br>
#16 0x00007fb71197f7b0 in<br>
clang::CodeGen::CodeGenFunction::<lambda(clang::CodeGen::CodeGenFunction&,<br>
clang::CodeGen::PrePostActionTy&)>::operator()(clang::CodeGen::CodeGenFunction<br>
&, clang::CodeGen::PrePostActionTy &) const (__closure=0x7fffd4fd8940,<br>
    CGF=...) at<br>
/u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:3346<br>
#17 0x00007fb71199771f in<br>
clang::CodeGen::RegionCodeGenTy::CallbackFn<clang::CodeGen::CodeGenFunction::EmitOMPForDirective(const<br>
clang::OMPForDirective&)::<lambda(clang::CodeGen::CodeGenFunction&,<br>
clang::CodeGen::PrePostActionTy&)> >(intptr_t,<br>
clang::CodeGen::CodeGenFunction &, clang::CodeGen::PrePostActionTy &)<br>
(CodeGen=140736766773568, CGF=..., Action=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.h:80<br>
#18 0x00007fb7118a8787 in clang::CodeGen::RegionCodeGenTy::operator()<br>
(this=0x4d7e948, CGF=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp:595<br>
#19 0x00007fb7118ab598 in (anonymous<br>
namespace)::CGOpenMPRegionInfo::EmitBody (this=0x4d7e8d0, CGF=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp:1041<br>
#20 0x00007fb7118cce36 in<br>
clang::CodeGen::CGOpenMPRuntime::emitInlinedDirective (this=0x4614460,<br>
CGF=...,<br>
    InnerKind=llvm::omp::OMPD_for, CodeGen=..., HasCancel=false)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp:6222<br>
#21 0x00007fb71197f8bd in<br>
clang::CodeGen::CodeGenFunction::EmitOMPForDirective<br>
(this=0x7fffd4fda9d0, S=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:3353<br>
#22 0x00007fb711952aeb in clang::CodeGen::CodeGenFunction::EmitStmt<br>
(this=0x7fffd4fda9d0, S=0x46c3b18, Attrs=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmt.cpp:202<br>
#23 0x00007fb7119537d3 in<br>
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope<br>
(this=0x7fffd4fda9d0, S=...,<br>
    GetLast=false, AggSlot=...) at<br>
/u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmt.cpp:453<br>
#24 0x00007fb7119534b6 in<br>
clang::CodeGen::CodeGenFunction::EmitCompoundStmt<br>
(this=0x7fffd4fda9d0, S=..., GetLast=false,<br>
    AggSlot=...) at<br>
/u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmt.cpp:404<br>
#25 0x00007fb7119532b8 in<br>
clang::CodeGen::CodeGenFunction::EmitSimpleStmt (this=0x7fffd4fda9d0,<br>
S=0x46c4750)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmt.cpp:377<br>
#26 0x00007fb711952547 in clang::CodeGen::CodeGenFunction::EmitStmt<br>
(this=0x7fffd4fda9d0, S=0x46c4750, Attrs=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmt.cpp:53<br>
#27 0x00007fb7119757e9 in<br>
clang::CodeGen::CodeGenFunction::<lambda(clang::CodeGen::CodeGenFunction&,<br>
clang::CodeGen::PrePostActionTy&)>::operator()(clang::CodeGen::CodeGenFunction<br>
&, clang::CodeGen::PrePostActionTy &) const (__closure=0x7fffd4fdc360,<br>
    CGF=..., Action=...) at<br>
/u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:1733<br>
#28 0x00007fb711996ecf in<br>
clang::CodeGen::RegionCodeGenTy::CallbackFn<clang::CodeGen::CodeGenFunction::EmitOMPParallelDirective(const<br>
clang::OMPParallelDirective&)::<lambda(clang::CodeGen::CodeGenFunction&,<br>
clang::CodeGen::PrePostActionTy&)> >(intptr_t,<br>
clang::CodeGen::CodeGenFunction &, clang::CodeGen::PrePostActionTy &)<br>
(CodeGen=140736766788448, CGF=..., Action=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.h:80<br>
#29 0x00007fb7118a8787 in clang::CodeGen::RegionCodeGenTy::operator()<br>
(this=0x7fffd4fda988, CGF=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp:595<br>
#30 0x00007fb7118ab598 in (anonymous<br>
namespace)::CGOpenMPRegionInfo::EmitBody (this=0x7fffd4fda910,<br>
CGF=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp:1041<br>
#31 0x00007fb71196e1e1 in<br>
clang::CodeGen::CodeGenFunction::GenerateOpenMPCapturedStmtFunction<br>
(this=0x7fffd4fda9d0, S=...,<br>
    Loc=...) at<br>
/u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:615<br>
#32 0x00007fb7118ace11 in emitParallelOrTeamsOutlinedFunction<br>
(CGM=..., D=..., CS=0x4a693a8, ThreadIDVar=0x49fe398,<br>
    InnermostKind=llvm::omp::OMPD_parallel, OutlinedHelperName=..., CodeGen=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp:1289<br>
#33 0x00007fb7118acec7 in<br>
clang::CodeGen::CGOpenMPRuntime::emitParallelOutlinedFunction<br>
(this=0x4614460, D=...,<br>
    ThreadIDVar=0x49fe398, InnermostKind=llvm::omp::OMPD_parallel, CodeGen=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp:1297<br>
#34 0x00007fb7119745c9 in emitCommonOMPParallelDirective (CGF=...,<br>
S=..., InnermostKind=llvm::omp::OMPD_parallel, CodeGen=...,<br>
    CodeGenBoundParameters=...) at<br>
/u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:1530<br>
#35 0x00007fb711975bd9 in<br>
clang::CodeGen::CodeGenFunction::EmitOMPParallelDirective<br>
(this=0x7fffd4fdc7e0, S=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:1740<br>
#36 0x00007fb711952aa5 in clang::CodeGen::CodeGenFunction::EmitStmt<br>
(this=0x7fffd4fdc7e0, S=0x4a695a8, Attrs=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmt.cpp:196<br>
#37 0x00007fb7119537d3 in<br>
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope<br>
(this=0x7fffd4fdc7e0, S=...,<br>
    GetLast=false, AggSlot=...) at<br>
/u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CGStmt.cpp:453<br>
#38 0x00007fb7119d69ec in<br>
clang::CodeGen::CodeGenFunction::EmitFunctionBody<br>
(this=0x7fffd4fdc7e0, Body=0x4a695e0)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1147<br>
#39 0x00007fb7119d75bc in<br>
clang::CodeGen::CodeGenFunction::GenerateCode (this=0x7fffd4fdc7e0,<br>
GD=..., Fn=0x4699718, FnInfo=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1312<br>
#40 0x00007fb7119facdf in<br>
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition<br>
(this=0x4b103a0, GD=..., GV=0x4699718)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:4528<br>
#41 0x00007fb7119f3f73 in<br>
clang::CodeGen::CodeGenModule::EmitGlobalDefinition (this=0x4b103a0,<br>
GD=..., GV=0x4699718)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2890<br>
#42 0x00007fb7119f0ec2 in clang::CodeGen::CodeGenModule::EmitDeferred<br>
(this=0x4b103a0)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2208<br>
#43 0x00007fb7119e8448 in clang::CodeGen::CodeGenModule::Release<br>
(this=0x4b103a0)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:399<br>
---Type <return> to continue, or q <return> to quit---<br>
#44 0x00007fb71166b523 in (anonymous<br>
namespace)::CodeGeneratorImpl::HandleTranslationUnit (this=0x4ceb9c0,<br>
Ctx=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:267<br>
#45 0x00007fb71163ff48 in<br>
clang::BackendConsumer::HandleTranslationUnit (this=0x49fc8d0, C=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:283<br>
#46 0x00007fb711dbf5f5 in<br>
clang::MultiplexConsumer::HandleTranslationUnit (this=0x2cc6290,<br>
Ctx=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/Frontend/MultiplexConsumer.cpp:292<br>
#47 0x00007fb71203fb15 in clang::ParseAST (S=..., PrintStats=false,<br>
SkipFunctionBodies=false)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/Parse/ParseAST.cpp:171<br>
#48 0x00007fb711d7fee7 in clang::ASTFrontendAction::ExecuteAction<br>
(this=0x41bcf20)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1058<br>
#49 0x00007fb71163b730 in clang::CodeGenAction::ExecuteAction (this=0x41bcf20)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1184<br>
#50 0x00007fb711d80137 in clang::WrapperFrontendAction::ExecuteAction<br>
(this=0x4cb8cd0)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1089<br>
#51 0x00007fb711d7f83f in clang::FrontendAction::Execute (this=0x4cb8cd0)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/Frontend/FrontendAction.cpp:950<br>
#52 0x00007fb711d0d96f in clang::CompilerInstance::ExecuteAction<br>
(this=0x7fffd4fe1ed0, Act=...)<br>
    at /u/geoff/llvmrepo/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:984<br>
<br>
On Mon, Aug 3, 2020 at 2:28 PM Geoff Levner <<a href="mailto:glevner@gmail.com" target="_blank">glevner@gmail.com</a>> wrote:<br>
><br>
> Greetings, Lang and other JITters,<br>
><br>
> Last week I moved our Orc v2-based app from top-of-tree to the new<br>
> 11.x branch, and it no longer handles C++ code containing OpenMP<br>
> directives correctly.<br>
><br>
> More specifically, if I JIT compile a function containing OpenMP<br>
> parallel/for pragmas, using a release version of LLVM, the code<br>
> compiles and seems to work, but if I try to write the module's bitcode<br>
> to file, I get the following error message:<br>
><br>
>     Invalid record (Producer: 'LLVM11.0.0' Reader: 'LLVM 11.0.0').<br>
><br>
> If I use a debug version of LLVM, compilation fails with a broken assertion:<br>
><br>
>     .../llvm/lib/IR/Instructions.cpp:455: void<br>
> llvm::CallInst::init(llvm::FunctionType*, llvm::Va<br>
> lue*, llvm::ArrayRef<llvm::Value*>,<br>
> llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, const<br>
> llvm::Twine&): Assertion `(i ><br>
> = FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType())<br>
> && "Calling a function with a bad signature!"' failed.<br>
><br>
> The same code compiles correctly using clang from the command line. It<br>
> also works fine using Orc v2 in the master branch of LLVM from the end<br>
> of May.<br>
><br>
> The problems are way too deep in the LLVM code for me to make any<br>
> sense of them... Does anybody else have a clue what might have<br>
> happened to Orc and/or OpenMP in the past couple months to trigger<br>
> this?<br>
><br>
> Geoff<br>
</blockquote></div>