[PATCH] D133426: [LSR] Address a special case involving NULL.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 13 13:29:35 PDT 2022


efriedma added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:3478
+      } else if (const Constant *Const = dyn_cast<Constant>(V)) {
+        // NULL values don't really have a live range. They are just NULL.
+        if (Const->isNullValue())
----------------
NULL has a live range.

If you assume all the users of the NULL are GEPs, then I guess in practice the null is going to get eliminated... but GEPs from null should be extremely rare: it implies you're loading from an absolute address.  And it's undefined behavior to load from a null pointer unless the function is marked null_pointer_is_valid (or you're in a non-zero address space).


================
Comment at: llvm/test/Transforms/LoopStrengthReduce/Power/opaque-null-ptr.ll:27
+  %uglygep = getelementptr i8, ptr null, i64 %i184
+  %uglygep2 = getelementptr i8, ptr %uglygep, i64 4
+  %i190 = load float, ptr %uglygep2, align 4
----------------
Does this really reflect actual user code?  The first iteration of the loop loads from the constant addresses "4" and "8".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133426



More information about the llvm-commits mailing list