Issue 209123
Summary [flang][openmp] Crash with power operator when compiling for AMD GPUs
Labels flang
Assignees
Reporter VeeEM
    Here's a small reproducer:
```
module m
contains
    subroutine s()
 integer :: n1
      real :: tmp1
      !$omp declare target
      tmp1 = 2**n1
    end subroutine s
end module
```
```
flang -c -nogpulib -fopenmp --offload-arch=gfx90a invalid_cast.f90 
loc("/home/acc/llvm-stuff/invalid_cast.f90":7:7): error: 'llvm.call' op calling function with void result must not produce values
error: Lowering to LLVM IR failed
flang-23: /home/acc/llvm-stuff/llvm_upstream/llvm-project/llvm/lib/IR/Instructions.cpp:3109: static llvm::CastInst* llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, const llvm::Twine&, llvm::InsertPosition): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: /home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23 -fc1 -triple amdgcn-amd-amdhsa -emit-llvm-bc -fcolor-diagnostics -flto=full -mrelocation-model pic -pic-level 2 -target-cpu gfx90a -fopenmp -resource-dir /home/acc/llvm-stuff/llvm_upstream/install/lib/clang/23 -fintrinsic-modules-path /home/acc/llvm-stuff/llvm_upstream/install/lib/clang/23/finclude/flang/amdgcn-amd-amdhsa -fintrinsic-modules-path /home/acc/llvm-stuff/llvm_upstream/install/lib/clang/23/finclude/flang/x86_64-unknown-linux-gnu -foffload-device -fopenmp-host-ir-file-path /tmp/invalid_cast-d305b4.bc -fopenmp-is-target-device -nogpulib -mframe-pointer=all -o /tmp/invalid_cast-gfx90a-da0682.o -x f95 invalid_cast.f90
 #0 0x000056470669afb7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23+0x3115fb7)
 #1 0x0000564706697f14 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007f5c3ba4a970 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x40970)
 #3 0x00007f5c3baa11dc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #4 0x00007f5c3ba4a842 raise ./signal/../sysdeps/posix/raise.c:27:6
 #5 0x00007f5c3ba324b2 abort ./stdlib/abort.c:85:3
 #6 0x00007f5c3ba32424 __assert_perror_fail ./assert/assert-perr.c:31:1
 #7 0x00005647058220ed (/home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23+0x229d0ed)
 #8 0x000056470aeb517b llvm::IRBuilderBase::CreateCast(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&, llvm::MDNode*, llvm::FMFSource) (.isra.0) LLVMToLLVMIRTranslation.cpp:0:0
 #9 0x000056470aedcc20 convertOperationImpl(mlir::Operation&, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) LLVMToLLVMIRTranslation.cpp:0:0
#10 0x000056470cf363cf mlir::LLVM::ModuleTranslation::convertOperationImpl(mlir::Operation&, llvm::IRBuilderBase&, bool) (/home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23+0x99b13cf)
#11 0x000056470cf43834 mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp) (/home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23+0x99be834)
#12 0x000056470cf44a20 mlir::LLVM::ModuleTranslation::convertFunctions() (/home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23+0x99bfa20)
#13 0x000056470cf509d0 mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef, bool, llvm::vfs::FileSystem*) (/home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23+0x99cb9d0)
#14 0x0000564706a332c5 Fortran::frontend::CodeGenAction::generateLLVMIR() (/home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23+0x34ae2c5)
#15 0x0000564706a38658 Fortran::frontend::CodeGenAction::executeAction() (/home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23+0x34b3658)
#16 0x00005647066f225c Fortran::frontend::FrontendAction::execute() (/home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23+0x316d25c)
#17 0x00005647066d9514 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23+0x3154514)
#18 0x00005647066fe609 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23+0x3179609)
#19 0x00005647059599f8 fc1_main(llvm::ArrayRef<char const*>, char const*) (/home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23+0x23d49f8)
#20 0x0000564705886ab1 main (/home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23+0x2301ab1)
#21 0x00007f5c3ba33f77 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#22 0x00007f5c3ba34027 call_init ./csu/../csu/libc-start.c:128:20
#23 0x00007f5c3ba34027 __libc_start_main ./csu/../csu/libc-start.c:347:5
#24 0x0000564705958821 _start (/home/acc/llvm-stuff/llvm_upstream/install/bin/flang-23+0x23d3821)
flang-23: error: unable to execute command: Aborted
flang-23: error: flang frontend command failed with exit code -2 (use -v to see invocation)
flang version 23.0.0git (https://github.com/llvm/llvm-project.git 97e24c8d1cfd7259733ef4b3476f4429402415fb)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/acc/llvm-stuff/llvm_upstream/install/bin
Build config: +assertions
flang-23: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING CRASH REPRODUCER FILES TO THE BUG REPORT:
flang-23: note: diagnostic msg: /tmp/invalid_cast-gfx90a-e530ce
flang-23: note: diagnostic msg: /tmp/invalid_cast-3bd736
flang-23: note: diagnostic msg: /tmp/invalid_cast-gfx90a-e530ce.sh
flang-23: note: diagnostic msg: 

********************
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to