[llvm] [SDAG] Don't allow implicit trunc in getConstant() (PR #117558)
Nathan Chancellor via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 1 10:59:55 PST 2024
nathanchance wrote:
@nikic Found another one with `ARCH=hexagon`.
```c
struct ufs_clk_scaling {
long long window_start_t;
int enable_attr; int suspend_work;
};
struct ufs_hba {
struct ufs_clk_scaling clk_scaling;
};
void *ufshcd_clk_scaling_suspend_work___mptr;
void ufshcd_clk_scaling_suspend_work() {
struct ufs_hba *hba = ({
ufshcd_clk_scaling_suspend_work___mptr -
__builtin_offsetof(struct ufs_hba, clk_scaling.suspend_work);
});
hba->clk_scaling.window_start_t = 0;
}
```
```llvm
target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
target triple = "hexagon-unknown-linux-musl"
define void @ufshcd_clk_scaling_suspend_work(ptr %0) {
entry:
%add.ptr = getelementptr i8, ptr %0, i32 -12
store i64 0, ptr %add.ptr, align 8
ret void
}
```
```
$ clang --target=hexagon-linux-musl -O2 -c -o /dev/null ufshcd.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=hexagon-linux-musl -O2 -c -o /dev/null ufshcd.i
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'ufshcd.i'.
4. Running pass 'Hexagon DAG->DAG Pattern Instruction Selection' on function '@ufshcd_clk_scaling_suspend_work'
…
$ 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 'Hexagon DAG->DAG Pattern Instruction Selection' on function '@ufshcd_clk_scaling_suspend_work'
#0 0x0000560c18dfd9b6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x37149b6)
#1 0x0000560c18dfb40e llvm::sys::RunSignalHandlers() (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x371240e)
#2 0x0000560c18dfe0c4 SignalHandler(int) Signals.cpp:0:0
#3 0x00007fc60b1151d0 (/usr/lib/libc.so.6+0x3d1d0)
#4 0x00007fc60b16e3f4 (/usr/lib/libc.so.6+0x963f4)
#5 0x00007fc60b115120 raise (/usr/lib/libc.so.6+0x3d120)
#6 0x00007fc60b0fc4c3 abort (/usr/lib/libc.so.6+0x244c3)
#7 0x00007fc60b0fc3df (/usr/lib/libc.so.6+0x243df)
#8 0x00007fc60b10d177 (/usr/lib/libc.so.6+0x35177)
#9 0x0000560c18b745ff (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x348b5ff)
#10 0x0000560c173eaa04 llvm::HexagonDAGToDAGISel::RunSDNodeXForm(llvm::SDValue, unsigned int) HexagonISelDAGToDAG.cpp:0:0
#11 0x0000560c18be92d1 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x35002d1)
#12 0x0000560c173ec3ce llvm::HexagonDAGToDAGISel::SelectStore(llvm::SDNode*) HexagonISelDAGToDAG.cpp:0:0
#13 0x0000560c18bdfb6d llvm::SelectionDAGISel::DoInstructionSelection() (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x34f6b6d)
#14 0x0000560c18bdead9 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x34f5ad9)
#15 0x0000560c18bdc2be llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x34f32be)
#16 0x0000560c18bd9741 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x34f0741)
#17 0x0000560c173faf07 llvm::HexagonDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) HexagonISelDAGToDAG.cpp:0:0
#18 0x0000560c18bd6fd6 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x34edfd6)
#19 0x0000560c17dd4582 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x26eb582)
#20 0x0000560c18340023 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x2c57023)
#21 0x0000560c18348862 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x2c5f862)
#22 0x0000560c18340b02 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x2c57b02)
#23 0x0000560c1727ee5e main (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x1b95e5e)
#24 0x00007fc60b0fde08 (/usr/lib/libc.so.6+0x25e08)
#25 0x00007fc60b0fdecc __libc_start_main (/usr/lib/libc.so.6+0x25ecc)
#26 0x0000560c17278be5 _start (/home/nathan/tmp/cvise.wrgrJOK5aT/install/llvm-bad/bin/llc+0x1b8fbe5)
```
This reproduces for me at 31bde711c4098b3136edd1cb92dd4e0cc1d4d179.
https://github.com/llvm/llvm-project/pull/117558
More information about the llvm-commits
mailing list