mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-27 13:30:05 +00:00
Testcases for andersen's alias analysis.
I think this is all of the stuff I had pending in my tree.. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13703 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f52988a92d
commit
2b83af553a
17
test/Analysis/Andersens/arg-must-alias.ll
Normal file
17
test/Analysis/Andersens/arg-must-alias.ll
Normal file
@ -0,0 +1,17 @@
|
||||
; RUN: llvm-as < %s | opt -anders-aa -load-vn -gcse -deadargelim | llvm-dis | not grep ARG
|
||||
|
||||
%G = internal constant int* null
|
||||
|
||||
implementation
|
||||
|
||||
internal int %internal(int* %ARG) {
|
||||
;; The 'Arg' argument must-aliases the null pointer, so it can be subsituted
|
||||
;; directly here, making it dead.
|
||||
store int* %ARG, int** %G
|
||||
ret int 0
|
||||
}
|
||||
|
||||
int %foo() {
|
||||
%V = call int %internal(int* null)
|
||||
ret int %V
|
||||
}
|
29
test/Analysis/Andersens/basictest.ll
Normal file
29
test/Analysis/Andersens/basictest.ll
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
implementation
|
||||
|
||||
void %test1() {
|
||||
%X = malloc int*
|
||||
%Y = malloc int
|
||||
%Z = cast int* %Y to int
|
||||
%W = cast int %Z to int*
|
||||
store int* %W, int** %X
|
||||
ret void
|
||||
}
|
||||
|
||||
void %test2(int* %P) {
|
||||
%X = malloc int*
|
||||
%Y = malloc int
|
||||
store int* %P, int** %X
|
||||
ret void
|
||||
}
|
||||
|
||||
internal int *%test3(int* %P) {
|
||||
ret int* %P
|
||||
}
|
||||
|
||||
void %test4() {
|
||||
%X = malloc int
|
||||
%Y = call int* %test3(int* %X)
|
||||
%ZZ = getelementptr int* null, int 17
|
||||
ret void
|
||||
}
|
22
test/Analysis/Andersens/external.ll
Normal file
22
test/Analysis/Andersens/external.ll
Normal file
@ -0,0 +1,22 @@
|
||||
; RUN: llvm-as < %s | opt -anders-aa -load-vn -gcse -deadargelim | llvm-dis | grep store | not grep null
|
||||
|
||||
; Because the 'internal' function is passed to an external function, we don't
|
||||
; know what the incoming values will alias. As such, we cannot do the
|
||||
; optimization checked by the 'arg-must-alias.llx' test.
|
||||
|
||||
declare void %external(int(int*)*)
|
||||
%G = internal constant int* null
|
||||
|
||||
implementation
|
||||
|
||||
internal int %internal(int* %ARG) {
|
||||
;;; We *DON'T* know that ARG always points to null!
|
||||
store int* %ARG, int** %G
|
||||
ret int 0
|
||||
}
|
||||
|
||||
int %foo() {
|
||||
call void %external(int(int*)* %internal)
|
||||
%V = call int %internal(int* null)
|
||||
ret int %V
|
||||
}
|
Loading…
Reference in New Issue
Block a user