[llvm-bugs] [Bug 46688] New: omp_pteam_mem_alloc memory "Invalid constantexpr cast"

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jul 11 15:15:13 PDT 2020


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

            Bug ID: 46688
           Summary: omp_pteam_mem_alloc memory "Invalid constantexpr cast"
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Clang Compiler Support
          Assignee: unassignedclangbugs at nondot.org
          Reporter: xw111luoye at gmail.com
                CC: llvm-bugs at lists.llvm.org

In the following example,
  T base[2];
  #pragma omp allocate(base) allocator(omp_pteam_mem_alloc)
  compute_prefactor(team_id, base);
calling function compute_prefactor with the base caused compiler error.

Reproducer
https://github.com/ye-luo/openmp-target/blob/master/hands-on/tests/allocator/omp_pteam_mem_alloc.cpp

$ clang++ -fopenmp -fopenmp-targets=nvptx64 omp_pteam_mem_alloc.cpp
clang-11: warning: Unknown CUDA version 11.0. Assuming the latest supported
version 10.1 [-Wunknown-cuda-version]
clang-11:
/home/yeluo/opt/llvm-clang/llvm-project/llvm/lib/IR/Constants.cpp:1785: static
llvm::Constant *llvm::ConstantExpr::getCast(unsigned int, llvm::Constant *,
llvm::Type *, bool): Assertion `CastInst::castIsValid(opc, C, Ty) && "Invalid
constantexpr cast!"' 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/dev-20200711/bin/clang-11 -cc1 -triple
nvptx64 -aux-triple x86_64-unknown-linux-gnu -S -disable-free -main-file-name
omp_pteam_mem_alloc.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all
-fno-rounding-math -fno-verbose-asm -no-integrated-as -mlink-builtin-bitcode
/usr/local/cuda-11.0/nvvm/libdevice/libdevice.10.bc -target-feature +ptx70
-target-sdk-version=11.0 -mlink-builtin-bitcode
/opt/llvm/dev-20200711/lib/libomptarget-nvptx-sm_61.bc -target-cpu sm_61
-fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/opt/llvm/dev-20200711/lib/clang/11.0.0 -internal-isystem
/opt/llvm/dev-20200711/lib/clang/11.0.0/include/openmp_wrappers -include
__clang_openmp_device_functions.h -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward
-internal-isystem /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward
-internal-isystem /usr/local/include -internal-isystem
/opt/llvm/dev-20200711/lib/clang/11.0.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -internal-isystem /usr/local/include
-internal-isystem /opt/llvm/dev-20200711/lib/clang/11.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir
/home/yeluo/opt/openmp-target/hands-on/tests/allocator -ferror-limit 19
-fopenmp -fopenmp-cuda-parallel-target-regions -fgnuc-version=4.2.1
-fcxx-exceptions -fexceptions -fcolor-diagnostics -fopenmp-is-device
-fopenmp-host-ir-file-path /tmp/omp_pteam_mem_alloc-9ac7dd.bc -o
/tmp/omp_pteam_mem_alloc-dafb3e.s -x c++ omp_pteam_mem_alloc.cpp 
1.      <eof> parser at end of file
2.      omp_pteam_mem_alloc.cpp:14:6: instantiating function definition
'test_omp_pteam_mem_alloc<int>'
3.      omp_pteam_mem_alloc.cpp:14:6: LLVM IR generation of declaration
'test_omp_pteam_mem_alloc'
4.      omp_pteam_mem_alloc.cpp:19:3: LLVM IR generation of compound statement
('{}')
 #0 0x0000000001db8c64 PrintStackTraceSignalHandler(void*)
(/opt/llvm/dev-20200711/bin/clang-11+0x1db8c64)
 #1 0x0000000001db684e llvm::sys::RunSignalHandlers()
(/opt/llvm/dev-20200711/bin/clang-11+0x1db684e)
 #2 0x0000000001db8f85 SignalHandler(int)
(/opt/llvm/dev-20200711/bin/clang-11+0x1db8f85)
 #3 0x00007f383e5098a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
 #4 0x00007f383cfb2f47 raise
/build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f383cfb48b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f383cfa442a __assert_fail_base
/build/glibc-2ORdQG/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f383cfa44a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
 #8 0x00000000016310ec llvm::ConstantExpr::getCast(unsigned int,
llvm::Constant*, llvm::Type*, bool)
(/opt/llvm/dev-20200711/bin/clang-11+0x16310ec)
 #9 0x0000000000a01e99
llvm::IRBuilderBase::CreateCast(llvm::Instruction::CastOps, llvm::Value*,
llvm::Type*, llvm::Twine const&) (/opt/llvm/dev-20200711/bin/clang-11+0xa01e99)
#10 0x00000000022381ae
clang::CodeGen::CodeGenFunction::EmitCall(clang::CodeGen::CGFunctionInfo
const&, clang::CodeGen::CGCallee const&, clang::CodeGen::ReturnValueSlot,
clang::CodeGen::CallArgList const&, llvm::CallBase**, clang::SourceLocation)
(/opt/llvm/dev-20200711/bin/clang-11+0x22381ae)
#11 0x000000000228ffa0
clang::CodeGen::CodeGenFunction::EmitCall(clang::QualType,
clang::CodeGen::CGCallee const&, clang::CallExpr const*,
clang::CodeGen::ReturnValueSlot, llvm::Value*)
(/opt/llvm/dev-20200711/bin/clang-11+0x228ffa0)
#12 0x000000000228eddd
clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*,
clang::CodeGen::ReturnValueSlot)
(/opt/llvm/dev-20200711/bin/clang-11+0x228eddd)
#13 0x00000000022bf84c (anonymous
namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*)
(/opt/llvm/dev-20200711/bin/clang-11+0x22bf84c)
#14 0x00000000022afc18
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool)
(/opt/llvm/dev-20200711/bin/clang-11+0x22afc18)
#15 0x0000000002273700 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr
const*, clang::CodeGen::AggValueSlot, bool)
(/opt/llvm/dev-20200711/bin/clang-11+0x2273700)
#16 0x00000000022736a9
clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*)
(/opt/llvm/dev-20200711/bin/clang-11+0x22736a9)
#17 0x000000000202e7f2 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/opt/llvm/dev-20200711/bin/clang-11+0x202e7f2)
#18 0x00000000020385f0
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/opt/llvm/dev-20200711/bin/clang-11+0x20385f0)
#19 0x00000000020378ff
clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&,
bool, clang::CodeGen::AggValueSlot)
(/opt/llvm/dev-20200711/bin/clang-11+0x20378ff)
#20 0x000000000202eec6
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*)
(/opt/llvm/dev-20200711/bin/clang-11+0x202eec6)
#21 0x000000000202e715 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/opt/llvm/dev-20200711/bin/clang-11+0x202e715)
#22 0x000000000204be03
clang::CodeGen::CodeGenFunction::EmitOMPLoopBody(clang::OMPLoopDirective
const&, clang::CodeGen::CodeGenFunction::JumpDest)
(/opt/llvm/dev-20200711/bin/clang-11+0x204be03)
#23 0x0000000002051235
emitOMPLoopBodyWithStopPoint(clang::CodeGen::CodeGenFunction&,
clang::OMPLoopDirective const&, clang::CodeGen::CodeGenFunction::JumpDest)
(/opt/llvm/dev-20200711/bin/clang-11+0x2051235)
#24 0x0000000002078a36 void llvm::function_ref<void
(clang::CodeGen::CodeGenFunction&)>::callback_fn<clang::CodeGen::CodeGenFunction::EmitOMPDistributeLoop(clang::OMPLoopDirective
const&, llvm::function_ref<void (clang::CodeGen::CodeGenFunction&,
clang::OMPLoopDirective const&, clang::CodeGen::CodeGenFunction::JumpDest)>
const&, clang::Expr*)::$_72::operator()(clang::CodeGen::CodeGenFunction&,
clang::CodeGen::PrePostActionTy&)
const::'lambda'(clang::CodeGen::CodeGenFunction&)>(long,
clang::CodeGen::CodeGenFunction&)
(/opt/llvm/dev-20200711/bin/clang-11+0x2078a36)
#25 0x000000000204c6f8
clang::CodeGen::CodeGenFunction::EmitOMPInnerLoop(clang::OMPExecutableDirective
const&, bool, clang::Expr const*, clang::Expr const*, llvm::function_ref<void
(clang::CodeGen::CodeGenFunction&)>, llvm::function_ref<void
(clang::CodeGen::CodeGenFunction&)>)
(/opt/llvm/dev-20200711/bin/clang-11+0x204c6f8)
#26 0x00000000020789f1 void
clang::CodeGen::RegionCodeGenTy::CallbackFn<clang::CodeGen::CodeGenFunction::EmitOMPDistributeLoop(clang::OMPLoopDirective
const&, llvm::function_ref<void (clang::CodeGen::CodeGenFunction&,
clang::OMPLoopDirective const&, clang::CodeGen::CodeGenFunction::JumpDest)>
const&, clang::Expr*)::$_72>(long, clang::CodeGen::CodeGenFunction&,
clang::CodeGen::PrePostActionTy&)
(/opt/llvm/dev-20200711/bin/clang-11+0x20789f1)
#27 0x000000000233e313
clang::CodeGen::RegionCodeGenTy::operator()(clang::CodeGen::CodeGenFunction&)
const (/opt/llvm/dev-20200711/bin/clang-11+0x233e313)
#28 0x0000000002067fda void
clang::CodeGen::RegionCodeGenTy::CallbackFn<emitCommonSimdLoop(clang::CodeGen::CodeGenFunction&,
clang::OMPLoopDirective const&, clang::CodeGen::RegionCodeGenTy const&,
clang::CodeGen::RegionCodeGenTy const&)::$_121>(long,
clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&)
(/opt/llvm/dev-20200711/bin/clang-11+0x2067fda)
#29 0x000000000233e313
clang::CodeGen::RegionCodeGenTy::operator()(clang::CodeGen::CodeGenFunction&)
const (/opt/llvm/dev-20200711/bin/clang-11+0x233e313)
#30 0x000000000204fe0a emitCommonSimdLoop(clang::CodeGen::CodeGenFunction&,
clang::OMPLoopDirective const&, clang::CodeGen::RegionCodeGenTy const&,
clang::CodeGen::RegionCodeGenTy const&)
(/opt/llvm/dev-20200711/bin/clang-11+0x204fe0a)
#31 0x000000000205e203
clang::CodeGen::CodeGenFunction::EmitOMPDistributeLoop(clang::OMPLoopDirective
const&, llvm::function_ref<void (clang::CodeGen::CodeGenFunction&,
clang::OMPLoopDirective const&, clang::CodeGen::CodeGenFunction::JumpDest)>
const&, clang::Expr*) (/opt/llvm/dev-20200711/bin/clang-11+0x205e203)
#32 0x000000000207b820 void
clang::CodeGen::RegionCodeGenTy::CallbackFn<emitTargetTeamsDistributeRegion(clang::CodeGen::CodeGenFunction&,
clang::CodeGen::PrePostActionTy&, clang::OMPTargetTeamsDistributeDirective
const&)::$_143>(long, clang::CodeGen::CodeGenFunction&,
clang::CodeGen::PrePostActionTy&)
(/opt/llvm/dev-20200711/bin/clang-11+0x207b820)
#33 0x00000000023795f7 (anonymous
namespace)::CGOpenMPRegionInfo::EmitBody(clang::CodeGen::CodeGenFunction&,
clang::Stmt const*) (/opt/llvm/dev-20200711/bin/clang-11+0x23795f7)
#34 0x00000000023664d7
clang::CodeGen::CGOpenMPRuntime::emitInlinedDirective(clang::CodeGen::CodeGenFunction&,
llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&, bool)
(/opt/llvm/dev-20200711/bin/clang-11+0x23664d7)
#35 0x000000000207b793 void
clang::CodeGen::RegionCodeGenTy::CallbackFn<emitTargetTeamsDistributeRegion(clang::CodeGen::CodeGenFunction&,
clang::CodeGen::PrePostActionTy&, clang::OMPTargetTeamsDistributeDirective
const&)::$_144>(long, clang::CodeGen::CodeGenFunction&,
clang::CodeGen::PrePostActionTy&)
(/opt/llvm/dev-20200711/bin/clang-11+0x207b793)
#36 0x00000000023795f7 (anonymous
namespace)::CGOpenMPRegionInfo::EmitBody(clang::CodeGen::CodeGenFunction&,
clang::Stmt const*) (/opt/llvm/dev-20200711/bin/clang-11+0x23795f7)
#37 0x000000000203ffe5
clang::CodeGen::CodeGenFunction::GenerateOpenMPCapturedStmtFunction(clang::CapturedStmt
const&, clang::SourceLocation) (/opt/llvm/dev-20200711/bin/clang-11+0x203ffe5)
#38 0x00000000023448be
emitParallelOrTeamsOutlinedFunction(clang::CodeGen::CodeGenModule&,
clang::OMPExecutableDirective const&, clang::CapturedStmt const*,
clang::VarDecl const*, llvm::omp::Directive, llvm::StringRef,
clang::CodeGen::RegionCodeGenTy const&)
(/opt/llvm/dev-20200711/bin/clang-11+0x23448be)
#39 0x0000000002344a36
clang::CodeGen::CGOpenMPRuntime::emitTeamsOutlinedFunction(clang::OMPExecutableDirective
const&, clang::VarDecl const*, llvm::omp::Directive,
clang::CodeGen::RegionCodeGenTy const&)
(/opt/llvm/dev-20200711/bin/clang-11+0x2344a36)
#40 0x000000000239ff81
clang::CodeGen::CGOpenMPRuntimeNVPTX::emitTeamsOutlinedFunction(clang::OMPExecutableDirective
const&, clang::VarDecl const*, llvm::omp::Directive,
clang::CodeGen::RegionCodeGenTy const&)
(/opt/llvm/dev-20200711/bin/clang-11+0x239ff81)
#41 0x0000000002060673
emitCommonOMPTeamsDirective(clang::CodeGen::CodeGenFunction&,
clang::OMPExecutableDirective const&, llvm::omp::Directive,
clang::CodeGen::RegionCodeGenTy const&)
(/opt/llvm/dev-20200711/bin/clang-11+0x2060673)
#42 0x000000000207b58d void
clang::CodeGen::RegionCodeGenTy::CallbackFn<clang::CodeGen::CodeGenFunction::EmitOMPTargetTeamsDistributeDeviceFunction(clang::CodeGen::CodeGenModule&,
llvm::StringRef, clang::OMPTargetTeamsDistributeDirective const&)::$_84>(long,
clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&)
(/opt/llvm/dev-20200711/bin/clang-11+0x207b58d)
#43 0x00000000023795f7 (anonymous
namespace)::CGOpenMPRegionInfo::EmitBody(clang::CodeGen::CodeGenFunction&,
clang::Stmt const*) (/opt/llvm/dev-20200711/bin/clang-11+0x23795f7)
#44 0x000000000203ffe5
clang::CodeGen::CodeGenFunction::GenerateOpenMPCapturedStmtFunction(clang::CapturedStmt
const&, clang::SourceLocation) (/opt/llvm/dev-20200711/bin/clang-11+0x203ffe5)
#45 0x000000000236777f
clang::CodeGen::CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(clang::OMPExecutableDirective
const&, llvm::StringRef, llvm::Function*&, llvm::Constant*&, bool,
clang::CodeGen::RegionCodeGenTy const&)
(/opt/llvm/dev-20200711/bin/clang-11+0x236777f)
#46 0x00000000023988e8
clang::CodeGen::CGOpenMPRuntimeNVPTX::emitNonSPMDKernel(clang::OMPExecutableDirective
const&, llvm::StringRef, llvm::Function*&, llvm::Constant*&, bool,
clang::CodeGen::RegionCodeGenTy const&)
(/opt/llvm/dev-20200711/bin/clang-11+0x23988e8)
#47 0x000000000239e4ae
clang::CodeGen::CGOpenMPRuntimeNVPTX::emitTargetOutlinedFunction(clang::OMPExecutableDirective
const&, llvm::StringRef, llvm::Function*&, llvm::Constant*&, bool,
clang::CodeGen::RegionCodeGenTy const&)
(/opt/llvm/dev-20200711/bin/clang-11+0x239e4ae)
#48 0x00000000020609bd
clang::CodeGen::CodeGenFunction::EmitOMPTargetTeamsDistributeDeviceFunction(clang::CodeGen::CodeGenModule&,
llvm::StringRef, clang::OMPTargetTeamsDistributeDirective const&)
(/opt/llvm/dev-20200711/bin/clang-11+0x20609bd)
#49 0x000000000236b6d0
clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt
const*, llvm::StringRef) (/opt/llvm/dev-20200711/bin/clang-11+0x236b6d0)
#50 0x000000000236b56a
clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt
const*, llvm::StringRef) (/opt/llvm/dev-20200711/bin/clang-11+0x236b56a)
#51 0x000000000236b9d1
clang::CodeGen::CGOpenMPRuntime::emitTargetFunctions(clang::GlobalDecl)
(/opt/llvm/dev-20200711/bin/clang-11+0x236b9d1)
#52 0x00000000020aa54f
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(/opt/llvm/dev-20200711/bin/clang-11+0x20aa54f)
#53 0x00000000020b15a3
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*)
(/opt/llvm/dev-20200711/bin/clang-11+0x20b15a3)
#54 0x0000000002bc1b50 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
(/opt/llvm/dev-20200711/bin/clang-11+0x2bc1b50)
#55 0x0000000002bbea0b
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/opt/llvm/dev-20200711/bin/clang-11+0x2bbea0b)
#56 0x0000000003d52eca
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool, bool)
(/opt/llvm/dev-20200711/bin/clang-11+0x3d52eca)
#57 0x0000000003d560a1 clang::Sema::PerformPendingInstantiations(bool)
(/opt/llvm/dev-20200711/bin/clang-11+0x3d560a1)
#58 0x00000000035d3215
clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind)
(/opt/llvm/dev-20200711/bin/clang-11+0x35d3215)
#59 0x00000000035d3a7a clang::Sema::ActOnEndOfTranslationUnit()
(/opt/llvm/dev-20200711/bin/clang-11+0x35d3a7a)
#60 0x00000000034df694
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/opt/llvm/dev-20200711/bin/clang-11+0x34df694)
#61 0x00000000034dac2d clang::ParseAST(clang::Sema&, bool, bool)
(/opt/llvm/dev-20200711/bin/clang-11+0x34dac2d)
#62 0x000000000258cf13 clang::FrontendAction::Execute()
(/opt/llvm/dev-20200711/bin/clang-11+0x258cf13)
#63 0x00000000025248a3
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/llvm/dev-20200711/bin/clang-11+0x25248a3)
#64 0x0000000002638822
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/llvm/dev-20200711/bin/clang-11+0x2638822)
#65 0x00000000009c57cf cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/llvm/dev-20200711/bin/clang-11+0x9c57cf)
#66 0x00000000009c392c ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/opt/llvm/dev-20200711/bin/clang-11+0x9c392c)
#67 0x00000000009c368b main (/opt/llvm/dev-20200711/bin/clang-11+0x9c368b)
#68 0x00007f383cf95b97 __libc_start_main
/build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#69 0x00000000009c06ca _start (/opt/llvm/dev-20200711/bin/clang-11+0x9c06ca)
clang-11: error: unable to execute command: Aborted (core dumped)
clang-11: error: clang frontend command failed due to signal (use -v to see
invocation)

-- 
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/20200711/0fbcc5b0/attachment-0001.html>


More information about the llvm-bugs mailing list