[llvm] r259299 - [BasicAA] Fix for missing must alias (D16343)

Gerolf Hoflehner via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 29 21:52:53 PST 2016


Author: ghoflehner
Date: Fri Jan 29 23:52:53 2016
New Revision: 259299

URL: http://llvm.org/viewvc/llvm-project?rev=259299&view=rev
Log:
[BasicAA] Fix for missing must alias (D16343)

Added:
    llvm/trunk/test/Analysis/BasicAA/noalias-wraparound-bug.ll
Modified:
    llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=259299&r1=259298&r2=259299&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Fri Jan 29 23:52:53 2016
@@ -465,6 +465,9 @@ static int64_t adjustToPointerSize(int64
       }
     }
 
+    // Take care of wrap-arounds
+    BaseOffs = adjustToPointerSize(BaseOffs, PointerSize);
+
     // Analyze the base pointer next.
     V = GEPOp->getOperand(0);
   } while (--MaxLookup);

Added: llvm/trunk/test/Analysis/BasicAA/noalias-wraparound-bug.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/noalias-wraparound-bug.ll?rev=259299&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/BasicAA/noalias-wraparound-bug.ll (added)
+++ llvm/trunk/test/Analysis/BasicAA/noalias-wraparound-bug.ll Fri Jan 29 23:52:53 2016
@@ -0,0 +1,24 @@
+; RUN: opt -S -basicaa -gvn < %s | FileCheck %s
+
+target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
+target triple = "i386-apple-macosx10.6.0"
+
+; We incorrectly returned noalias in the example below for "tmp5" and
+; "tmp12" returning i32 32, since basicaa converted the offsets to 64b
+; and missed the wrap-around
+
+define i32 @foo(i8* %buffer) {
+entry:
+  %tmp2 = getelementptr i8, i8* %buffer, i32 -2071408432
+  %tmp3 = bitcast i8* %tmp2 to i32*
+  %tmp4 = getelementptr i8, i8* %buffer, i32 128
+  %tmp5 = bitcast i8* %tmp4 to i32*
+  store i32 32, i32* %tmp5, align 4
+  %tmp12 = getelementptr i32, i32* %tmp3, i32 -1629631508
+  store i32 28, i32* %tmp12, align 4
+  %tmp13 = getelementptr i8, i8* %buffer, i32 128
+  %tmp14 = bitcast i8* %tmp13 to i32*
+  %tmp2083 = load i32, i32* %tmp14, align 4
+; CHECK: ret i32 28
+  ret i32 %tmp2083
+}




More information about the llvm-commits mailing list