[PATCH] D99642: For non-null pointer checks, do not descend through out-of-bounds GEPs

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 7 09:34:17 PDT 2021


nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM, just some suggestions for the test.



================
Comment at: llvm/test/Analysis/ValueTracking/unknown-nonnull-gep-out-of-bounds.ll:1
+; RUN: opt -jump-threading -S %s -o - | FileCheck %s
+
----------------
This test should be in llvm/test/Transform/JumpThreading.


================
Comment at: llvm/test/Analysis/ValueTracking/unknown-nonnull-gep-out-of-bounds.ll:11
+entry:
+  %a = alloca i64, align 8
+  store i64 0, i64* %a, align 8
----------------
I'd pass in an `i64* %a` here -- the alloca case is less straightforward to me (because you'd have to guess the alloca offset to reach null).


================
Comment at: llvm/test/Analysis/ValueTracking/unknown-nonnull-gep-out-of-bounds.ll:21
+if.then:
+  %call0 = call i32 @puts(i8* noundef nonnull dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
+  br label %if.end
----------------
The puts calls don't seem relevant, I'd just replace these with `ret i32 0` and `ret i32 1` or so.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99642/new/

https://reviews.llvm.org/D99642



More information about the llvm-commits mailing list