mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-30 23:21:04 +00:00
Move Transforms/BasicAA to Analysis/BasicAA
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15316 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
08f998f08d
commit
acb7444b05
@ -1,18 +0,0 @@
|
||||
; This testcase makes sure that size is taken to account when alias analysis
|
||||
; is performed. It is not legal to delete the second load instruction because
|
||||
; the value computed by the first load instruction is changed by the store.
|
||||
|
||||
; RUN: llvm-as < %s | opt -load-vn -gcse -instcombine | llvm-dis | grep DONOTREMOVE
|
||||
|
||||
int %test() {
|
||||
%A = alloca int
|
||||
store int 0, int* %A
|
||||
%X = load int* %A
|
||||
%B = cast int* %A to sbyte*
|
||||
%C = getelementptr sbyte* %B, long 1
|
||||
store sbyte 1, sbyte* %C ; Aliases %A
|
||||
%Y.DONOTREMOVE = load int* %A
|
||||
%Z = sub int %X, %Y.DONOTREMOVE
|
||||
ret int %Z
|
||||
}
|
||||
|
@ -1,7 +0,0 @@
|
||||
; RUN: llvm-as < %s | opt -basicaa -aa-eval -disable-output
|
||||
; Test for a bug in BasicAA which caused a crash when querying equality of P1&P2
|
||||
void %test({[2 x int],[2 x int]}* %A, long %X, long %Y) {
|
||||
%P1 = getelementptr {[2 x int],[2 x int]}* %A, long 0, ubyte 0, long %X
|
||||
%P2 = getelementptr {[2 x int],[2 x int]}* %A, long 0, ubyte 1, long %Y
|
||||
ret void
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
; RUN: llvm-as < %s | opt -load-vn -gcse -instcombine | llvm-dis | grep sub
|
||||
|
||||
; BasicAA was incorrectly concluding that P1 and P2 didn't conflict!
|
||||
|
||||
int %test(int *%Ptr, long %V) {
|
||||
%P2 = getelementptr int* %Ptr, long 1
|
||||
%P1 = getelementptr int* %Ptr, long %V
|
||||
%X = load int* %P1
|
||||
store int 5, int* %P2
|
||||
|
||||
%Y = load int* %P1
|
||||
|
||||
%Z = sub int %X, %Y
|
||||
ret int %Z
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
; RUN: llvm-as < %s | opt -basicaa -aa-eval -disable-output
|
||||
; Test for a bug in BasicAA which caused a crash when querying equality of P1&P2
|
||||
void %test([17 x ushort]* %mask_bits) {
|
||||
%P1 = getelementptr [17 x ushort]* %mask_bits, long 0, long 0
|
||||
%P2 = getelementptr [17 x ushort]* %mask_bits, long 252645134, long 0
|
||||
ret void
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
; RUN: llvm-as < %s | opt -licm -disable-output
|
||||
%struct..apr_array_header_t = type { int*, int, int, int, sbyte* }
|
||||
%struct..apr_table_t = type { %struct..apr_array_header_t, uint, [32 x int], [32 x int] }
|
||||
|
||||
void %table_reindex(%struct..apr_table_t* %t.1) { ; No predecessors!
|
||||
br label %loopentry
|
||||
|
||||
loopentry: ; preds = %0, %no_exit
|
||||
%tmp.101 = getelementptr %struct..apr_table_t* %t.1, long 0, ubyte 0, ubyte 2 ; <int*> [#uses=1]
|
||||
%tmp.11 = load int* %tmp.101 ; <int> [#uses=0]
|
||||
br bool false, label %no_exit, label %UnifiedExitNode
|
||||
|
||||
no_exit: ; preds = %loopentry
|
||||
%tmp.25 = cast int 0 to long ; <long> [#uses=1]
|
||||
%tmp.261 = getelementptr %struct..apr_table_t* %t.1, long 0, ubyte 3, long %tmp.25 ; <int*> [#uses=1]
|
||||
store int 0, int* %tmp.261
|
||||
br label %loopentry
|
||||
|
||||
UnifiedExitNode: ; preds = %loopentry
|
||||
ret void
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
; RUN: llvm-as < %s | opt -basicaa -aa-eval -disable-output
|
||||
|
||||
int %MTConcat([3 x int]* %a.1) {
|
||||
%tmp.961 = getelementptr [3 x int]* %a.1, long 0, long 4
|
||||
%tmp.97 = load int* %tmp.961
|
||||
%tmp.119 = getelementptr [3 x int]* %a.1, long 1, long 0
|
||||
%tmp.120 = load int* %tmp.119
|
||||
%tmp.1541 = getelementptr [3 x int]* %a.1, long 0, long 4
|
||||
%tmp.155 = load int* %tmp.1541
|
||||
ret int 0
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
; RUN: llvm-as < %s | opt -basicaa -aa-eval -disable-output
|
||||
|
||||
%struct..RefPoint = type { int, { uint, ushort, ushort } }
|
||||
%struct..RefRect = type { %struct..RefPoint, %struct..RefPoint }
|
||||
|
||||
implementation ; Functions:
|
||||
|
||||
uint %BMT_CommitPartDrawObj() {
|
||||
%tmp.19111 = getelementptr %struct..RefRect* null, long 0, ubyte 0, ubyte 1, ubyte 2
|
||||
%tmp.20311 = getelementptr %struct..RefRect* null, long 0, ubyte 1, ubyte 1, ubyte 2
|
||||
ret uint 0
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
; In this test, a local alloca cannot alias an incoming argument.
|
||||
|
||||
; RUN: llvm-as < %s | opt -load-vn -gcse -instcombine | llvm-dis | not grep sub
|
||||
|
||||
int %test(int* %P) {
|
||||
%X = alloca int
|
||||
%V1 = load int* %P
|
||||
store int 0, int* %X
|
||||
%V2 = load int* %P
|
||||
%Diff = sub int %V1, %V2
|
||||
ret int %Diff
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
; This testcase consists of alias relations which should be completely
|
||||
; resolvable by basicaa.
|
||||
|
||||
; RUN: llvm-as < %s | opt -aa-eval -print-may-aliases 2>&1 -disable-output | not grep May:
|
||||
|
||||
%T = type { uint, [10 x ubyte] }
|
||||
|
||||
void %test(%T* %P) {
|
||||
%A = getelementptr %T* %P, long 0
|
||||
%B = getelementptr %T* %P, long 0, ubyte 0
|
||||
%C = getelementptr %T* %P, long 0, ubyte 1
|
||||
%D = getelementptr %T* %P, long 0, ubyte 1, long 0
|
||||
%E = getelementptr %T* %P, long 0, ubyte 1, long 5
|
||||
ret void
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
; This testcase consists of alias relations which should be completely
|
||||
; resolvable by basicaa, but require analysis of getelementptr constant exprs.
|
||||
|
||||
; RUN: llvm-as < %s | opt -aa-eval -print-may-aliases 2>&1 -disable-output | not grep May:
|
||||
|
||||
%T = type { uint, [10 x ubyte] }
|
||||
|
||||
%G = external global %T
|
||||
|
||||
void %test() {
|
||||
%D = getelementptr %T* %G, long 0, ubyte 0
|
||||
%E = getelementptr %T* %G, long 0, ubyte 1, long 5
|
||||
%F = getelementptr uint* getelementptr (%T* %G, long 0, ubyte 0), long 0
|
||||
%X = getelementptr [10 x ubyte]* getelementptr (%T* %G, long 0, ubyte 1), long 0, long 5
|
||||
|
||||
ret void
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
; RUN: llvm-as < %s | opt -load-vn -gcse -instcombine | llvm-dis | not grep load
|
||||
|
||||
%X = constant [2 x int] [int 4, int 5]
|
||||
|
||||
int %test(int* %Y, long %idx) {
|
||||
%P = getelementptr [2 x int]* %X, long 0, long %idx
|
||||
%A = load int* %P ; Load from invariant memory
|
||||
store int 4, int* %Y ; Store could not be to %X
|
||||
%B = load int* %P
|
||||
%C = sub int %A, %B
|
||||
ret int %C
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
; RUN: llvm-as < %s | opt -dse | llvm-dis | grep 'store int 0'
|
||||
|
||||
void %test({int,int }* %P) {
|
||||
%Q = getelementptr {int,int}* %P, int 1
|
||||
%X = getelementptr {int,int}* %Q, int 0, uint 1
|
||||
%Y = getelementptr {int,int}* %Q, int 1, uint 1
|
||||
store int 0, int* %X
|
||||
store int 1, int* %Y
|
||||
ret void
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
; This testcase tests for various features the basicaa test should be able to
|
||||
; determine, as noted in the comments.
|
||||
|
||||
; RUN: llvm-as < %s | opt -basicaa -load-vn -gcse -instcombine -dce | llvm-dis | not grep REMOVE
|
||||
|
||||
%Global = external global { int }
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
; Array test: Test that operations on one local array do not invalidate
|
||||
; operations on another array. Important for scientific codes.
|
||||
;
|
||||
int %different_array_test(long %A, long %B) {
|
||||
%Array1 = alloca int, uint 100
|
||||
%Array2 = alloca int, uint 200
|
||||
|
||||
%pointer = getelementptr int* %Array1, long %A
|
||||
%val = load int* %pointer
|
||||
|
||||
%pointer2 = getelementptr int* %Array2, long %B
|
||||
store int 7, int* %pointer2
|
||||
|
||||
%REMOVE = load int* %pointer ; redundant with above load
|
||||
%retval = sub int %REMOVE, %val
|
||||
ret int %retval
|
||||
}
|
||||
|
||||
; Constant index test: Constant indexes into the same array should not
|
||||
; interfere with each other. Again, important for scientific codes.
|
||||
;
|
||||
int %constant_array_index_test() {
|
||||
%Array = alloca int, uint 100
|
||||
%P1 = getelementptr int* %Array, long 7
|
||||
%P2 = getelementptr int* %Array, long 6
|
||||
|
||||
%A = load int* %P1
|
||||
store int 1, int* %P2 ; Should not invalidate load
|
||||
%BREMOVE = load int* %P1
|
||||
%Val = sub int %A, %BREMOVE
|
||||
ret int %Val
|
||||
}
|
||||
|
||||
; Test that if two pointers are spaced out by a constant getelementptr, that
|
||||
; they cannot alias.
|
||||
int %gep_distance_test(int* %A) {
|
||||
%REMOVEu = load int* %A
|
||||
%B = getelementptr int* %A, long 2 ; Cannot alias A
|
||||
store int 7, int* %B
|
||||
%REMOVEv = load int* %A
|
||||
%r = sub int %REMOVEu, %REMOVEv
|
||||
ret int %r
|
||||
}
|
||||
|
||||
; Test that if two pointers are spaced out by a constant offset, that they
|
||||
; cannot alias, even if there is a variable offset between them...
|
||||
int %gep_distance_test2({int,int}* %A, long %distance) {
|
||||
%A = getelementptr {int,int}* %A, long 0, ubyte 0
|
||||
%REMOVEu = load int* %A
|
||||
%B = getelementptr {int,int}* %A, long %distance, ubyte 1
|
||||
store int 7, int* %B ; B cannot alias A, it's at least 4 bytes away
|
||||
%REMOVEv = load int* %A
|
||||
%r = sub int %REMOVEu, %REMOVEv
|
||||
ret int %r
|
||||
}
|
||||
|
||||
; Test that we can do funny pointer things and that distance calc will still
|
||||
; work.
|
||||
int %gep_distance_test3(int * %A) {
|
||||
%X = load int* %A
|
||||
%B = cast int* %A to sbyte*
|
||||
%C = getelementptr sbyte* %B, long 4
|
||||
%Y = load sbyte* %C
|
||||
ret int 8
|
||||
}
|
||||
|
||||
; Test that we can disambiguate globals reached through constantexpr geps
|
||||
int %constexpr_test() {
|
||||
%X = alloca int
|
||||
%Y = load int* %X
|
||||
store int 5, int* getelementptr ({ int }* %Global, long 0, ubyte 0)
|
||||
%REMOVE = load int* %X
|
||||
%retval = sub int %Y, %REMOVE
|
||||
ret int %retval
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
; Test that GCSE uses basicaa to do alias analysis, which is capable of
|
||||
; disambiguating some obvious cases. All loads should be removable in
|
||||
; this testcase.
|
||||
|
||||
; RUN: llvm-as < %s | opt -basicaa -load-vn -gcse -instcombine -dce | llvm-dis | not grep load
|
||||
|
||||
%A = global int 7
|
||||
%B = global int 8
|
||||
implementation
|
||||
|
||||
int %test() {
|
||||
%A1 = load int* %A
|
||||
|
||||
store int 123, int* %B ; Store cannot alias %A
|
||||
|
||||
%A2 = load int* %A
|
||||
%X = sub int %A1, %A2
|
||||
ret int %X
|
||||
}
|
||||
|
||||
int %test2() {
|
||||
%A1 = load int* %A
|
||||
br label %Loop
|
||||
Loop:
|
||||
%AP = phi int [0, %0], [%X, %Loop]
|
||||
store int %AP, int* %B ; Store cannot alias %A
|
||||
|
||||
%A2 = load int* %A
|
||||
%X = sub int %A1, %A2
|
||||
%c = seteq int %X, 0
|
||||
br bool %c, label %out, label %Loop
|
||||
|
||||
out:
|
||||
ret int %X
|
||||
}
|
||||
|
||||
declare void %external()
|
||||
|
||||
int %test3() {
|
||||
%X = alloca int
|
||||
store int 7, int* %X
|
||||
call void %external()
|
||||
%V = load int* %X
|
||||
ret int %V
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
; Test that LICM uses basicaa to do alias analysis, which is capable of
|
||||
; disambiguating some obvious cases. If LICM is able to disambiguate the
|
||||
; two pointers, then the load should be hoisted, and the store sunk. Thus
|
||||
; the loop becomes empty and can be deleted by ADCE.
|
||||
|
||||
; RUN: llvm-as < %s | opt -basicaa -licm --adce | llvm-dis | not grep Loop
|
||||
|
||||
%A = global int 7
|
||||
%B = global int 8
|
||||
%C = global [2 x int ] [ int 4, int 8 ]
|
||||
implementation
|
||||
|
||||
int %test(bool %c) {
|
||||
%Atmp = load int* %A
|
||||
br label %Loop
|
||||
Loop:
|
||||
%ToRemove = load int* %A
|
||||
store int %Atmp, int* %B ; Store cannot alias %A
|
||||
|
||||
br bool %c, label %Out, label %Loop
|
||||
Out:
|
||||
%X = sub int %ToRemove, %Atmp
|
||||
ret int %X
|
||||
}
|
||||
|
||||
int %test2(bool %c) {
|
||||
br label %Loop
|
||||
Loop:
|
||||
%AVal = load int* %A
|
||||
%C0 = getelementptr [2 x int ]* %C, long 0, long 0
|
||||
store int %AVal, int* %C0 ; Store cannot alias %A
|
||||
|
||||
%BVal = load int* %B
|
||||
%C1 = getelementptr [2 x int ]* %C, long 0, long 1
|
||||
store int %BVal, int* %C1 ; Store cannot alias %A, %B, or %C0
|
||||
|
||||
br bool %c, label %Out, label %Loop
|
||||
Out:
|
||||
%X = sub int %AVal, %BVal
|
||||
ret int %X
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user