[llvm] [SDAG] Don't allow implicit trunc in getConstant() (PR #117558)
Nathan Chancellor via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 27 09:22:03 PST 2024
nathanchance wrote:
@nikic Whoops, looks like the original file got too reduced, how about this one? It reproduces for me at f67ba5855278401728413431216dda5d370ac2e0.
```c
int *get_next_block_base;
char get_next_block_length_0;
void __attribute__get_next_block() {
int i;
short temp[20];
for (i = 0; get_next_block_length_0; i++)
get_next_block_base[i] += temp[i];
}
```
```llvm
target datalayout = "E-m:e-p:32:32-Fn32-i64:64-n32"
target triple = "powerpc-unknown-linux-gnu"
define void @__attribute__get_next_block() {
entry:
%temp = alloca [20 x i16], i32 0, align 2
br label %for.body
for.body: ; preds = %for.body, %entry
%i.04 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
%arrayidx = getelementptr [20 x i16], ptr %temp, i32 0, i32 %i.04
%0 = load i16, ptr %arrayidx, align 2
%conv = sext i16 %0 to i32
store i32 %conv, ptr null, align 4
%inc = add i32 %i.04, 1
br label %for.body
}
```
```
$ clang --target=powerpc-linux-gnu -O2 -c -o /dev/null decompress_bunzip2.i
clang: llvm/include/llvm/ADT/APInt.h:128: 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, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: clang --target=powerpc-linux-gnu -O2 -c -o /dev/null decompress_bunzip2.i
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'decompress_bunzip2.i'.
4. Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@__attribute__get_next_block'
...
$ llc reduced.ll
llc: llvm/include/llvm/ADT/APInt.h:128: 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.
Stack dump:
0. Program arguments: llc reduced.ll
1. Running pass 'Function Pass Manager' on module 'reduced.ll'.
2. Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@__attribute__get_next_block'
#0 0x000055dde1e70ac8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-main/bin/llc+0x5683ac8)
#1 0x000055dde1e6e57e llvm::sys::RunSignalHandlers() (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-main/bin/llc+0x568157e)
#2 0x000055dde1e71178 SignalHandler(int) Signals.cpp:0:0
#3 0x00007f88e8ed31d0 (/usr/lib/libc.so.6+0x3d1d0)
#4 0x00007f88e8f2c3f4 (/usr/lib/libc.so.6+0x963f4)
#5 0x00007f88e8ed3120 raise (/usr/lib/libc.so.6+0x3d120)
#6 0x00007f88e8eba4c3 abort (/usr/lib/libc.so.6+0x244c3)
#7 0x00007f88e8eba3df (/usr/lib/libc.so.6+0x243df)
#8 0x00007f88e8ecb177 (/usr/lib/libc.so.6+0x35177)
#9 0x000055dde1c033c8 (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-main/bin/llc+0x54163c8)
#10 0x000055dde01f7ab4 (anonymous namespace)::PPCDAGToDAGISel::selectFrameIndex(llvm::SDNode*, llvm::SDNode*, unsigned long) PPCISelDAGToDAG.cpp:0:0
#11 0x000055dde01eb27c (anonymous namespace)::PPCDAGToDAGISel::Select(llvm::SDNode*) PPCISelDAGToDAG.cpp:0:0
#12 0x000055dde1c69caf llvm::SelectionDAGISel::DoInstructionSelection() (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-main/bin/llc+0x547ccaf)
#13 0x000055dde1c68c38 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-main/bin/llc+0x547bc38)
#14 0x000055dde1c66bef llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-main/bin/llc+0x5479bef)
#15 0x000055dde1c63a30 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-main/bin/llc+0x5476a30)
#16 0x000055dde01e595e (anonymous namespace)::PPCDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) PPCISelDAGToDAG.cpp:0:0
#17 0x000055dde1c61316 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-main/bin/llc+0x5474316)
#18 0x000055dde0f06707 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-main/bin/llc+0x4719707)
#19 0x000055dde143c95a llvm::FPPassManager::runOnFunction(llvm::Function&) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-main/bin/llc+0x4c4f95a)
#20 0x000055dde1444df2 llvm::FPPassManager::runOnModule(llvm::Module&) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-main/bin/llc+0x4c57df2)
#21 0x000055dde143d426 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-main/bin/llc+0x4c50426)
#22 0x000055dddf89af0e compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#23 0x000055dddf89879d main (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-main/bin/llc+0x30ab79d)
#24 0x00007f88e8ebbe08 (/usr/lib/libc.so.6+0x25e08)
#25 0x00007f88e8ebbecc __libc_start_main (/usr/lib/libc.so.6+0x25ecc)
#26 0x000055dddf8945e5 _start (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-main/bin/llc+0x30a75e5)
```
https://github.com/llvm/llvm-project/pull/117558
More information about the llvm-commits
mailing list