Skip to content

[AArch64] llc crashed and triggered assertion "Value is not an N-bit unsigned value" at -O3 #164775

@XChy

Description

@XChy

Reproducer: https://godbolt.org/z/P4q4ocvd3
Testcase (reduced from a valid C program):

target triple = "aarch64-unknown-linux-musl"

%struct.S0 = type { i16 }

@g_260 = dso_local global %struct.S0 zeroinitializer
@g_480 = dso_local global i16 0

define i32 @func_1(ptr %l_3253) {
entry:
  %l_32531.sroa.3 = alloca [3 x i8], align 4
  %l_32531.sroa.4 = alloca [115 x i8], align 4
  call void @llvm.lifetime.start.p0(ptr %l_32531.sroa.3)
  call void @llvm.lifetime.start.p0(ptr %l_32531.sroa.4)
  call void @llvm.memset.p0.i64(ptr null, i8 0, i64 3, i1 false)
  call void @llvm.memset.p0.i64(ptr null, i8 0, i64 115, i1 false)
  %0 = getelementptr inbounds i8, ptr %l_3253, i64 8
  store i8 0, ptr %0, align 4
  %1 = getelementptr inbounds i8, ptr %l_3253, i64 12
  store i8 0, ptr %1, align 4
  %2 = getelementptr inbounds i8, ptr %l_3253, i64 16
  store i8 0, ptr %2, align 4
  %3 = getelementptr inbounds i8, ptr %l_3253, i64 20
  store i8 0, ptr %3, align 4
  %4 = load volatile i16, ptr @g_260, align 4
  %5 = load i16, ptr @g_480, align 4
  %dec.i.i = add i16 %5, -1
  store i16 %dec.i.i, ptr @g_480, align 4
  %call1 = tail call i32 @func_4(i32 0, ptr @g_480)
  ret i32 %call1

; uselistorder directives
  uselistorder ptr %l_3253, { 3, 2, 1, 0 }
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(ptr captures(none)) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr writeonly captures(none), i8, i64, i1 immarg) #1

declare i32 @func_4(...)

; uselistorder directives
uselistorder ptr @llvm.lifetime.start.p0, { 1, 0 }
uselistorder ptr @llvm.memset.p0.i64, { 1, 0 }

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }

llc output:

llc: /root/llvm-project/llvm/include/llvm/ADT/APInt.h:127: llvm::APInt::APInt(unsigned int, uint64_t, bool, bool): Assertion `llvm::isUIntN(BitWidth, val) && "Value is not an N-bit unsigned value"' 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 -O3 <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'AArch64 Instruction Selection' on function '@func_1'
 #0 0x0000000004166aa8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x4166aa8)
 #1 0x0000000004163954 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007f58fd442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007f58fd4969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007f58fd442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007f58fd4287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x00007f58fd42871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x00007f58fd439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x0000000003ebc859 llvm::SelectionDAG::getConstant(unsigned long, llvm::SDLoc const&, llvm::EVT, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3ebc859)
 #9 0x0000000000d2ba97 llvm::AArch64TargetLowering::getIndexedAddressParts(llvm::SDNode*, llvm::SDNode*, llvm::SDValue&, llvm::SDValue&, llvm::SelectionDAG&) const (.part.0) AArch64ISelLowering.cpp:0:0
#10 0x0000000000d2bdb1 llvm::AArch64TargetLowering::getPostIndexedAddressParts(llvm::SDNode*, llvm::SDNode*, llvm::SDValue&, llvm::SDValue&, llvm::ISD::MemIndexedMode&, llvm::SelectionDAG&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0xd2bdb1)
#11 0x0000000003ce6f40 (anonymous namespace)::DAGCombiner::CombineToPostIndexedLoadStore(llvm::SDNode*) (.part.0) DAGCombiner.cpp:0:0
#12 0x0000000003d7f12b (anonymous namespace)::DAGCombiner::visitSTORE(llvm::SDNode*) DAGCombiner.cpp:0:0
#13 0x0000000003d87f0b (anonymous namespace)::DAGCombiner::visit(llvm::SDNode*) DAGCombiner.cpp:0:0
#14 0x0000000003d8975c (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
#15 0x0000000003d8b1cd (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) DAGCombiner.cpp:0:0
#16 0x0000000003d8dd33 llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::BatchAAResults*, llvm::CodeGenOptLevel) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3d8dd33)
#17 0x0000000003ef7845 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3ef7845)
#18 0x0000000003efaf2d llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3efaf2d)
#19 0x0000000003efc515 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3efc515)
#20 0x0000000003ee7ecf llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3ee7ecf)
#21 0x0000000003057079 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#22 0x00000000036a47f8 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x36a47f8)
#23 0x00000000036a4a31 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x36a4a31)
#24 0x00000000036a529f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x36a529f)
#25 0x00000000008f8993 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#26 0x00000000007c5d56 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x7c5d56)
#27 0x00007f58fd429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#28 0x00007f58fd429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#29 0x00000000008eddd5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x8eddd5)
Program terminated with signal: SIGSEGV
Compiler returned: 139

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions