Open
Description
While compiling the following code using nvptx64, Assembly printer hit an unreachable. https://godbolt.org/z/4xEP8js58
@G = global <4 x i32> <i32 7, i32 7, i32 7, i32 7>
@G_addr = global i20 ptrtoint (<4 x i32>* @G to i20)
Unhandled binary operator
UNREACHABLE executed at /root/llvm-project/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp:2129!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=nvptx64 <source>
#0 0x00005649b897460f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x382660f)
#1 0x00005649b8971fd4 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f01b7dce420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007f01b789b00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007f01b787a859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00005649b88d66fe (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37886fe)
#6 0x00005649b6ac6c71 llvm::NVPTXAsmPrinter::printMCExpr(llvm::MCExpr const&, llvm::raw_ostream&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x1978c71)
#7 0x00005649b6ace505 llvm::NVPTXAsmPrinter::printModuleLevelGV(llvm::GlobalVariable const*, llvm::raw_ostream&, bool, llvm::NVPTXSubtarget const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x1980505)
#8 0x00005649b6acef87 llvm::NVPTXAsmPrinter::emitGlobals(llvm::Module const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x1980f87)
#9 0x00005649b6acfbf3 llvm::NVPTXAsmPrinter::doFinalization(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x1981bf3)
#10 0x00005649b80653a5 llvm::FPPassManager::doFinalization(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f173a5)
#11 0x00005649b8071da6 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f23da6)
#12 0x00005649b5cfc983 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#13 0x00005649b5c3f642 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0xaf1642)
#14 0x00007f01b787c083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#15 0x00005649b5cf3c5e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0xba5c5e)
Compiler returned: 139
Cause
When lowering i20
, NVPTXAsmPrinter::lowerConstantForGV
creates an And
with -1 to extract bits. (Shown below)
llvm-project/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
Lines 2040 to 2060 in c823517
However, And
is not handled when printing the assembly in NVPTXAsmPrinter::printMCExpr
. (Shown below)
llvm-project/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
Lines 2117 to 2129 in c823517
It shouldn't be a hard fix, if anyone can tell me what are the expected syntax for bit wise And
in NVPTX