[llvm] r265474 - [CFLAA] Fix PR27213; incorrect tagging of args/globals
George Burgess IV via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 5 14:40:45 PDT 2016
Author: gbiv
Date: Tue Apr 5 16:40:45 2016
New Revision: 265474
URL: http://llvm.org/viewvc/llvm-project?rev=265474&view=rev
Log:
[CFLAA] Fix PR27213; incorrect tagging of args/globals
Prior to this patch, CFLAA wouldn't tag arguments/globals properly if
it didn't find any "interesting" edges on them. This means that, if all
you do is store constants to a global or argument, we would never
actually treat it as a global/argument.
Test case:
define void @foo(i32* %A, i32* %B) #0 {
entry:
store i32 0, i32* %A, align 4
store i32 0, i32* %B, align 4
ret void
}
CFLAA would say that %A can't alias %B, because neither pointer was
used in an interesting way. This patch makes us note whether something
is an argument, global, ... regardless of how interesting CFLAA thinks
its uses are.
(For the record, using a value in an interesting way means loading
from it, using it in a GEP, ...)
Added:
llvm/trunk/test/Analysis/CFLAliasAnalysis/pr27213.ll
Modified:
llvm/trunk/lib/Analysis/CFLAliasAnalysis.cpp
llvm/trunk/test/Analysis/CFLAliasAnalysis/basic-interproc.ll
Modified: llvm/trunk/lib/Analysis/CFLAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CFLAliasAnalysis.cpp?rev=265474&r1=265473&r2=265474&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CFLAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/CFLAliasAnalysis.cpp Tue Apr 5 16:40:45 2016
@@ -941,6 +941,10 @@ CFLAAResult::FunctionInfo CFLAAResult::b
if (canSkipAddingToSets(CurValue))
continue;
+ Optional<StratifiedAttr> MaybeCurIndex = valueToAttrIndex(CurValue);
+ if (MaybeCurIndex)
+ Builder.noteAttributes(CurValue, *MaybeCurIndex);
+
for (const auto &EdgeTuple : Graph.edgesFor(Node)) {
auto Weight = std::get<0>(EdgeTuple);
auto Label = Weight.first;
@@ -964,7 +968,7 @@ CFLAAResult::FunctionInfo CFLAAResult::b
}
auto Aliasing = Weight.second;
- if (auto MaybeCurIndex = valueToAttrIndex(CurValue))
+ if (MaybeCurIndex)
Aliasing.set(*MaybeCurIndex);
if (auto MaybeOtherIndex = valueToAttrIndex(OtherValue))
Aliasing.set(*MaybeOtherIndex);
Modified: llvm/trunk/test/Analysis/CFLAliasAnalysis/basic-interproc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CFLAliasAnalysis/basic-interproc.ll?rev=265474&r1=265473&r2=265474&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/CFLAliasAnalysis/basic-interproc.ll (original)
+++ llvm/trunk/test/Analysis/CFLAliasAnalysis/basic-interproc.ll Tue Apr 5 16:40:45 2016
@@ -4,11 +4,8 @@
; RUN: opt < %s -disable-basicaa -cfl-aa -aa-eval -print-may-aliases -disable-output 2>&1 | FileCheck %s
; RUN: opt < %s -aa-pipeline=cfl-aa -passes=aa-eval -print-may-aliases -disable-output 2>&1 | FileCheck %s
-; CHECK: Function: test
-; CHECK: 2 Total Alias Queries Performed
-; CHECK: 1 no alias responses
-; ^^ In @test2, %arg1 and %arg2 may alias
-
+; CHECK: Function: test2
+; CHECK: MayAlias: i32* %arg1, i32* %arg2
define void @test2(i32* %arg1, i32* %arg2) {
store i32 0, i32* %arg1
store i32 0, i32* %arg2
Added: llvm/trunk/test/Analysis/CFLAliasAnalysis/pr27213.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CFLAliasAnalysis/pr27213.ll?rev=265474&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/CFLAliasAnalysis/pr27213.ll (added)
+++ llvm/trunk/test/Analysis/CFLAliasAnalysis/pr27213.ll Tue Apr 5 16:40:45 2016
@@ -0,0 +1,39 @@
+; RUN: opt < %s -disable-basicaa -cfl-aa -aa-eval -print-may-aliases -disable-output 2>&1 | FileCheck %s
+; RUN: opt < %s -aa-pipeline=cfl-aa -passes=aa-eval -print-may-aliases -disable-output 2>&1 | FileCheck %s
+
+; CHECK-LABEL: Function: foo
+; CHECK: MayAlias: i32* %A, i32* %B
+define void @foo(i32* %A, i32* %B) {
+entry:
+ store i32 0, i32* %A, align 4
+ store i32 0, i32* %B, align 4
+ ret void
+}
+
+; CHECK-LABEL: Function: bar
+; CHECK: MayAlias: i32* %A, i32* %B
+; CHECK: MayAlias: i32* %A, i32* %arrayidx
+; CHECK: MayAlias: i32* %B, i32* %arrayidx
+define void @bar(i32* %A, i32* %B) {
+entry:
+ store i32 0, i32* %A, align 4
+ %arrayidx = getelementptr inbounds i32, i32* %B, i64 1
+ store i32 0, i32* %arrayidx, align 4
+ ret void
+}
+
+ at G = global i32 0
+
+; CHECK-LABEL: Function: baz
+; CHECK: MayAlias: i32* %A, i32* @G
+define void @baz(i32* %A) {
+entry:
+ store i32 0, i32* %A, align 4
+ store i32 0, i32* @G, align 4
+ ret void
+}
+
+; CHECK-LABEL: Alias Analysis Evaluator Report
+; CHECK: 5 Total Alias Queries Performed
+; CHECK: 0 no alias responses
+; CHECK: 5 may alias responses
More information about the llvm-commits
mailing list