[llvm-bugs] [Bug 45439] New: OpenMP `omp for collapse(2) ordered(2)` generates invalid IR

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 5 19:43:32 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45439

            Bug ID: 45439
           Summary: OpenMP `omp for collapse(2) ordered(2)` generates
                    invalid IR
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: OpenMP
          Assignee: unassignedclangbugs at nondot.org
          Reporter: t-kawashima at fujitsu.com
                CC: llvm-bugs at lists.llvm.org

[Envinronment]
OS: Linux
CPU: x86_64 and AArch64
LLVM/Clang/OpenMP: latest master branch (commit 74d44c43e8c)

When I compile `doacross.4.c` in the official 'OpenMP Examples Version 5.0.0'
<https://github.com/OpenMP/Examples/blob/v5.0.0/sources/Example_doacross.4.c>
into the LLVM IR and compile the generated IR, the IR verifier detects an
error.

----------------------------------------------------------------
$ clang -fopenmp -S -emit-llvm Example_doacross.4.c
$ clang -fopenmp Example_doacross.4.ll
Example_doacross.4.ll:91:9: error: stored value and pointer type do not match
  store i32 %64, i64* %59, align 8
        ^
1 error generated.
----------------------------------------------------------------

I created a small reproducer.

----------------------------------------------------------------
void work(int N, int M)
{
  #pragma omp for collapse(2) ordered(2)
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++)
      ;
}
----------------------------------------------------------------

When I compile the reproducer with the Clang/LLVM release build, the same error
occurs:

----------------------------------------------------------------
$ clang -fopenmp -S -emit-llvm reproducer.c 
$ clang -fopenmp reproducer.ll
reproducer.ll:76:9: error: stored value and pointer type do not match
  store i32 %50, i64* %45, align 8
        ^
1 error generated.
----------------------------------------------------------------

The generated IR:

----------------------------------------------------------------
42:                                               ; preds = %39
  %43 = bitcast [2 x %struct.kmp_dim]* %13 to i8*
  call void @llvm.memset.p0i8.i64(i8* align 8 %43, i8 0, i64 48, i1 false)
  %44 = getelementptr inbounds [2 x %struct.kmp_dim], [2 x %struct.kmp_dim]*
%13, i64 0, i64 0
  %45 = getelementptr inbounds %struct.kmp_dim, %struct.kmp_dim* %44, i32 0,
i32 1
  %46 = load i32, i32* %8, align 4
  %47 = sub nsw i32 %46, 0
  %48 = sub nsw i32 %47, 1
  %49 = add nsw i32 %48, 1
  %50 = sdiv i32 %49, 1
  store i32 %50, i64* %45, align 8 ; **** invalid IR ****
  %51 = getelementptr inbounds %struct.kmp_dim, %struct.kmp_dim* %44, i32 0,
i32 2
  store i64 1, i64* %51, align 8
  %52 = getelementptr inbounds [2 x %struct.kmp_dim], [2 x %struct.kmp_dim]*
%13, i64 0, i64 1
  %53 = getelementptr inbounds %struct.kmp_dim, %struct.kmp_dim* %52, i32 0,
i32 1
  %54 = load i32, i32* %9, align 4
  %55 = sub nsw i32 %54, 0
  %56 = sub nsw i32 %55, 1
  %57 = add nsw i32 %56, 1
  %58 = sdiv i32 %57, 1
  store i32 %58, i64* %53, align 8
  %59 = getelementptr inbounds %struct.kmp_dim, %struct.kmp_dim* %52, i32 0,
i32 2
  store i64 1, i64* %59, align 8
  %60 = getelementptr inbounds [2 x %struct.kmp_dim], [2 x %struct.kmp_dim]*
%13, i64 0, i64 0
  %61 = bitcast %struct.kmp_dim* %60 to i8*
  call void @__kmpc_doacross_init(%struct.ident_t* @0, i32 %20, i32 2, i8* %61)
  store i64 0, i64* %14, align 8
  %62 = load i64, i64* %10, align 8
  store i64 %62, i64* %15, align 8
  store i64 1, i64* %16, align 8
  store i32 0, i32* %17, align 4
  call void @__kmpc_for_static_init_8(%struct.ident_t* @1, i32 %20, i32 33,
i32* %17, i64* %14, i64* %15, i64* %16, i64 1, i64 1)
  br label %63
----------------------------------------------------------------

When I compile the reproducer with the Clang/LLVM debug build, an assersion
failure occurs:

----------------------------------------------------------------
$ clang -fopenmp -S -emit-llvm reproducer.c
clang: src/llvm/llvm/lib/IR/Instructions.cpp:1411: void
llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() ==
cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a
pointer
 to Val type!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:   
0.      Program arguments: opt/llvm/bin/clang -fopenmp -S -emit-llvm
reproducer.c
1.      <eof> parser at end of file
2.      reproducer.c:1:6: LLVM IR generation of declaration 'work'
3.      reproducer.c:1:6: Generating code for declaration 'work'
 #0 0x0000ffff9d3113e0 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
src/llvm/llvm/lib/Support/Unix/Signals.inc:564:22
 #1 0x0000ffff9d311488 PrintStackTraceSignalHandler(void*)
src/llvm/llvm/lib/Support/Unix/Signals.inc:625:1
 #2 0x0000ffff9d30f758 llvm::sys::RunSignalHandlers()
src/llvm/llvm/lib/Support/Signals.cpp:68:20
 #3 0x0000ffff9d310ca0 llvm::sys::CleanupOnSignal(unsigned long)
src/llvm/llvm/lib/Support/Unix/Signals.inc:361:31
 #4 0x0000ffff9d1b8684 (anonymous
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long)
src/llvm/llvm/lib/Support/CrashRecoveryContext.cpp:77:5
 #5 0x0000ffff9d1b8b5c CrashRecoverySignalHandler(int)
src/llvm/llvm/lib/Support/CrashRecoveryContext.cpp:383:1
 #6 0x0000ffffa65d066c  0x66c raise
 #7 0x0000ffffa65d066c
 #8 0x0000ffffa65d066c abort (+0x66c)
 #9 0x0000ffff9b1450e8 __assert_fail_base (/lib64/libc.so.6+0x350e8)
