Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDAG] Don't allow implicit trunc in getConstant() #117558

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

nikic
Copy link
Contributor

@nikic nikic commented Nov 25, 2024

Assert that the passed value is a valid unsigned integer value for the specified type.

For signed values getSignedConstant() / getSignedTargetConstant() should be used instead.

@nikic nikic requested review from arsenm, RKSimon and topperc November 25, 2024 13:47
@llvmbot llvmbot added the llvm:SelectionDAG SelectionDAGISel as well label Nov 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 25, 2024

@llvm/pr-subscribers-llvm-selectiondag

Author: Nikita Popov (nikic)

Changes

Assert that the passed value is a valid unsigned integer value for the specified type.

For signed values getSignedConstant() / getSignedTargetConstant() should be used instead.


Full diff: https://github.com/llvm/llvm-project/pull/117558.diff

1 Files Affected:

  • (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (+1-7)
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 3a8ec3c6105bc0..f67f30b8c1ee5f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1638,13 +1638,7 @@ SDValue SelectionDAG::getBoolConstant(bool V, const SDLoc &DL, EVT VT,
 SDValue SelectionDAG::getConstant(uint64_t Val, const SDLoc &DL, EVT VT,
                                   bool isT, bool isO) {
   EVT EltVT = VT.getScalarType();
-  assert((EltVT.getSizeInBits() >= 64 ||
-          (uint64_t)((int64_t)Val >> EltVT.getSizeInBits()) + 1 < 2) &&
-         "getConstant with a uint64_t value that doesn't fit in the type!");
-  // TODO: Avoid implicit trunc?
-  // See https://github.com/llvm/llvm-project/issues/112510.
-  return getConstant(APInt(EltVT.getSizeInBits(), Val, /*isSigned=*/false,
-                           /*implicitTrunc=*/true),
+  return getConstant(APInt(EltVT.getSizeInBits(), Val, /*isSigned=*/false),
                      DL, VT, isT, isO);
 }
 

Copy link

github-actions bot commented Nov 25, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Assert that the passed value is a valid unsigned integer value
for the specified type.

For signed values getSignedConstant() / getSignedTargetConstant()
should be used instead.
@nikic nikic force-pushed the sdag-implicit-trunc branch from 45be4ce to 1195b05 Compare November 25, 2024 14:57
Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one minor - cheers

return getConstant(APInt(EltVT.getSizeInBits(), Val, /*isSigned=*/false,
/*implicitTrunc=*/true),
DL, VT, isT, isO);
return getConstant(APInt(EltVT.getSizeInBits(), Val, /*isSigned=*/false), DL,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EltVT.getSizeInBits() -> VT.getScalarSizeInBits()

Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nikic nikic merged commit 3e1b55c into llvm:main Nov 26, 2024
8 checks passed
@nikic nikic deleted the sdag-implicit-trunc branch November 26, 2024 09:36
@nathanchance
Copy link
Member

Hi @nikic, I am seeing an assertion failure when building the Linux kernel for 32-bit powerpc after this change.

char *get_next_block_mtfSymbol;
char get_next_block_mtfSymbol_0;
void get_next_block() {
  get_next_block_mtfSymbol_0 = get_next_block_mtfSymbol[-1];
}
target datalayout = "E-m:e-p:32:32-Fn32-i64:64-n32"
target triple = "powerpc-unknown-linux-gnu"

define void @get_next_block() {
entry:
  %0 = load i8, ptr inttoptr (i32 -1 to ptr), align 1
  store i8 %0, ptr null, align 1
  ret void
}
$ clang --target=powerpc-linux-gnu -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 -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 '@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 '@get_next_block'
 #0 0x000055a661ef0828 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x3391828)
 #1 0x000055a661eee2de llvm::sys::RunSignalHandlers() (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x338f2de)
 #2 0x000055a661ef0ed8 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007fd107ddf1d0 (/usr/lib/libc.so.6+0x3d1d0)
 #4 0x00007fd107e383f4 (/usr/lib/libc.so.6+0x963f4)
 #5 0x00007fd107ddf120 raise (/usr/lib/libc.so.6+0x3d120)
 #6 0x00007fd107dc64c3 abort (/usr/lib/libc.so.6+0x244c3)
 #7 0x00007fd107dc63df (/usr/lib/libc.so.6+0x243df)
 #8 0x00007fd107dd7177 (/usr/lib/libc.so.6+0x35177)
 #9 0x000055a661c82ac8 (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x3123ac8)
#10 0x000055a660595953 llvm::PPCTargetLowering::SelectOptimalAddrMode(llvm::SDNode const*, llvm::SDValue, llvm::SDValue&, llvm::SDValue&, llvm::SelectionDAG&, llvm::MaybeAlign) const PPCISelLowering.cpp:0:0
#11 0x000055a6605ab2b5 (anonymous namespace)::PPCDAGToDAGISel::CheckComplexPattern(llvm::SDNode*, llvm::SDNode*, llvm::SDValue, unsigned int, llvm::SmallVectorImpl<std::pair<llvm::SDValue, llvm::SDNode*>>&) PPCISelDAGToDAG.cpp:0:0
#12 0x000055a661cf0b42 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x3191b42)
#13 0x000055a6605a71db (anonymous namespace)::PPCDAGToDAGISel::Select(llvm::SDNode*) PPCISelDAGToDAG.cpp:0:0
#14 0x000055a661ce96cf llvm::SelectionDAGISel::DoInstructionSelection() (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x318a6cf)
#15 0x000055a661ce8658 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x3189658)
#16 0x000055a661ce660f llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x318760f)
#17 0x000055a661ce3450 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x3184450)
#18 0x000055a66059fa2e (anonymous namespace)::PPCDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) PPCISelDAGToDAG.cpp:0:0
#19 0x000055a661ce0d36 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x3181d36)
#20 0x000055a660f62507 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x2403507)
#21 0x000055a6614a75aa llvm::FPPassManager::runOnFunction(llvm::Function&) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x29485aa)
#22 0x000055a6614afa42 llvm::FPPassManager::runOnModule(llvm::Module&) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x2950a42)
#23 0x000055a6614a8076 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x2949076)
#24 0x000055a6604d441e compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#25 0x000055a6604d1d1d main (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x1972d1d)
#26 0x00007fd107dc7e08 (/usr/lib/libc.so.6+0x25e08)
#27 0x00007fd107dc7ecc __libc_start_main (/usr/lib/libc.so.6+0x25ecc)
#28 0x000055a6604cdbe5 _start (/mnt/nvme/tmp/cvise.kJkUnw63jz/install/llvm-bad/bin/llc+0x196ebe5)

@nikic
Copy link
Contributor Author

nikic commented Nov 27, 2024

@nathanchance I can't reproduce this on current main. Based on the backtrace, I think I already fixed this in 5322415?

@nathanchance
Copy link
Member

@nikic Whoops, looks like the original file got too reduced, how about this one? It reproduces for me at f67ba58.

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];
}
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)

nikic added a commit that referenced this pull request Nov 28, 2024
The offset is signed. Fixes assertion failure reported at:
#117558 (comment)
@nikic
Copy link
Contributor Author

nikic commented Nov 28, 2024

@nathanchance Thanks, should be fixed by 04a2d50.

@nathanchance
Copy link
Member

@nikic Found another one with ARCH=hexagon.

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;
}
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 31bde71.

