[llvm-bugs] [Bug 46867] New: compile-time crash when using target enter data to map a constexpr array

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 27 20:04:10 PDT 2020


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

            Bug ID: 46867
           Summary: compile-time crash when using target enter data to map
                    a constexpr array
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Clang Compiler Support
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bertoni at anl.gov
                CC: llvm-bugs at lists.llvm.org

Hello,

Issue:
I see a compile-time crash when a constexpr array is used in a "target enter
data" construct. Reproducer below, which was cut down from a bigger code. 
This is minor, it compiles and runs fine either without `constexpr` or just
with `const` instead of `constexpr`, but it would be nice if it didn't crash
the compiler.


# Steps to reproduce:
```
$ cat t.cpp 
#define LENGTH 2
int main()
{
  constexpr double h_chebyshev_coefs[LENGTH] = { 0, 0 };
#pragma omp target enter data map(to:h_chebyshev_coefs[0:LENGTH])
  return 0;
}


$ clang++ -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda t.cpp 
clang-12:
/gpfs/jlse-fs0/users/yeluo/opt/llvm-clang/llvm-project/clang/lib/CodeGen/CGExpr.cpp:2724:
clang::CodeGen::LValue clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(const
clang::DeclRefExpr *): Assertion `(ND->isUsed(fal\
se) || !isa<VarDecl>(ND) || E->isNonOdrUse() || !E->getLocation().isValid()) &&
"Should not use decl without marking it used!"' 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: /soft/compilers/llvm/master-20200727/bin/clang-12
-cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -emit-llvm-uselists
-disable-free -main-file-name t.cpp -mrelocation-model static
-mframe-pointer=al\
l -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables
-target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/soft/compilers/llvm/master-20200727/lib/clang/12.0.0 -c-isystem /soft/compil\
ers/cuda/cuda-10.0.130/include -internal-isystem
/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0/../../../../include/c++/7.4.0
-internal-isystem /soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/\
x86_64-pc-linux-gnu/7.4.0/../../../../include/c++/7.4.0/x86_64-pc-linux-gnu
-internal-isystem
/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0/../../../../include/c++/7.4.0/backward
-internal-isystem\

/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0/../../../../include/c++/7.4.0
-internal-isystem
/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0/../../../../include/c+\
+/7.4.0/x86_64-pc-linux-gnu -internal-isystem
/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0/../../../../include/c++/7.4.0/backward
-internal-isystem /usr/local/include -internal-isystem /soft/comp\
ilers/llvm/master-20200727/lib/clang/12.0.0/include -internal-externc-isystem
/include -internal-externc-isystem /usr/include -internal-isystem
/usr/local/include -internal-isystem
/soft/compilers/llvm/master-20200727/lib/clang/1\
2.0.0/include -internal-externc-isystem /include -internal-externc-isystem
/usr/include -fdeprecated-macro -fdebug-compilation-dir /home/bertoni/tmp
-ferror-limit 19 -fopenmp -fopenmp-cuda-parallel-target-regions
-fgnuc-version=4\
.2.1 -fcxx-exceptions -fexceptions -disable-llvm-passes
-fopenmp-targets=nvptx64-nvidia-cuda -faddrsig -o /tmp/t-ac7105.bc -x c++ t.cpp
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      t.cpp:2:5: Generating code for declaration 'main'
 #0 0x0000000002833ae4 PrintStackTraceSignalHandler(void*)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2833ae4)
 #1 0x00000000028316ee llvm::sys::RunSignalHandlers()
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x28316ee)
 #2 0x0000000002833e05 SignalHandler(int)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2833e05)
 #3 0x00007f4c41bfd630 __restore_rt (/lib64/libpthread.so.0+0xf630)
 #4 0x00007f4c4076d377 raise (/lib64/libc.so.6+0x36377)
 #5 0x00007f4c4076ea68 abort (/lib64/libc.so.6+0x37a68)
 #6 0x00007f4c40766196 __assert_fail_base (/lib64/libc.so.6+0x2f196)
 #7 0x00007f4c40766242 (/lib64/libc.so.6+0x2f242)
 #8 0x0000000002d01492
clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2d01492)
 #9 0x0000000002cf539c clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr
