llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.84k stars 11.47k forks source link

Assertion `Elt->getBitWidth() == EltVT.getSizeInBits() && "APInt size does not match type size!"' failed. #91975

Closed DigOrDog closed 3 months ago

DigOrDog commented 3 months ago

Description

The following code crashes aarch64 backend with "Assertion `Elt->getBitWidth() == EltVT.getSizeInBits() && "APInt size does not match type size!"' failed."

Minimal Reproduction

https://godbolt.org/z/6Kvh5oeT8

Code

; ModuleID = 'Fuzzer input'
source_filename = "M"

@G = global ppc_fp128 0xM7FF00000000000000000000000000000

define i1 @f(i1 %0, i8 %1, i64 %2) {
BB:
  %CastFPTrunc1 = fpext float 4.200000e+01 to x86_fp80
  %CastExt = sext i16 0 to i32
  %CastFPTrunc = fpext float 0x47EFFFFFE0000000 to ppc_fp128
  %RP = alloca i1, i32 %CastExt, align 1
  %3 = load i1, ptr %RP, align 1
  store ppc_fp128 %CastFPTrunc, ptr @G, align 16
  store x86_fp80 %CastFPTrunc1, ptr %RP, align 16
  ret i1 %3
}

Stack Trace

llc: /root/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1703: llvm::SDValue llvm::SelectionDAG::getConstant(const llvm::ConstantInt&, const llvm::SDLoc&, llvm::EVT, bool, bool): Assertion `Elt->getBitWidth() == EltVT.getSizeInBits() && "APInt size does not match type size!"' failed.
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 aarch64 -global-isel -O0 <source>
1.  Running pass 'Function Pass Manager' on module '<source>'.
2.  Running pass 'AArch64 Instruction Selection' on function '@f'
 #0 0x000000000399e058 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x399e058)
 #1 0x000000000399b7ac SignalHandler(int) Signals.cpp:0:0
 #2 0x00007a02eb242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007a02eb2969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007a02eb242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007a02eb2287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x00007a02eb22871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x00007a02eb239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x000000000372fa81 llvm::SelectionDAG::getConstant(llvm::ConstantInt const&, llvm::SDLoc const&, llvm::EVT, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x372fa81)
 #9 0x000000000384f5aa llvm::DAGTypeLegalizer::SoftenFloatRes_ConstantFP(llvm::SDNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x384f5aa)
#10 0x0000000003862fa2 llvm::DAGTypeLegalizer::SoftenFloatResult(llvm::SDNode*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3862fa2)
#11 0x00000000037f2ed3 llvm::DAGTypeLegalizer::run() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37f2ed3)
#12 0x00000000037f3d59 llvm::SelectionDAG::LegalizeTypes() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37f3d59)
#13 0x00000000037664b4 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37664b4)
#14 0x0000000003769f45 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3769f45)
#15 0x000000000376b9b7 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#16 0x00000000029af0d1 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#17 0x0000000002f70f83 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f70f83)
#18 0x0000000002f711c1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f711c1)
#19 0x0000000002f71a25 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f71a25)
#20 0x000000000082dfcc compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#21 0x000000000072b486 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x72b486)
#22 0x00007a02eb229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#23 0x00007a02eb229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#24 0x0000000000824aee _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x824aee)
Program terminated with signal: SIGSEGV
Compiler returned: 139
llvmbot commented 3 months ago

@llvm/issue-subscribers-backend-aarch64

Author: None (DigOrDog)

# Description The following code crashes aarch64 backend with "Assertion `Elt->getBitWidth() == EltVT.getSizeInBits() && "APInt size does not match type size!"' failed." # Minimal Reproduction https://godbolt.org/z/6Kvh5oeT8 ## Code ``` ; ModuleID = 'Fuzzer input' source_filename = "M" @G = global ppc_fp128 0xM7FF00000000000000000000000000000 define i1 @f(i1 %0, i8 %1, i64 %2) { BB: %CastFPTrunc1 = fpext float 4.200000e+01 to x86_fp80 %CastExt = sext i16 0 to i32 %CastFPTrunc = fpext float 0x47EFFFFFE0000000 to ppc_fp128 %RP = alloca i1, i32 %CastExt, align 1 %3 = load i1, ptr %RP, align 1 store ppc_fp128 %CastFPTrunc, ptr @G, align 16 store x86_fp80 %CastFPTrunc1, ptr %RP, align 16 ret i1 %3 } ``` ## Stack Trace ``` llc: /root/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1703: llvm::SDValue llvm::SelectionDAG::getConstant(const llvm::ConstantInt&, const llvm::SDLoc&, llvm::EVT, bool, bool): Assertion `Elt->getBitWidth() == EltVT.getSizeInBits() && "APInt size does not match type size!"' failed. 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 aarch64 -global-isel -O0 <source> 1. Running pass 'Function Pass Manager' on module '<source>'. 2. Running pass 'AArch64 Instruction Selection' on function '@f' #0 0x000000000399e058 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x399e058) #1 0x000000000399b7ac SignalHandler(int) Signals.cpp:0:0 #2 0x00007a02eb242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520) #3 0x00007a02eb2969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc) #4 0x00007a02eb242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476) #5 0x00007a02eb2287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3) #6 0x00007a02eb22871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b) #7 0x00007a02eb239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96) #8 0x000000000372fa81 llvm::SelectionDAG::getConstant(llvm::ConstantInt const&, llvm::SDLoc const&, llvm::EVT, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x372fa81) #9 0x000000000384f5aa llvm::DAGTypeLegalizer::SoftenFloatRes_ConstantFP(llvm::SDNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x384f5aa) #10 0x0000000003862fa2 llvm::DAGTypeLegalizer::SoftenFloatResult(llvm::SDNode*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3862fa2) #11 0x00000000037f2ed3 llvm::DAGTypeLegalizer::run() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37f2ed3) #12 0x00000000037f3d59 llvm::SelectionDAG::LegalizeTypes() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37f3d59) #13 0x00000000037664b4 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37664b4) #14 0x0000000003769f45 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3769f45) #15 0x000000000376b9b7 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0 #16 0x00000000029af0d1 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0 #17 0x0000000002f70f83 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f70f83) #18 0x0000000002f711c1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f711c1) #19 0x0000000002f71a25 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f71a25) #20 0x000000000082dfcc compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0 #21 0x000000000072b486 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x72b486) #22 0x00007a02eb229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90) #23 0x00007a02eb229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40) #24 0x0000000000824aee _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x824aee) Program terminated with signal: SIGSEGV Compiler returned: 139 ```
dtcxzyw commented 3 months ago

We don't support ppc_fp128 on AArch64. BTW, please don't submit IR generated by fuzzers if you don't understand it. See https://github.com/llvm/llvm-project/issues/93391#issuecomment-2132061299