Skip to content

Commit 87ddb65

Browse files
committed
[BasicAA] Fix for missing must alias (D16343)
llvm-svn: 259299
1 parent 73fc84b commit 87ddb65

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Diff for: llvm/lib/Analysis/BasicAliasAnalysis.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,9 @@ static int64_t adjustToPointerSize(int64_t Offset, unsigned PointerSize) {
465465
}
466466
}
467467

468+
// Take care of wrap-arounds
469+
BaseOffs = adjustToPointerSize(BaseOffs, PointerSize);
470+
468471
// Analyze the base pointer next.
469472
V = GEPOp->getOperand(0);
470473
} while (--MaxLookup);

Diff for: llvm/test/Analysis/BasicAA/noalias-wraparound-bug.ll

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
; RUN: opt -S -basicaa -gvn < %s | FileCheck %s
2+
3+
target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
4+
target triple = "i386-apple-macosx10.6.0"
5+
6+
; We incorrectly returned noalias in the example below for "tmp5" and
7+
; "tmp12" returning i32 32, since basicaa converted the offsets to 64b
8+
; and missed the wrap-around
9+
10+
define i32 @foo(i8* %buffer) {
11+
entry:
12+
%tmp2 = getelementptr i8, i8* %buffer, i32 -2071408432
13+
%tmp3 = bitcast i8* %tmp2 to i32*
14+
%tmp4 = getelementptr i8, i8* %buffer, i32 128
15+
%tmp5 = bitcast i8* %tmp4 to i32*
16+
store i32 32, i32* %tmp5, align 4
17+
%tmp12 = getelementptr i32, i32* %tmp3, i32 -1629631508
18+
store i32 28, i32* %tmp12, align 4
19+
%tmp13 = getelementptr i8, i8* %buffer, i32 128
20+
%tmp14 = bitcast i8* %tmp13 to i32*
21+
%tmp2083 = load i32, i32* %tmp14, align 4
22+
; CHECK: ret i32 28
23+
ret i32 %tmp2083
24+
}

0 commit comments

Comments
 (0)