llvm-6502/test/Analysis/TypeBasedAliasAnalysis/precedence.ll
Manman Ren 9e81c3bdb2 TBAA: handle scalar TBAA format and struct-path aware TBAA format.
Remove the command line argument "struct-path-tbaa" since we should not depend
on command line argument to decide which format the IR file is using. Instead,
we check the first operand of the tbaa tag node, if it is a MDNode, we treat
it as struct-path aware TBAA format, otherwise, we treat it as scalar TBAA
format.

When clang starts to use struct-path aware TBAA format no matter whether
struct-path-tbaa is no, and we can auto-upgrade existing bc files, the support
for scalar TBAA format can be dropped.

Existing testing cases are updated to use the struct-path aware TBAA format.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191538 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-27 18:34:27 +00:00

51 lines
1.6 KiB
LLVM

; RUN: opt -basicaa -tbaa -gvn -instcombine -S < %s | FileCheck %s --check-prefix=TBAA
; RUN: opt -tbaa -basicaa -gvn -instcombine -S < %s | FileCheck %s --check-prefix=BASICAA
; According to the TBAA metadata the load and store don't alias. However,
; according to the actual code, they do. The order of the alias analysis
; passes should determine which of these takes precedence.
target datalayout = "e-p:64:64:64"
; Test for simple MustAlias aliasing.
; TBAA: @trouble
; TBAA: ret i32 0
; BASICAA: @trouble
; BASICAA: ret i32 1075000115
define i32 @trouble(i32* %x) nounwind {
entry:
store i32 0, i32* %x, !tbaa !0
%0 = bitcast i32* %x to float*
store float 0x4002666660000000, float* %0, !tbaa !3
%tmp3 = load i32* %x, !tbaa !0
ret i32 %tmp3
}
; Test for PartialAlias aliasing. GVN doesn't yet eliminate the load
; in the BasicAA case.
; TBAA: @offset
; TBAA: ret i64 0
; BASICAA: @offset
; BASICAA: ret i64 %tmp3
define i64 @offset(i64* %x) nounwind {
entry:
store i64 0, i64* %x, !tbaa !4
%0 = bitcast i64* %x to i8*
%1 = getelementptr i8* %0, i64 1
store i8 1, i8* %1, !tbaa !5
%tmp3 = load i64* %x, !tbaa !4
ret i64 %tmp3
}
!0 = metadata !{metadata !2, metadata !2, i64 0}
!1 = metadata !{metadata !"simple"}
!2 = metadata !{metadata !"int", metadata !1}
!3 = metadata !{metadata !6, metadata !6, i64 0}
!4 = metadata !{metadata !7, metadata !7, i64 0}
!5 = metadata !{metadata !8, metadata !8, i64 0}
!6 = metadata !{metadata !"float", metadata !1}
!7 = metadata !{metadata !"long", metadata !1}
!8 = metadata !{metadata !"small", metadata !1}