[llvm] [IR] Use iteration limit in stripPointerCastsAndOffsets (PR #190472)

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 7 13:01:28 PDT 2026


aeubanks wrote:

this breaks the following:

```
$ cat /tmp/a.ll
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc19.34.0"

define void @foo() {
bb:
  %alloca = alloca i64, align 8
  %getelementptr = getelementptr i8, ptr %alloca, i32 0
  %getelementptr1 = getelementptr i8, ptr %getelementptr, i32 0
  %getelementptr2 = getelementptr i8, ptr %getelementptr1, i32 0
  %getelementptr3 = getelementptr i8, ptr %getelementptr2, i32 0
  %getelementptr4 = getelementptr i8, ptr %getelementptr3, i32 0
  %getelementptr5 = getelementptr i8, ptr %getelementptr4, i32 0
  %getelementptr6 = getelementptr i8, ptr %getelementptr5, i32 0
  %getelementptr7 = getelementptr i8, ptr %getelementptr6, i32 0
  %getelementptr8 = getelementptr i8, ptr %getelementptr7, i32 0
  %getelementptr9 = getelementptr i8, ptr %getelementptr8, i32 0
  %getelementptr10 = getelementptr i8, ptr %getelementptr9, i32 0
  %getelementptr11 = getelementptr i8, ptr %getelementptr10, i32 0
  %getelementptr12 = getelementptr i8, ptr %getelementptr11, i32 0
  store i64 0, ptr %getelementptr12, align 8
  ret void
}
$ llc -o /dev/null /tmp/a.ll
llc: ../../llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From *) [To = llvm::AllocaInst, From = const llvm::Value]: Assertion `isa<To>(Val) && "cas
t<Ty>() argument of incompatible type!"' 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: build/rel/bin/llc -o /dev/null /tmp/e.ll              
1.      Running pass 'Function Pass Manager' on module '/tmp/e.ll'.
2.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@foo'
 #0 0x00005616eda35758 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/Support/Unix/Sign
als.inc:880:13
 #1 0x00005616eda32715 llvm::sys::RunSignalHandlers() /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/Support/Signals.cpp:109:18
 #2 0x00005616eda35e81 SignalHandler(int, siginfo_t*, void*) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/Support/Unix/Signals.inc:448:38
 #3 0x00007f7c8ba40a70 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x40a70)
 #4 0x00007f7c8ba973dc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f7c8ba40942 raise ./signal/../sysdeps/posix/raise.c:27:6
 #6 0x00007f7c8ba284ac abort ./stdlib/abort.c:85:3
 #7 0x00007f7c8ba28420 __assert_perror_fail ./assert/assert-perr.c:31:1
 #8 0x00005616ed2059dd doit /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/Support/Casting.h:109:5
 #9 0x00005616ed2059dd doit /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/Support/Casting.h:137:12
#10 0x00005616ed2059dd doit /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/Support/Casting.h:127:12
#11 0x00005616ed2059dd isPossible /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/Support/Casting.h:255:12
#12 0x00005616ed2059dd isPossible /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/Support/Casting.h:509:12
#13 0x00005616ed2059dd isa<llvm::AllocaInst, const llvm::Value *> /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/Support/Casting.h
:548:11
#14 0x00005616ed2059dd cast<llvm::AllocaInst, const llvm::Value> /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/Support/Casting.h:
572:3
#15 0x00005616ed2059dd findArgumentCopyElisionCandidates /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/CodeGen/SelectionDAG/SelectionDAGBu
ilder.cpp:11739:28
#16 0x00005616ed2059dd llvm::SelectionDAGISel::LowerArguments(llvm::Function const&) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/CodeGen
/SelectionDAG/SelectionDAGBuilder.cpp:11873:3
#17 0x00005616ed23b541 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/C
odeGen/SelectionDAG/SelectionDAGISel.cpp:1693:3
#18 0x00005616ed239f61 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/
CodeGen/SelectionDAG/SelectionDAGISel.cpp:659:22
```

https://github.com/llvm/llvm-project/pull/190472


More information about the llvm-commits mailing list