const*) (/soft/compilers/llvm/master-20200727/bin/clang-12+0x2cf539c)
#10 0x0000000002ac167b
clang::CodeGen::CodeGenFunction::EmitOMPSharedLValue(clang::Expr const*)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2ac167b)
#11 0x0000000002dfd109 (anonymous
namespace)::MappableExprsHandler::generateInfoForComponentList(clang::OpenMPMapClauseKind,
llvm::ArrayRef<clang::OpenMPMapModifierKind>,
llvm::ArrayRef<clang::OMPClauseMappableExprCommon::Mappabl\
eComponent>, (anonymous namespace)::MappableExprsHandler::MapCombinedInfoTy&,
(anonymous namespace)::MappableExprsHandler::StructRangeInfoTy&, bool, bool,
clang::ValueDecl const*, bool, llvm::ArrayRef<llvm::ArrayRef<clang::OMPCla\
useMappableExprCommon::MappableComponent> >) const
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2dfd109)
#12 0x0000000002e0fdc5 (anonymous
namespace)::MappableExprsHandler::generateAllInfo((anonymous
namespace)::MappableExprsHandler::MapCombinedInfoTy&,
llvm::DenseSet<clang::CanonicalDeclPtr<clang::Decl const>,
llvm::DenseMapInfo<cl\
ang::CanonicalDeclPtr<clang::Decl const> > > const&) const
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2e0fdc5)
#13 0x0000000002e18068
clang::CodeGen::CGOpenMPRuntime::emitTargetDataStandAloneCall(clang::CodeGen::CodeGenFunction&,
clang::OMPExecutableDirective const&, clang::Expr const*, clang::Expr
const*)::$_37::operator()(clang::CodeGen\
::CodeGenFunction&, clang::CodeGen::PrePostActionTy&) const
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2e18068)
#14 0x0000000002def89d
clang::CodeGen::CGOpenMPRuntime::emitTargetDataStandAloneCall(clang::CodeGen::CodeGenFunction&,
clang::OMPExecutableDirective const&, clang::Expr const*, clang::Expr const*)
(/soft/compilers/llvm/master-202\
00727/bin/clang-12+0x2def89d)
#15 0x0000000002ae4445
clang::CodeGen::CodeGenFunction::EmitOMPTargetEnterDataDirective(clang::OMPTargetEnterDataDirective
const&) (/soft/compilers/llvm/master-20200727/bin/clang-12+0x2ae4445)
#16 0x0000000002ab0ea3 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2ab0ea3)
#17 0x0000000002abad00
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2abad00)
#18 0x0000000002b109fb
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2b109fb)
#19 0x0000000002b2f2e2
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2b2f2e2)
#20 0x0000000002b27e6c
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2b27e6c)
#21 0x0000000002b1b200 clang::CodeGen::CodeGenModule::EmitDeferred()
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2b1b200)
#22 0x0000000002b19f69 clang::CodeGen::CodeGenModule::Release()
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2b19f69)
#23 0x000000000365ef74 (anonymous
namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x365ef74)
#24 0x000000000365bcea
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x365bcea)
#25 0x00000000040dc5e3 clang::ParseAST(clang::Sema&, bool, bool)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x40dc5e3)
#26 0x000000000301e5d3 clang::FrontendAction::Execute()
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x301e5d3)
#27 0x0000000002fb4e23
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x2fb4e23)
#28 0x00000000030cb1a2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0x30cb1a2)
#29 0x0000000000a44008 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/soft/compilers/llvm/master-20200727/bin/clang-12+0xa44008)
#30 0x0000000000a4206c ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/soft/compilers/llvm/master-20200727/bin/clang-12+0xa4206c)
#31 0x0000000000a41d21 main
(/soft/compilers/llvm/master-20200727/bin/clang-12+0xa41d21)
#32 0x00007f4c40759545 __libc_start_main (/lib64/libc.so.6+0x22545)
#33 0x0000000000a3ed4d _start
(/soft/compilers/llvm/master-20200727/bin/clang-12+0xa3ed4d)
clang-12: error: unable to execute command: Aborted
clang-12: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 12.0.0
(/gpfs/jlse-fs0/users/yeluo/opt/llvm-clang/llvm-project/clang
fa1145a8d2f1bd00a60d0ed4572901d2b1403157)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /soft/compilers/llvm/master-nightly/bin
clang-12: note: diagnostic msg: Error generating preprocessed source(s).
```

# Compiler version:
```
$ clang++ -v
clang version 12.0.0
(/gpfs/jlse-fs0/users/yeluo/opt/llvm-clang/llvm-project/clang
fa1145a8d2f1bd00a60d0ed4572901d2b1403157)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /soft/compilers/llvm/master-nightly/bin
Found candidate GCC installation:
/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0
Selected GCC installation:
/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /soft/compilers/cuda/cuda-10.0.130, version 10.0
```

# Platform:
x86 + Nvidia V100


Thanks,
Colleen

-- 
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/20200728/a6cf7723/attachment-0001.html>


More information about the llvm-bugs mailing list