[llvm] [LVI] Handle nonnull attributes at callsite (PR #125377)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 2 07:59:49 PST 2025


================
@@ -622,10 +622,12 @@ LazyValueInfoImpl::solveBlockValueImpl(Value *Val, BasicBlock *BB) {
   return getFromRangeMetadata(BBI);
 }
 
-static void AddNonNullPointer(Value *Ptr, NonNullPointerSet &PtrSet) {
+static void AddNonNullPointer(Value *Ptr, NonNullPointerSet &PtrSet,
+                              bool IsDereferenced = true) {
   // TODO: Use NullPointerIsDefined instead.
   if (Ptr->getType()->getPointerAddressSpace() == 0)
-    PtrSet.insert(getUnderlyingObject(Ptr));
+    PtrSet.insert(IsDereferenced ? getUnderlyingObject(Ptr)
+                                 : Ptr->stripInBoundsOffsets());
----------------
nikic wrote:

As a followup, it may be worth checking whether always using stripInBoundsOffset() has a positive effect on llvm-opt-benchmark. The lookup always uses stripInBoundsOffset(), so currently there is mismatch between getUnderlyingObject on one side an stripInBoundsOffset on the other and it may give better results to always use only stripInBoundsOffset.

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


More information about the llvm-commits mailing list