#10 0x0000ffff9b146760 __assert_perror_fail (/lib64/libc.so.6+0x36760)
#11 0x0000ffff9b13e5dc llvm::StoreInst::AssertOK()
src/llvm/llvm/lib/IR/Instructions.cpp:1409:3
#12 0x0000ffff9b13e694 llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*,
bool, llvm::MaybeAlign, llvm::AtomicOrdering, unsigned char,
llvm::Instruction*) src/llvm/llvm/lib/IR/Instructions.cpp:1452:1
#13 0x0000ffff9f246ec0 llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*,
bool, llvm::MaybeAlign, llvm::Instruction*)
src/llvm/llvm/lib/IR/Instructions.cpp:1433:51
#14 0x0000ffff9f2471a0 llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*,
bool, llvm::Instruction*) src/llvm/llvm/lib/IR/Instructions.cpp:1424:71
#15 0x0000ffff9f247080 llvm::IRBuilderBase::CreateStore(llvm::Value*,
llvm::Value*, bool) src/llvm/llvm/include/llvm/IR/IRBuilder.h:1696:18
#16 0x0000ffff9f246fe0 llvm::IRBuilderBase::CreateAlignedStore(llvm::Value*,
llvm::Value*, llvm::MaybeAlign, bool)
src/llvm/llvm/include/llvm/IR/IRBuilder.h:1790:32
#17 0x0000ffffa2bf61e8 clang::CodeGen::CGBuilderTy::CreateStore(llvm::Value*,
clang::CodeGen::Address, bool) src/llvm/clang/lib/CodeGen/CGBuilder.h:105:75
#18 0x0000ffffa2bf6370
clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*,
clang::CodeGen::Address, bool, clang::QualType, clang::CodeGen::LValueBaseInfo,
clang::CodeGen::TBAAAccessInfo, bool, bool)
src/llvm/clang/lib/CodeGen/CGExpr.cpp:1772:47
#19 0x0000ffffa2bf6e7c
clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*,
clang::CodeGen::LValue, bool) src/llvm/clang/lib/CodeGen/CGExpr.cpp:1788:1
#20 0x0000ffffa2dde448
clang::CodeGen::CGOpenMPRuntime::emitDoacrossInit(clang::CodeGen::CodeGenFunction&,
clang::OMPLoopDirective const&, llvm::ArrayRef<clang::Expr*>)
src/llvm/clang/lib/CodeGen/CGOpenMPRuntime.cpp:11216:57 
#21 0x0000ffffa2dde604
clang::CodeGen::CodeGenFunction::EmitOMPWorksharingLoop(clang::OMPLoopDirective
const&, clang::Expr*, llvm::function_ref<std::pair<clang::CodeGen::LValue,
clang::CodeGen::LValue> (clang::CodeGen::CodeGenFunction&,
clang::OMPExecutableDirective const&)> const&,
llvm::function_ref<std::pair<llvm::Value*, llvm::Value*>
(clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&,
clang::CodeGen::Address, clang::CodeGen::Address)> const&)
src/llvm/clang/lib/CodeGen/CGStmtOpenMP.cpp:2630:28
#22 0x0000ffffa2f0e7d0
clang::CodeGen::CodeGenFunction::EmitOMPForDirective(clang::OMPForDirective
const&)::'lambda'(clang::CodeGen::CodeGenFunction&,
clang::CodeGen::PrePostActionTy&)::operator()(clang::CodeGen::CodeGenFunction&,
clang::
CodeGen::PrePostActionTy&) const
src/llvm/clang/lib/CodeGen/CGStmtOpenMP.cpp:2855:49
#23 0x0000ffffa2fca608 void
clang::CodeGen::RegionCodeGenTy::CallbackFn<clang::CodeGen::CodeGenFunction::EmitOMPForDirective(clang::OMPForDirective
const&)::'lambda'(clang::CodeGen::CodeGenFunction&,
clang::CodeGen::PrePostActionTy&)>(long, clang::CodeGen::CodeGenFunction&,
clang::CodeGen::PrePostActionTy&)
src/llvm/clang/lib/CodeGen/CGOpenMPRuntime.h:78:64
#24 0x0000ffffa2fcb38c
clang::CodeGen::RegionCodeGenTy::operator()(clang::CodeGen::CodeGenFunction&)
const src/llvm/clang/lib/CodeGen/CGOpenMPRuntime.cpp:795:21
#25 0x0000ffffa2fddf18 (anonymous
namespace)::CGOpenMPRegionInfo::EmitBody(clang::CodeGen::CodeGenFunction&,
clang::Stmt const*) src/llvm/clang/lib/CodeGen/CGOpenMPRuntime.cpp:1231:27
#26 0x0000ffffa2ee1104
clang::CodeGen::CGOpenMPRuntime::emitInlinedDirective(clang::CodeGen::CodeGenFunction&,
llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&, bool)
src/llvm/clang/lib/CodeGen/CGOpenMPRuntime.cpp:6621:68
#27 0x0000ffffa2ee330c
clang::CodeGen::CodeGenFunction::EmitOMPForDirective(clang::OMPForDirective
const&) src/llvm/clang/lib/CodeGen/CGStmtOpenMP.cpp:2862:49
#28 0x0000ffffa2efda84 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
src/llvm/clang/lib/CodeGen/CGStmt.cpp:201:5
#29 0x0000ffffa2fcb47c
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
src/llvm/clang/lib/CodeGen/CGStmt.cpp:416:3
#30 0x0000ffffa2fa5460
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*)
src/llvm/clang/lib/CodeGen/CodeGenFunction.cpp:1184:1
#31 0x0000ffffa2fa5e38
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
src/llvm/clang/lib/CodeGen/CodeGenFunction.cpp:1346:21
#32 0x0000ffffa30256ac
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) src/llvm/clang/lib/CodeGen/CodeGenModule.cpp:4499:3
#33 0x0000ffffa3026098
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) src/llvm/clang/lib/CodeGen/CodeGenModule.cpp:2862:47
#34 0x0000ffffa30461f8
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
src/llvm/clang/lib/CodeGen/CodeGenModule.cpp:2615:5
#35 0x0000ffffa30407c4
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.localalias.1)
src/llvm/clang/lib/CodeGen/CodeGenModule.cpp:5307:37
#36 0x0000ffffa303f988 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
src/llvm/clang/lib/CodeGen/ModuleBuilder.cpp:169:7
#37 0x0000ffffa3049244
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
src/llvm/clang/lib/CodeGen/CodeGenAction.cpp:216:7
#38 0x0000ffffa31cfe84 clang::ParseAST(clang::Sema&, bool, bool)
src/llvm/clang/lib/Parse/ParseAST.cpp:162:49
#39 0x0000ffffa3015174 clang::ASTFrontendAction::ExecuteAction()
src/llvm/clang/lib/Frontend/FrontendAction.cpp:1047:11
#40 0x0000ffff980c796c clang::CodeGenAction::ExecuteAction()
src/llvm/clang/lib/CodeGen/CodeGenAction.cpp:1180:1
#41 0x0000ffffa226678c clang::FrontendAction::Execute()
src/llvm/clang/lib/Frontend/FrontendAction.cpp:944:38
#42 0x0000ffffa3011e90
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
src/llvm/clang/lib/Frontend/CompilerInstance.cpp:973:42
#43 0x0000ffffa22661c8
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
src/llvm/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:282:38
#44 0x0000ffffa21f5ba4 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) src/llvm/clang/tools/driver/cc1_main.cpp:240:40
#45 0x0000ffffa1e8efc0 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
src/llvm/clang/tools/driver/driver.cpp:330:20
#46 0x000000000044c4f8
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::'lambda'()::operator()() const
src/llvm/clang/lib/Driver/Job.cpp:417:32
#47 0x0000000000441be0 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::'lambda'()>(long)
src/llvm/llvm/include/llvm/ADT/STLExtras.h:109:40
#48 0x0000ffffa26aeb68 llvm::function_ref<void ()>::operator()() const
src/llvm/llvm/include/llvm/ADT/STLExtras.h:126:62
#49 0x0000ffffa26af238
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
src/llvm/llvm/lib/Support/CrashRecoveryContext.cpp:419:10
#50 0x0000ffff9d1b927c
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const src/llvm/clang/lib/Driver/Job.cpp:417:21
#51 0x0000ffff9d1b8d3c
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
src/llvm/clang/lib/Driver/Compilation.cpp:195:22
#52 0x0000ffffa26aecb4
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
src/llvm/clang/lib/Driver/Compilation.cpp:246:53     
#53 0x0000ffffa265c5d0
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
src/llvm/clang/lib/Driver/Driver.cpp:1483:28
#54 0x0000ffffa265c8e4 main src/llvm/clang/tools/driver/driver.cpp:502:39
#55 0x0000ffffa26708ac __libc_start_main
(opt/llvm/bin/../lib/libclangDriver.so.11git+0x1308ac)
#56 0x00000000004428e4 _start (opt/llvm/bin/clang+0x4428e4)
opt/llvm/bin/../lib/libLLVMSupport.so.11git(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x38)[0xffff9d3113e0]
opt/llvm/bin/../lib/libLLVMSupport.so.11git(+0x3d1488)[0xffff9d311488]
opt/llvm/bin/../lib/libLLVMSupport.so.11git(_ZN4llvm3sys17RunSignalHandlersEv+0x8c)[0xffff9d30f758]
opt/llvm/bin/../lib/libLLVMSupport.so.11git(_ZN4llvm3sys15CleanupOnSignalEm+0x88)[0xffff9d310ca0]
opt/llvm/bin/../lib/libLLVMSupport.so.11git(+0x278684)[0xffff9d1b8684]
opt/llvm/bin/../lib/libLLVMSupport.so.11git(+0x278b5c)[0xffff9d1b8b5c]
[0xffffa65d066c]
/lib64/libc.so.6(gsignal+0x4c)[0xffff9b1450e8]
/lib64/libc.so.6(abort+0x11c)[0xffff9b146760]
/lib64/libc.so.6(+0x2e5dc)[0xffff9b13e5dc]
/lib64/libc.so.6(__assert_perror_fail+0x0)[0xffff9b13e694]
opt/llvm/bin/../lib/libLLVMCore.so.11git(_ZN4llvm9StoreInst8AssertOKEv+0xf4)[0xffff9f246ec0]
opt/llvm/bin/../lib/libLLVMCore.so.11git(_ZN4llvm9StoreInstC2EPNS_5ValueES2_bNS_10MaybeAlignENS_14AtomicOrderingEhPNS_11InstructionE+0xc4)[0xffff9f2471a0]
opt/llvm/bin/../lib/libLLVMCore.so.11git(_ZN4llvm9StoreInstC1EPNS_5ValueES2_bNS_10MaybeAlignEPNS_11InstructionE+0x44)[0xffff9f247080]
opt/llvm/bin/../lib/libLLVMCore.so.11git(_ZN4llvm9StoreInstC2EPNS_5ValueES2_bPNS_11InstructionE+0x44)[0xffff9f246fe0]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(+0x3161e8)[0xffffa2bf61e8]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(+0x316370)[0xffffa2bf6370]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(+0x316e7c)[0xffffa2bf6e7c]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang7CodeGen15CodeGenFunction17EmitStoreOfScalarEPN4llvm5ValueENS0_7AddressEbNS_8QualTypeENS0_14LValueBaseInfoENS0_14TBAAAccessInfoEbb+0x378)[0xffffa2dde448] 
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang7CodeGen15CodeGenFunction17EmitStoreOfScalarEPN4llvm5ValueENS0_6LValueEb+0xd4)[0xffffa2dde604]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang7CodeGen15CGOpenMPRuntime16emitDoacrossInitERNS0_15CodeGenFunctionERKNS_16OMPLoopDirectiveEN4llvm8ArrayRefIPNS_4ExprEEE+0x3b4)[0xffffa2f0e7d0]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang7CodeGen15CodeGenFunction22EmitOMPWorksharingLoopERKNS_16OMPLoopDirectiveEPNS_4ExprERKN4llvm12function_refIFSt4pairINS0_6LValueESA_ERS1_RKNS_22OMPExecutableDirectiveEEEERKNS8_IFS9_IPNS7_5ValueESL_ESC_SF_NS0_7AddressESN_EEE+0x24c)[0xffffa2fca608]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(+0x6eb38c)[0xffffa2fcb38c]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(+0x6fdf18)[0xffffa2fddf18]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZNK5clang7CodeGen15RegionCodeGenTyclERNS0_15CodeGenFunctionE+0xa0)[0xffffa2ee1104]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(+0x60330c)[0xffffa2ee330c]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang7CodeGen15CGOpenMPRuntime20emitInlinedDirectiveERNS0_15CodeGenFunctionEN4llvm3omp9DirectiveERKNS0_15RegionCodeGenTyEb+0x7c)[0xffffa2efda84]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang7CodeGen15CodeGenFunction19EmitOMPForDirectiveERKNS_15OMPForDirectiveE+0xcc)[0xffffa2fcb47c]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang7CodeGen15CodeGenFunction8EmitStmtEPKNS_4StmtEN4llvm8ArrayRefIPKNS_4AttrEEE+0x4f8)[0xffffa2fa5460]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang7CodeGen15CodeGenFunction28EmitCompoundStmtWithoutScopeERKNS_12CompoundStmtEbNS0_12AggValueSlotE+0x250)[0xffffa2fa5e38]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang7CodeGen15CodeGenFunction16EmitFunctionBodyEPKNS_4StmtE+0x74)[0xffffa30256ac]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang7CodeGen15CodeGenFunction12GenerateCodeENS_10GlobalDeclEPN4llvm8FunctionERKNS0_14CGFunctionInfoE+0x3c0)[0xffffa3026098]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang7CodeGen13CodeGenModule28EmitGlobalFunctionDefinitionENS_10GlobalDeclEPN4llvm11GlobalValueE+0x144)[0xffffa30461f8]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang7CodeGen13CodeGenModule20EmitGlobalDefinitionENS_10GlobalDeclEPN4llvm11GlobalValueE+0x1f8)[0xffffa30407c4]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang7CodeGen13CodeGenModule10EmitGlobalENS_10GlobalDeclE+0x6a4)[0xffffa303f988]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang7CodeGen13CodeGenModule16EmitTopLevelDeclEPNS_4DeclE+0x84)[0xffffa3049244]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(+0x8efe84)[0xffffa31cfe84]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(+0x735174)[0xffffa3015174]
opt/llvm/bin/../lib/../lib/libclangParse.so.11git(_ZN5clang8ParseASTERNS_4SemaEbb+0x1cc)[0xffff980c796c]
opt/llvm/bin/../lib/libclangFrontend.so.11git(_ZN5clang17ASTFrontendAction13ExecuteActionEv+0x168)[0xffffa226678c]
opt/llvm/bin/../lib/libclangCodeGen.so.11git(_ZN5clang13CodeGenAction13ExecuteActionEv+0x5e8)[0xffffa3011e90]
opt/llvm/bin/../lib/libclangFrontend.so.11git(_ZN5clang14FrontendAction7ExecuteEv+0x84)[0xffffa22661c8]
opt/llvm/bin/../lib/libclangFrontend.so.11git(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x5f4)[0xffffa21f5ba4]
opt/llvm/bin/../lib/libclangFrontendTool.so.11git(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x550)[0xffffa1e8efc0]
opt/llvm/bin/clang(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0x3e4)[0x44c4f8]
opt/llvm/bin/clang[0x441be0]
opt/llvm/bin/../lib/libclangDriver.so.11git(+0x16eb68)[0xffffa26aeb68]
opt/llvm/bin/../lib/libclangDriver.so.11git(+0x16f238)[0xffffa26af238]
opt/llvm/bin/../lib/libLLVMSupport.so.11git(+0x27927c)[0xffff9d1b927c]
opt/llvm/bin/../lib/libLLVMSupport.so.11git(_ZN4llvm20CrashRecoveryContext9RunSafelyENS_12function_refIFvvEEE+0xc0)[0xffff9d1b8d3c]
opt/llvm/bin/../lib/libclangDriver.so.11git(_ZNK5clang6driver10CC1Command7ExecuteEN4llvm8ArrayRefINS2_8OptionalINS2_9StringRefEEEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPb+0x138)[0xffffa26aecb4] 
opt/llvm/bin/../lib/libclangDriver.so.11git(_ZNK5clang6driver11Compilation14ExecuteCommandERKNS0_7CommandERPS3_+0x29c)[0xffffa265c5d0]
opt/llvm/bin/../lib/libclangDriver.so.11git(_ZNK5clang6driver11Compilation11ExecuteJobsERKNS0_7JobListERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x94)[0xffffa265c8e4]
opt/llvm/bin/../lib/libclangDriver.so.11git(_ZN5clang6driver6Driver18ExecuteCompilationERNS0_11CompilationERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x104)[0xffffa26708ac]
opt/llvm/bin/clang(main+0xadc)[0x4428e4]
/lib64/libc.so.6(__libc_start_main+0xf0)[0xffff9b1315d4]
opt/llvm/bin/clang[0x4408dc]
clang-11: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 11.0.0 (git@****:****/****.git
74d44c43e8caa5d325106b0587ea030360ed01c9)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: opt/llvm/bin
clang-11: note: diagnostic msg:
----------------------------------------------------------------

Debugging with gdb:

----------------------------------------------------------------
(gdb) bt
#0  0x0000ffffb33350e8 in raise () from /lib64/libc.so.6
#1  0x0000ffffb3336760 in abort () from /lib64/libc.so.6
#2  0x0000ffffb332e5dc in __assert_fail_base () from /lib64/libc.so.6
#3  0x0000ffffb332e694 in __assert_fail () from /lib64/libc.so.6
#4  0x0000ffffb7436ec0 in llvm::StoreInst::AssertOK (this=0x58f980) at
src/llvm/llvm/lib/IR/Instructions.cpp:1409
#5  0x0000ffffb74371a0 in llvm::StoreInst::StoreInst (this=0x58f980,
val=0x58f8e0, addr=0x58f618, isVolatile=false, Align=...,
Order=llvm::NotAtomic, SSID=1 '\001', InsertBefore=0x0) at
src/llvm/llvm/lib/IR/Instructions.cpp:1451
#6  0x0000ffffb7437080 in llvm::StoreInst::StoreInst (this=0x58f980,
val=0x58f8e0, addr=0x58f618, isVolatile=false, Align=..., InsertBefore=0x0) at
src/llvm/llvm/lib/IR/Instructions.cpp:1433
#7  0x0000ffffb7436fe0 in llvm::StoreInst::StoreInst (this=0x58f980,
val=0x58f8e0, addr=0x58f618, isVolatile=false, InsertBefore=0x0) at
src/llvm/llvm/lib/IR/Instructions.cpp:1424
#8  0x0000ffffbade61e8 in llvm::IRBuilderBase::CreateStore
(this=0xffffffff8558, Val=0x58f8e0, Ptr=0x58f618, isVolatile=false) at
src/llvm/llvm/include/llvm/IR/IRBuilder.h:1696
#9  0x0000ffffbade6370 in llvm::IRBuilderBase::CreateAlignedStore
(this=0xffffffff8558, Val=0x58f8e0, Ptr=0x58f618, Align=..., isVolatile=false)
at src/llvm/llvm/include/llvm/IR/IRBuilder.h:1790
#10 0x0000ffffbade6e7c in clang::CodeGen::CGBuilderTy::CreateStore
(this=0xffffffff8558, Val=0x58f8e0, Addr=..., IsVolatile=false) at
src/llvm/clang/lib/CodeGen/CGBuilder.h:104
#11 0x0000ffffbafce448 in clang::CodeGen::CodeGenFunction::EmitStoreOfScalar
(this=0xffffffff8470, Value=0x58f8e0, Addr=..., Volatile=false, Ty=...,
BaseInfo=..., TBAAInfo=..., isInit=false, isNontemporal=false) at
src/llvm/clang/lib/CodeGen/CGExpr.cpp:1772
#12 0x0000ffffbafce604 in clang::CodeGen::CodeGenFunction::EmitStoreOfScalar
(this=0xffffffff8470, value=0x58f8e0, lvalue=..., isInit=false) at
src/llvm/clang/lib/CodeGen/CGExpr.cpp:1785
#13 0x0000ffffbb0fe7d0 in clang::CodeGen::CGOpenMPRuntime::emitDoacrossInit
(this=0x52f530, CGF=..., D=..., NumIterations=...) at
src/llvm/clang/lib/CodeGen/CGOpenMPRuntime.cpp:11213
#14 0x0000ffffbb1ba608 in
clang::CodeGen::CodeGenFunction::EmitOMPWorksharingLoop(clang::OMPLoopDirective
const&, clang::Expr*, llvm::function_ref<std::pair<clang::CodeGen::LValue,
clang::CodeGen::LValue> (clang::CodeGen::CodeGenFunction&,
clang::OMPExecutableDirective const&)> const&,
llvm::function_ref<std::pair<llvm::Value*, llvm::Value*>
(clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&,
clang::CodeGen::Address, clang::CodeGen::Address)> const&)
(this=0xffffffff8470, S=..., EUB=0x5884a0, CodeGenLoopBounds=...,
CGDispatchBounds=...) at src/llvm/clang/lib/CodeGen/CGStmtOpenMP.cpp:2630
#15 0x0000ffffbb1bb38c in
clang::CodeGen::CodeGenFunction::<lambda(clang::CodeGen::CodeGenFunction&,
clang::CodeGen::PrePostActionTy&)>::operator()(clang::CodeGen::CodeGenFunction
&, clang::CodeGen::PrePostActionTy &) const (__closure=0xffffffff80a0, CGF=...)
at src/llvm/clang/lib/CodeGen/CGStmtOpenMP.cpp:2855
#16 0x0000ffffbb1cdf18 in
clang::CodeGen::RegionCodeGenTy::CallbackFn<clang::CodeGen::CodeGenFunction::EmitOMPForDirective(const
clang::OMPForDirective&)::<lambda(clang::CodeGen::CodeGenFunction&,
clang::CodeGen::PrePostActionTy&)> >(intptr_t, clang::CodeGen::CodeGenFunction
&, clang::CodeGen::PrePostActionTy &) (CodeGen=281474976678048, CGF=...,
Action=...) at src/llvm/clang/lib/CodeGen/CGOpenMPRuntime.h:78
#17 0x0000ffffbb0d1104 in clang::CodeGen::RegionCodeGenTy::operator()
(this=0x58aeb8, CGF=...) at src/llvm/clang/lib/CodeGen/CGOpenMPRuntime.cpp:796
#18 0x0000ffffbb0d330c in (anonymous namespace)::CGOpenMPRegionInfo::EmitBody
(this=0x58ae40, CGF=...) at src/llvm/clang/lib/CodeGen/CGOpenMPRuntime.cpp:1230
#19 0x0000ffffbb0eda84 in clang::CodeGen::CGOpenMPRuntime::emitInlinedDirective
(this=0x52f530, CGF=..., InnerKind=llvm::omp::OMPD_for, CodeGen=...,
HasCancel=false) at src/llvm/clang/lib/CodeGen/CGOpenMPRuntime.cpp:6622
#20 0x0000ffffbb1bb47c in clang::CodeGen::CodeGenFunction::EmitOMPForDirective
(this=0xffffffff8470, S=...) at
src/llvm/clang/lib/CodeGen/CGStmtOpenMP.cpp:2863
#21 0x0000ffffbb195460 in clang::CodeGen::CodeGenFunction::EmitStmt
(this=0xffffffff8470, S=0x588c60, Attrs=...) at
src/llvm/clang/lib/CodeGen/CGStmt.cpp:200
#22 0x0000ffffbb195e38 in
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope
(this=0xffffffff8470, S=..., GetLast=false, AggSlot=...) at
src/llvm/clang/lib/CodeGen/CGStmt.cpp:451
#23 0x0000ffffbb2156ac in clang::CodeGen::CodeGenFunction::EmitFunctionBody
(this=0xffffffff8470, Body=0x588da0) at
src/llvm/clang/lib/CodeGen/CodeGenFunction.cpp:1181
#24 0x0000ffffbb216098 in clang::CodeGen::CodeGenFunction::GenerateCode
(this=0xffffffff8470, GD=..., Fn=0x55bd68, FnInfo=...) at
src/llvm/clang/lib/CodeGen/CodeGenFunction.cpp:1346
#25 0x0000ffffbb2361f8 in
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition (this=0x52c600,
GD=..., GV=0x55bd68) at src/llvm/clang/lib/CodeGen/CodeGenModule.cpp:4499
#26 0x0000ffffbb2307c4 in clang::CodeGen::CodeGenModule::EmitGlobalDefinition
(this=0x52c600, GD=..., GV=0x0) at
src/llvm/clang/lib/CodeGen/CodeGenModule.cpp:2862
#27 0x0000ffffbb22f988 in clang::CodeGen::CodeGenModule::EmitGlobal
(this=0x52c600, GD=...) at src/llvm/clang/lib/CodeGen/CodeGenModule.cpp:2614
#28 0x0000ffffbb239244 in clang::CodeGen::CodeGenModule::EmitTopLevelDecl
(this=0x52c600, D=0x55fe88) at
src/llvm/clang/lib/CodeGen/CodeGenModule.cpp:5304
#29 0x0000ffffbb3bfe84 in (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl (this=0x52bc30, DG=...) at
src/llvm/clang/lib/CodeGen/ModuleBuilder.cpp:170
#30 0x0000ffffbb205174 in clang::BackendConsumer::HandleTopLevelDecl
(this=0x52ba50, D=...) at src/llvm/clang/lib/CodeGen/CodeGenAction.cpp:214
#31 0x0000ffffb02b796c in clang::ParseAST (S=..., PrintStats=false,
SkipFunctionBodies=false) at src/llvm/clang/lib/Parse/ParseAST.cpp:162
#32 0x0000ffffba45678c in clang::ASTFrontendAction::ExecuteAction
(this=0x50f250) at src/llvm/clang/lib/Frontend/FrontendAction.cpp:1047
#33 0x0000ffffbb201e90 in clang::CodeGenAction::ExecuteAction (this=0x50f250)
at src/llvm/clang/lib/CodeGen/CodeGenAction.cpp:1179
#34 0x0000ffffba4561c8 in clang::FrontendAction::Execute (this=0x50f250) at
src/llvm/clang/lib/Frontend/FrontendAction.cpp:940
#35 0x0000ffffba3e5ba4 in clang::CompilerInstance::ExecuteAction
(this=0x509150, Act=...) at
src/llvm/clang/lib/Frontend/CompilerInstance.cpp:973
#36 0x0000ffffba07efc0 in clang::ExecuteCompilerInvocation (Clang=0x509150) at
src/llvm/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:282
#37 0x000000000044c4f8 in cc1_main (Argv=..., Argv0=0x503940 "clang-11",
MainAddr=0x4409ac <GetExecutablePath[abi:cxx11](char const*, bool)>) at
src/llvm/clang/tools/driver/cc1_main.cpp:240
#38 0x0000000000441be0 in ExecuteCC1Tool (ArgV=...) at
src/llvm/clang/tools/driver/driver.cpp:330
#39 0x0000ffffba89eb68 in
clang::driver::CC1Command::<lambda()>::operator()(void) const
(__closure=0xffffffffcfd8) at src/llvm/clang/lib/Driver/Job.cpp:417
#40 0x0000ffffba89f238 in
llvm::function_ref<void()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::string*, bool*) const::<lambda()> >(intptr_t)
(callable=281474976698328) at src/llvm/llvm/include/llvm/ADT/STLExtras.h:108
#41 0x0000ffffb53a927c in llvm::function_ref<void ()>::operator()() const
(this=0xffffffffcb08) at src/llvm/llvm/include/llvm/ADT/STLExtras.h:126
#42 0x0000ffffb53a8d3c in
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(this=0xffffffffcb90, Fn=...) at
src/llvm/llvm/lib/Support/CrashRecoveryContext.cpp:418
#43 0x0000ffffba89ecb4 in clang::driver::CC1Command::Execute (this=0x508b90,
Redirects=..., ErrMsg=0xffffffffd070, ExecutionFailed=0xffffffffd06f) at
src/llvm/clang/lib/Driver/Job.cpp:417
#44 0x0000ffffba84c5d0 in clang::driver::Compilation::ExecuteCommand
(this=0x507af0, C=..., FailingCommand=@0xffffffffd168: 0x0) at
src/llvm/clang/lib/Driver/Compilation.cpp:195
#45 0x0000ffffba84c8e4 in clang::driver::Compilation::ExecuteJobs
(this=0x507af0, Jobs=..., FailingCommands=...) at
src/llvm/clang/lib/Driver/Compilation.cpp:246
#46 0x0000ffffba8608ac in clang::driver::Driver::ExecuteCompilation
(this=0xffffffffd398, C=..., FailingCommands=...) at
src/llvm/clang/lib/Driver/Driver.cpp:1480
#47 0x00000000004428e4 in main (argc_=6, argv_=0xffffffffeab8) at
src/llvm/clang/tools/driver/driver.cpp:502

(gdb) frame 4
#4  0x0000ffffb7436ec0 in llvm::StoreInst::AssertOK (this=0x58f980) at
src/llvm/llvm/lib/IR/Instructions.cpp:1409
1409      assert(getOperand(0)->getType() ==

(gdb) call getOperand(0)->getType()->dump()
i32

(gdb) call getOperand(1)->getType()->dump()
i64*
----------------------------------------------------------------

If I change `int` to `long` in the reproducer, the compilation succeeds.

----------------------------------------------------------------
void work(long N, long M)
{
  #pragma omp for collapse(2) ordered(2)
  for (long i = 0; i < N; i++)
    for (long j = 0; j < M; j++)
      ;
}
----------------------------------------------------------------

-- 
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/20200406/3a4cd7aa/attachment-0001.html>


More information about the llvm-bugs mailing list