Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CFLAA] Add attributes handling for CFLAnders.
This patch adds proper handling of stratified attributes into our anders-style CFLAA implementation. It also comes bundled with more CFLAnders tests. :) Patch by Jia Chen. Differential Revision: https://reviews.llvm.org/D22325 llvm-svn: 275604
- Loading branch information
1 parent
62fba48
commit 22682e2
Showing
3 changed files
with
282 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
llvm/test/Analysis/CFLAliasAnalysis/Andersen/attrs-below.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
; This testcase ensures that AliasAttrs are propagated not only on the same | ||
; level but also downward. | ||
|
||
; RUN: opt < %s -disable-basicaa -cfl-anders-aa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s | ||
; RUN: opt < %s -aa-pipeline=cfl-anders-aa -passes=aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s | ||
|
||
; CHECK-LABEL: Function: test_attr_below | ||
; CHECK: MayAlias: i64* %q, i64*** %p | ||
; CHECK: NoAlias: i64* %esc, i64*** %p | ||
; CHECK: NoAlias: i64* %esc, i64* %q | ||
|
||
; CHECK: MayAlias: i64* %unknown, i64*** %p | ||
; CHECK: MayAlias: i64* %q, i64* %unknown | ||
; CHECK: MayAlias: i64* %esc, i64* %unknown | ||
; CHECK: MayAlias: i64* %q, i64** %pdrf | ||
; CHECK: MayAlias: i64* %esc, i64** %pdrf | ||
; CHECK: MayAlias: i64* %unknown, i64** %pdrf | ||
; CHECK: MayAlias: i64* %pdrf2, i64* %q | ||
; CHECK: MayAlias: i64* %esc, i64* %pdrf2 | ||
; CHECK: MayAlias: i64* %pdrf2, i64* %unknown | ||
define void @test_attr_below(i64*** %p, i64* %q) { | ||
%esc = alloca i64, align 8 | ||
%escint = ptrtoint i64* %esc to i64 | ||
%unknown = inttoptr i64 %escint to i64* | ||
|
||
%pdrf = load i64**, i64*** %p | ||
%pdrf2 = load i64*, i64** %pdrf | ||
|
||
ret void | ||
} | ||
|
||
; CHECK-LABEL: Function: test_attr_assign_below | ||
; CHECK: MayAlias: i64** %sel, i64*** %p | ||
; CHECK: MayAlias: i64* %q, i64** %sel | ||
; CHECK: MayAlias: i64** %a, i64** %sel | ||
; CHECK: MayAlias: i64** %pdrf, i64** %sel | ||
|
||
; CHECK: MayAlias: i64** %c, i64*** %p | ||
; CHECK: MayAlias: i64* %q, i64** %c | ||
; CHECK: MayAlias: i64** %a, i64** %c | ||
; CHECK: MayAlias: i64** %c, i64** %pdrf | ||
; CHECK: MayAlias: i64** %c, i64** %sel | ||
|
||
; CHECK: MayAlias: i64* %d, i64*** %p | ||
; CHECK: MayAlias: i64* %d, i64* %q | ||
; CHECK: MayAlias: i64* %d, i64** %pdrf | ||
; CHECK: MayAlias: i64* %d, i64** %sel | ||
define void @test_attr_assign_below(i64*** %p, i64* %q, i1 %cond) { | ||
%a = alloca i64*, align 8 | ||
%pdrf = load i64**, i64*** %p | ||
%sel = select i1 %cond, i64** %a, i64** %pdrf | ||
|
||
%b = alloca i64**, align 8 | ||
store i64** %sel, i64*** %b | ||
|
||
%c = load i64**, i64*** %b | ||
%d = load i64*, i64** %c | ||
|
||
ret void | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
; This testcase ensures that CFL AA handles escaped values no more conservative than it should | ||
|
||
; RUN: opt < %s -disable-basicaa -cfl-anders-aa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s | ||
; RUN: opt < %s -aa-pipeline=cfl-anders-aa -passes=aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s | ||
|
||
; CHECK-LABEL: Function: test_local | ||
; CHECK: NoAlias: i32* %a, i32* %b | ||
; CHECK: MayAlias: i32* %a, i32* %aAlias | ||
; CHECK: NoAlias: i32* %aAlias, i32* %b | ||
define void @test_local() { | ||
%a = alloca i32, align 4 | ||
%b = alloca i32, align 4 | ||
%aint = ptrtoint i32* %a to i64 | ||
%aAlias = inttoptr i64 %aint to i32* | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: Function: test_global_param | ||
; CHECK: NoAlias: i32* %a, i32** %x | ||
; CHECK: MayAlias: i32* %a, i32* %xload | ||
; CHECK: MayAlias: i32* %a, i32* %gload | ||
; CHECK: MayAlias: i32* %gload, i32* %xload | ||
; CHECK: MayAlias: i32** %x, i32** @ext_global | ||
; CHECK: NoAlias: i32* %a, i32** @ext_global | ||
@ext_global = external global i32* | ||
define void @test_global_param(i32** %x) { | ||
%a = alloca i32, align 4 | ||
%aint = ptrtoint i32* %a to i64 | ||
%xload = load i32*, i32** %x | ||
%gload = load i32*, i32** @ext_global | ||
ret void | ||
} | ||
|
||
declare void @external_func(i32**) | ||
; CHECK-LABEL: Function: test_external_call | ||
; CHECK: NoAlias: i32* %b, i32* %x | ||
; CHECK: NoAlias: i32* %b, i32** %a | ||
; CHECK: MayAlias: i32* %c, i32* %x | ||
; CHECK: MayAlias: i32* %c, i32** %a | ||
; CHECK: NoAlias: i32* %b, i32* %c | ||
define void @test_external_call(i32* %x) { | ||
%a = alloca i32*, align 8 | ||
%b = alloca i32, align 4 | ||
call void @external_func(i32** %a) | ||
%c = load i32*, i32** %a | ||
ret void | ||
} | ||
|
||
declare void @external_func_readonly(i32**) readonly | ||
; CHECK-LABEL: Function: test_external_call_func_readonly | ||
; CHECK: MayAlias: i32* %c, i32* %x | ||
; CHECK: NoAlias: i32* %c, i32** %a | ||
define void @test_external_call_func_readonly(i32* %x) { | ||
%a = alloca i32*, align 8 | ||
%b = alloca i32, align 4 | ||
store i32* %x, i32** %a, align 4 | ||
call void @external_func_readonly(i32** %a) | ||
%c = load i32*, i32** %a | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: Function: test_external_call_callsite_readonly | ||
; CHECK: MayAlias: i32* %c, i32* %x | ||
; CHECK: NoAlias: i32* %c, i32** %a | ||
define void @test_external_call_callsite_readonly(i32* %x) { | ||
%a = alloca i32*, align 8 | ||
%b = alloca i32, align 4 | ||
store i32* %x, i32** %a, align 4 | ||
call void @external_func(i32** %a) readonly | ||
%c = load i32*, i32** %a | ||
ret void | ||
} | ||
|
||
declare i32* @external_func_normal_return(i32*) | ||
; CHECK-LABEL: Function: test_external_call_normal_return | ||
; CHECK: MayAlias: i32* %c, i32* %x | ||
; CHECK: MayAlias: i32* %a, i32* %c | ||
define void @test_external_call_normal_return(i32* %x) { | ||
%a = alloca i32, align 8 | ||
%b = alloca i32, align 4 | ||
%c = call i32* @external_func_normal_return(i32* %a) | ||
ret void | ||
} | ||
|
||
declare noalias i32* @external_func_noalias_return(i32*) | ||
; CHECK-LABEL: Function: test_external_call_noalias_return | ||
; CHECK: NoAlias: i32* %c, i32* %x | ||
; CHECK: NoAlias: i32* %a, i32* %c | ||
define void @test_external_call_noalias_return(i32* %x) { | ||
%a = alloca i32, align 8 | ||
%b = alloca i32, align 4 | ||
%c = call i32* @external_func_noalias_return(i32* %a) | ||
ret void | ||
} |