diff options
Diffstat (limited to 'test/Transforms/GVN/tbaa.ll')
-rw-r--r-- | test/Transforms/GVN/tbaa.ll | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/test/Transforms/GVN/tbaa.ll b/test/Transforms/GVN/tbaa.ll index d6412fc..71fbed41 100644 --- a/test/Transforms/GVN/tbaa.ll +++ b/test/Transforms/GVN/tbaa.ll @@ -1,4 +1,4 @@ -; RUN: opt -basicaa -gvn -S < %s | FileCheck %s +; RUN: opt -tbaa -basicaa -gvn -S < %s | FileCheck %s define i32 @test1(i8* %p, i8* %q) { ; CHECK: @test1(i8* %p, i8* %q) @@ -72,20 +72,57 @@ define i32 @test7(i8* %p, i8* %q) { ret i32 %c } + + +define i32 @test8(i32* %p, i32* %q) { +; CHECK-LABEL: test8 +; CHECK-NEXT: store i32 15, i32* %p +; CHECK-NEXT: ret i32 0 +; Since we know the location is invariant, we can forward the +; load across the potentially aliasing store. + + %a = load i32* %q, !tbaa !10 + store i32 15, i32* %p + %b = load i32* %q, !tbaa !10 + %c = sub i32 %a, %b + ret i32 %c +} +define i32 @test9(i32* %p, i32* %q) { +; CHECK-LABEL: test9 +; CHECK-NEXT: call void @clobber() +; CHECK-NEXT: ret i32 0 +; Since we know the location is invariant, we can forward the +; load across the potentially aliasing store (within the call). + + %a = load i32* %q, !tbaa !10 + call void @clobber() + %b = load i32* %q, !tbaa !10 + %c = sub i32 %a, %b + ret i32 %c +} + + +declare void @clobber() declare i32 @foo(i8*) readonly -; CHECK: [[TAGC]] = metadata !{metadata [[TYPEC:!.*]], metadata [[TYPEC]], i64 0} -; CHECK: [[TYPEC]] = metadata !{metadata !"C", metadata [[TYPEA:!.*]]} -; CHECK: [[TYPEA]] = metadata !{metadata !"A", metadata !{{.*}}} -; CHECK: [[TAGB]] = metadata !{metadata [[TYPEB:!.*]], metadata [[TYPEB]], i64 0} -; CHECK: [[TYPEB]] = metadata !{metadata !"B", metadata [[TYPEA]]} -; CHECK: [[TAGA]] = metadata !{metadata [[TYPEA]], metadata [[TYPEA]], i64 0} -!0 = metadata !{metadata !5, metadata !5, i64 0} -!1 = metadata !{metadata !6, metadata !6, i64 0} -!2 = metadata !{metadata !"tbaa root", null} -!3 = metadata !{metadata !7, metadata !7, i64 0} -!4 = metadata !{metadata !8, metadata !8, i64 0} -!5 = metadata !{metadata !"C", metadata !6} -!6 = metadata !{metadata !"A", metadata !2} -!7 = metadata !{metadata !"B", metadata !6} -!8 = metadata !{metadata !"another root", null} +; CHECK: [[TAGC]] = !{[[TYPEC:!.*]], [[TYPEC]], i64 0} +; CHECK: [[TYPEC]] = !{!"C", [[TYPEA:!.*]]} +; CHECK: [[TYPEA]] = !{!"A", !{{.*}}} +; CHECK: [[TAGB]] = !{[[TYPEB:!.*]], [[TYPEB]], i64 0} +; CHECK: [[TYPEB]] = !{!"B", [[TYPEA]]} +; CHECK: [[TAGA]] = !{[[TYPEA]], [[TYPEA]], i64 0} +!0 = !{!5, !5, i64 0} +!1 = !{!6, !6, i64 0} +!2 = !{!"tbaa root", null} +!3 = !{!7, !7, i64 0} +!4 = !{!8, !8, i64 0} +!5 = !{!"C", !6} +!6 = !{!"A", !2} +!7 = !{!"B", !6} +!8 = !{!"another root", null} + + +;; A TBAA structure who's only point is to have a constant location +!9 = !{!"yet another root"} +!10 = !{!"node", !9, i64 1} + |