[clang] [Clang][CodeGen] Use ptrtoaddr for pointer diff (PR #210729)
Devon Loehr via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 26 10:54:47 PDT 2026
DKLoehr wrote:
Further investigation: `opt-bisect-limit` narrows down the relevant pass to `dse`. If I write out the IR, the relevant part of the diff is this (everything else only differs in variable names, since the `dse` version defines two fewer variables at this part):
```
@@ -1043,155 +1043,151 @@ define internal void @_ZN12_GLOBAL__N_144RangeAdapterLValueTest_TrivialOperation
store i32 0, ptr %16, align 4, !tbaa !115
%17 = getelementptr inbounds nuw i8, ptr %16, i64 4
store i32 1, ptr %17, align 4, !tbaa !115
- %18 = getelementptr inbounds nuw i8, ptr %16, i64 8
- store i32 2, ptr %18, align 4, !tbaa !115
- %19 = getelementptr inbounds nuw i8, ptr %16, i64 12
- store i32 3, ptr %19, align 4, !tbaa !115
- %20 = getelementptr inbounds nuw i8, ptr %16, i64 16
- %21 = ptrtoaddr ptr %20 to i64
+ %18 = getelementptr inbounds nuw i8, ptr %16, i64 16
+ %19 = ptrtoaddr ptr %18 to i64
call void @llvm.assume(i1 true) [ "align"(ptr %16, i64 4) ]
```
That is, those first 4 lines get eliminated by `dse` after this change, which seems to be causing the problems.
https://github.com/llvm/llvm-project/pull/210729
More information about the cfe-commits
mailing list