[llvm] [BasicAA] Handle wrapping of pointer arithmetic (PR #69116)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 15 10:08:32 PDT 2023


================
@@ -1184,7 +1185,11 @@ AliasResult BasicAAResult::aliasGEP(
   APInt ModOffset = DecompGEP1.Offset.srem(GCD);
   if (ModOffset.isNegative())
     ModOffset += GCD; // We want mod, not rem.
-  if (ModOffset.uge(V2Size.getValue()) &&
+  unsigned PtrBW =
+      DL.getPointerSizeInBits(GEP1->getType()->getPointerAddressSpace());
+  if ((GCD.isPowerOf2() || !OffsetRange.sextOrTrunc(PtrBW).isFullSet() ||
+       (*DecompGEP1.InBounds && DecompGEP2.InBounds == true)) &&
+      ModOffset.uge(V2Size.getValue()) &&
----------------
nikic wrote:

I don't understand what you're trying to do here, but it's almost certainly not right. Please minimize the test case and provide an analysis of why it produced an incorrect result.

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


More information about the llvm-commits mailing list