nikic added a commit that referenced this pull request Dec 2, 2024
To handle negative offset addrmodes correctly.

Fixes #117558 (comment).
@nikic
Copy link
Contributor Author

nikic commented Dec 2, 2024

@nathanchance Thanks, should be fixed by 4851dbb.

@bjope
Copy link
Collaborator

bjope commented Dec 11, 2024

Also started to see assertion failures (with big-endian targets) in relation to DAGCombiner::ReduceLoadOpStoreWidth -> getMemBasePlusOffset , when ending up adding negative offsets.

I actually consider that as a bug in ReduceLoadOpStoreWidth (that was exposed by this patch) and propose a fix in this pull request: #119203

androm3da added a commit to androm3da/llvm-project that referenced this pull request Feb 16, 2025
After llvm#117558 landed, this code would assert "Value is not an N-bit unsigned
value" in getConstant(), from a test case in zig.

Co-authored-by:  Craig Topper <craig.topper@sifive.com>
Fixes llvm#127296
androm3da added a commit to androm3da/llvm-project that referenced this pull request Feb 16, 2025
After llvm#117558 landed, this code would assert "Value is not an N-bit unsigned
value" in getConstant(), from a test case in zig.

Co-authored-by:  Craig Topper <craig.topper@sifive.com>
Fixes llvm#127296
androm3da added a commit to androm3da/llvm-project that referenced this pull request Feb 16, 2025
After llvm#117558 landed, this code would assert "Value is not an N-bit unsigned
value" in getConstant(), from a test case in zig.

Co-authored-by:  Craig Topper <craig.topper@sifive.com>
Fixes llvm#127296
androm3da added a commit that referenced this pull request Feb 17, 2025
After #117558 landed, this code would assert "Value is not an N-bit
unsigned value" in getConstant(), from a test case in zig.

Co-authored-by:  Craig Topper <craig.topper@sifive.com>
Fixes #127296
swift-ci pushed a commit to swiftlang/llvm-project that referenced this pull request Feb 18, 2025
After llvm#117558 landed, this code would assert "Value is not an N-bit
unsigned value" in getConstant(), from a test case in zig.

Co-authored-by:  Craig Topper <craig.topper@sifive.com>
Fixes llvm#127296

(cherry picked from commit 788cb72)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:SelectionDAG SelectionDAGISel as well
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants