- Notifications
You must be signed in to change notification settings - Fork 15.3k
Labels
Description
Reproducer: https://godbolt.org/z/Exqa5vEn9
Testcase:
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128" target triple = "riscv64-unknown-linux-musl" define i32 @g_770(i32 %conv.i, i1 %iszero) #0 { entry: %not.i = xor i32 %conv.i, 1 %conv2.i = trunc i32 %not.i to i16 %conv22 = zext i16 %conv2.i to i64 %0 = call i64 @llvm.ctlz.i64(i64 %conv22, i1 false) %cast = trunc i64 %0 to i32 %clzg = select i1 %iszero, i32 -9, i32 %cast ret i32 %clzg } ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) declare i64 @llvm.ctlz.i64(i64, i1 immarg) #1 attributes #0 = { "target-features"="+b,+zicond" } attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }llc output:
llc: /root/llvm-project/llvm/include/llvm/ADT/APInt.h:490: bool llvm::APInt::isMask(unsigned int) const: Assertion `numBits <= BitWidth && "numBits out of range"' 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: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -O0 <source> 1. Running pass 'Function Pass Manager' on module '<source>'. 2. Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@g_770' #0 0x000000000419d348 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x419d348) #1 0x000000000419a1f4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0 #2 0x00007cead5442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520) #3 0x00007cead54969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc) #4 0x00007cead5442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476) #5 0x00007cead54287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3) #6 0x00007cead542871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b) #7 0x00007cead5439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96) #8 0x0000000003d36b09 (anonymous namespace)::DAGCombiner::visitSUB(llvm::SDNode*) DAGCombiner.cpp:0:0 #9 0x0000000003dbb284 (anonymous namespace)::DAGCombiner::visit(llvm::SDNode*) DAGCombiner.cpp:0:0 #10 0x0000000003dbd17c (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0 #11 0x0000000003dbebed (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) DAGCombiner.cpp:0:0 #12 0x0000000003dc1753 llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::BatchAAResults*, llvm::CodeGenOptLevel) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3dc1753) #13 0x0000000003f2ba65 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3f2ba65) #14 0x0000000003f2ec68 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3f2ec68) #15 0x0000000003f306e5 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3f306e5) #16 0x0000000003f1c0ef llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3f1c0ef) #17 0x000000000307fcc9 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0 #18 0x00000000036cfa86 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x36cfa86) #19 0x00000000036cfe31 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x36cfe31) #20 0x00000000036d069f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x36d069f) #21 0x00000000008fa803 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0 #22 0x00000000007c7986 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x7c7986) #23 0x00007cead5429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90) #24 0x00007cead5429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40) #25 0x00000000008efc45 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x8efc45) Program terminated with signal: SIGSEGV Compiler returned: 139