[PATCH] D154051: [LangRef] Always allow getelementptr inbounds with zero offset
Nuno Lopes via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 30 01:45:07 PDT 2023
nlopes accepted this revision.
nlopes added a comment.
This revision is now accepted and ready to land.
I've implemented this semantics in Alive2 and run it over LLVM's test suite.
There are only 2 regressions, and they seem ok:
+ LLVM :: Transforms/InstCombine/gep-inbounds-null.ll
define i1 @test_eq(ptr %base, i64 %idx) {
%gep = gep inbounds ptr %base, 1 x i64 %idx
%cnd = icmp eq ptr %gep, null
ret i1 %cnd
}
=>
define i1 @test_eq(ptr %base, i64 %idx) {
%cnd = icmp eq ptr %base, null ; wrong since %base can be OOB
ret i1 %cnd
}
+ LLVM :: Transforms/InstSimplify/gep.ll
define ptr @undef_inbounds_var_idx(i64 %idx) {
%el = gep inbounds ptr undef, 8 x i64 %idx
ret ptr %el
}
=>
define ptr @undef_inbounds_var_idx(i64 %idx) {
ret ptr poison ; only ok if %idx != 0
}
Therefore, if this change helps Rust, let's do it. It's backwards compatible since it's removing some UB behavior from before.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154051/new/
https://reviews.llvm.org/D154051
More information about the llvm-commits
mailing list