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
This commit is contained in:
Manman Ren 2013-09-27 18:34:27 +00:00
parent d237e834a8
commit 9e81c3bdb2
28 changed files with 252 additions and 110 deletions

View File

@ -16,7 +16,12 @@
// typical C/C++ TBAA, but it can also be used to implement custom alias
// analysis behavior for other languages.
//
// The current metadata format is very simple. TBAA MDNodes have up to
// We now support two types of metadata format: scalar TBAA and struct-path
// aware TBAA. After all testing cases are upgraded to use struct-path aware
// TBAA and we can auto-upgrade existing bc files, the support for scalar TBAA
// can be dropped.
//
// The scalar TBAA metadata format is very simple. TBAA MDNodes have up to
// three fields, e.g.:
// !0 = metadata !{ metadata !"an example type tree" }
// !1 = metadata !{ metadata !"int", metadata !0 }
@ -40,6 +45,65 @@
// should return true; see
// http://llvm.org/docs/AliasAnalysis.html#OtherItfs).
//
// With struct-path aware TBAA, the MDNodes attached to an instruction using
// "!tbaa" are called path tag nodes.
//
// The path tag node has 4 fields with the last field being optional.
//
// The first field is the base type node, it can be a struct type node
// or a scalar type node. The second field is the access type node, it
// must be a scalar type node. The third field is the offset into the base type.
// The last field has the same meaning as the last field of our scalar TBAA:
// it's an integer which if equal to 1 indicates that the access is "constant".
//
// The struct type node has a name and a list of pairs, one pair for each member
// of the struct. The first element of each pair is a type node (a struct type
// node or a sclar type node), specifying the type of the member, the second
// element of each pair is the offset of the member.
//
// Given an example
// typedef struct {
// short s;
// } A;
// typedef struct {
// uint16_t s;
// A a;
// } B;
//
// For an acess to B.a.s, we attach !5 (a path tag node) to the load/store
// instruction. The base type is !4 (struct B), the access type is !2 (scalar
// type short) and the offset is 4.
//
// !0 = metadata !{metadata !"Simple C/C++ TBAA"}
// !1 = metadata !{metadata !"omnipotent char", metadata !0} // Scalar type node
// !2 = metadata !{metadata !"short", metadata !1} // Scalar type node
// !3 = metadata !{metadata !"A", metadata !2, i64 0} // Struct type node
// !4 = metadata !{metadata !"B", metadata !2, i64 0, metadata !3, i64 4}
// // Struct type node
// !5 = metadata !{metadata !4, metadata !2, i64 4} // Path tag node
//
// The struct type nodes and the scalar type nodes form a type DAG.
// Root (!0)
// char (!1) -- edge to Root
// short (!2) -- edge to char
// A (!3) -- edge with offset 0 to short
// B (!4) -- edge with offset 0 to short and edge with offset 4 to A
//
// To check if two tags (tagX and tagY) can alias, we start from the base type
// of tagX, follow the edge with the correct offset in the type DAG and adjust
// the offset until we reach the base type of tagY or until we reach the Root
// node.
// If we reach the base type of tagY, compare the adjusted offset with
// offset of tagY, return Alias if the offsets are the same, return NoAlias
// otherwise.
// If we reach the Root node, perform the above starting from base type of tagY
// to see if we reach base type of tagX.
//
// If they have different roots, they're part of different potentially
// unrelated type systems, so we return Alias to be conservative.
// If neither node is an ancestor of the other and they have the same root,
// then we say NoAlias.
//
// TODO: The current metadata format doesn't support struct
// fields. For example:
// struct X {
@ -71,7 +135,6 @@ using namespace llvm;
// achieved by stripping the !tbaa tags from IR, but this option is sometimes
// more convenient.
static cl::opt<bool> EnableTBAA("enable-tbaa", cl::init(true));
static cl::opt<bool> EnableStructPathTBAA("struct-path-tbaa", cl::init(false));
namespace {
/// TBAANode - This is a simple wrapper around an MDNode which provides a
@ -259,12 +322,19 @@ TypeBasedAliasAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
AliasAnalysis::getAnalysisUsage(AU);
}
/// 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.
static bool isStructPathTBAA(const MDNode *MD) {
return isa<MDNode>(MD->getOperand(0));
}
/// Aliases - Test whether the type represented by A may alias the
/// type represented by B.
bool
TypeBasedAliasAnalysis::Aliases(const MDNode *A,
const MDNode *B) const {
if (EnableStructPathTBAA)
if (isStructPathTBAA(A))
return PathAliases(A, B);
// Keep track of the root node for A and B.
@ -397,8 +467,8 @@ bool TypeBasedAliasAnalysis::pointsToConstantMemory(const Location &Loc,
// If this is an "immutable" type, we can assume the pointer is pointing
// to constant memory.
if ((!EnableStructPathTBAA && TBAANode(M).TypeIsImmutable()) ||
(EnableStructPathTBAA && TBAAStructTagNode(M).TypeIsImmutable()))
if ((!isStructPathTBAA(M) && TBAANode(M).TypeIsImmutable()) ||
(isStructPathTBAA(M) && TBAAStructTagNode(M).TypeIsImmutable()))
return true;
return AliasAnalysis::pointsToConstantMemory(Loc, OrLocal);
@ -414,8 +484,8 @@ TypeBasedAliasAnalysis::getModRefBehavior(ImmutableCallSite CS) {
// If this is an "immutable" type, we can assume the call doesn't write
// to memory.
if (const MDNode *M = CS.getInstruction()->getMetadata(LLVMContext::MD_tbaa))
if ((!EnableStructPathTBAA && TBAANode(M).TypeIsImmutable()) ||
(EnableStructPathTBAA && TBAAStructTagNode(M).TypeIsImmutable()))
if ((!isStructPathTBAA(M) && TBAANode(M).TypeIsImmutable()) ||
(isStructPathTBAA(M) && TBAAStructTagNode(M).TypeIsImmutable()))
Min = OnlyReadsMemory;
return ModRefBehavior(AliasAnalysis::getModRefBehavior(CS) & Min);
@ -459,7 +529,7 @@ TypeBasedAliasAnalysis::getModRefInfo(ImmutableCallSite CS1,
}
bool MDNode::isTBAAVtableAccess() const {
if (!EnableStructPathTBAA) {
if (!isStructPathTBAA(this)) {
if (getNumOperands() < 1) return false;
if (MDString *Tag1 = dyn_cast<MDString>(getOperand(0))) {
if (Tag1->getString() == "vtable pointer") return true;
@ -485,7 +555,8 @@ MDNode *MDNode::getMostGenericTBAA(MDNode *A, MDNode *B) {
return A;
// For struct-path aware TBAA, we use the access type of the tag.
if (EnableStructPathTBAA) {
bool StructPath = isStructPathTBAA(A);
if (StructPath) {
A = cast_or_null<MDNode>(A->getOperand(1));
if (!A) return 0;
B = cast_or_null<MDNode>(B->getOperand(1));
@ -518,7 +589,7 @@ MDNode *MDNode::getMostGenericTBAA(MDNode *A, MDNode *B) {
--IA;
--IB;
}
if (!EnableStructPathTBAA)
if (!StructPath)
return Ret;
if (!Ret)

View File

@ -29,7 +29,9 @@ entry:
ret i32 %tmp5.lobit
}
!0 = metadata !{metadata !"double", metadata !1}
!0 = metadata !{metadata !4, metadata !4, i64 0}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
!3 = metadata !{metadata !"int", metadata !1}
!3 = metadata !{metadata !5, metadata !5, i64 0}
!4 = metadata !{metadata !"double", metadata !1}
!5 = metadata !{metadata !"int", metadata !1}

View File

@ -47,16 +47,21 @@ define i8 @test1_no(i8* %a, i8* %b) nounwind {
; Root note.
!0 = metadata !{ }
; Some type.
!1 = metadata !{ metadata !"foo", metadata !0 }
!1 = metadata !{metadata !7, metadata !7, i64 0}
; Some other non-aliasing type.
!2 = metadata !{ metadata !"bar", metadata !0 }
!2 = metadata !{metadata !8, metadata !8, i64 0}
; Some type.
!3 = metadata !{ metadata !"foo", metadata !0 }
!3 = metadata !{metadata !9, metadata !9, i64 0}
; Some type in a different type system.
!4 = metadata !{ metadata !"bar", metadata !"different" }
!4 = metadata !{metadata !10, metadata !10, i64 0}
; Invariant memory.
!5 = metadata !{ metadata !"qux", metadata !0, i1 1 }
!5 = metadata !{metadata !11, metadata !11, i64 0, i1 1}
; Not invariant memory.
!6 = metadata !{ metadata !"qux", metadata !0, i1 0 }
!6 = metadata !{metadata !11, metadata !11, i64 0, i1 0}
!7 = metadata !{ metadata !"foo", metadata !0 }
!8 = metadata !{ metadata !"bar", metadata !0 }
!9 = metadata !{ metadata !"foo", metadata !0 }
!10 = metadata !{ metadata !"bar", metadata !"different" }
!11 = metadata !{ metadata !"qux", metadata !0}

View File

@ -33,5 +33,7 @@ define i32 @callercaller(i32* %Q) {
}
!0 = metadata !{metadata !"test"}
!1 = metadata !{metadata !"green", metadata !0}
!2 = metadata !{metadata !"blue", metadata !0}
!1 = metadata !{metadata !3, metadata !3, i64 0}
!2 = metadata !{metadata !4, metadata !4, i64 0}
!3 = metadata !{metadata !"green", metadata !0}
!4 = metadata !{metadata !"blue", metadata !0}

View File

@ -51,16 +51,21 @@ define i8 @test1_no(i8* %a, i8* %b) nounwind {
; Root note.
!0 = metadata !{ }
; Some type.
!1 = metadata !{ metadata !"foo", metadata !0 }
!1 = metadata !{metadata !7, metadata !7, i64 0}
; Some other non-aliasing type.
!2 = metadata !{ metadata !"bar", metadata !0 }
!2 = metadata !{metadata !8, metadata !8, i64 0}
; Some type.
!3 = metadata !{ metadata !"foo", metadata !0 }
!3 = metadata !{metadata !9, metadata !9, i64 0}
; Some type in a different type system.
!4 = metadata !{ metadata !"bar", metadata !"different" }
!4 = metadata !{metadata !10, metadata !10, i64 0}
; Invariant memory.
!5 = metadata !{ metadata !"qux", metadata !0, i1 1 }
!5 = metadata !{metadata !11, metadata !11, i64 0, i1 1}
; Not invariant memory.
!6 = metadata !{ metadata !"qux", metadata !0, i1 0 }
!6 = metadata !{metadata !11, metadata !11, i64 0, i1 0}
!7 = metadata !{ metadata !"foo", metadata !0 }
!8 = metadata !{ metadata !"bar", metadata !0 }
!9 = metadata !{ metadata !"foo", metadata !0 }
!10 = metadata !{ metadata !"bar", metadata !"different" }
!11 = metadata !{ metadata !"qux", metadata !0}

View File

@ -13,7 +13,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
; CHECK: for.end:
; CHECK: %arrayidx31 = getelementptr inbounds %union.vector_t* %t, i64 0, i32 0, i64 1
; CHECK: %tmp32 = load i64* %arrayidx31, align 8, !tbaa !3
; CHECK: %tmp32 = load i64* %arrayidx31, align 8, !tbaa [[TAG:!.*]]
define void @vrlh(%union.vector_t* %va, %union.vector_t* %vb, %union.vector_t* %vd) nounwind {
entry:
@ -123,9 +123,15 @@ for.end: ; preds = %for.body
ret float %tmp10
}
!0 = metadata !{metadata !"short", metadata !1}
; CHECK: [[TAG]] = metadata !{metadata [[TYPE_LL:!.*]], metadata [[TYPE_LL]], i64 0}
; CHECK: [[TYPE_LL]] = metadata !{metadata !"long long", metadata {{!.*}}}
!0 = metadata !{metadata !6, metadata !6, i64 0}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
!3 = metadata !{metadata !"long long", metadata !1}
!4 = metadata !{metadata !"int", metadata !1}
!5 = metadata !{metadata !"float", metadata !1}
!3 = metadata !{metadata !7, metadata !7, i64 0}
!4 = metadata !{metadata !8, metadata !8, i64 0}
!5 = metadata !{metadata !9, metadata !9, i64 0}
!6 = metadata !{metadata !"short", metadata !1}
!7 = metadata !{metadata !"long long", metadata !1}
!8 = metadata !{metadata !"int", metadata !1}
!9 = metadata !{metadata !"float", metadata !1}

View File

@ -80,6 +80,7 @@ declare void @llvm.memcpy.p0i8.p0i8.i64(i8*, i8*, i64, i32, i1) nounwind
!0 = metadata !{ }
; Invariant memory.
!1 = metadata !{ metadata !"foo", metadata !0, i1 1 }
!1 = metadata !{metadata !3, metadata !3, i64 0, i1 1 }
; Not invariant memory.
!2 = metadata !{ metadata !"foo", metadata !0, i1 0 }
!2 = metadata !{metadata !3, metadata !3, i64 0, i1 0 }
!3 = metadata !{ metadata !"foo", metadata !0 }

View File

@ -85,7 +85,11 @@ if.else:
}
!0 = metadata !{}
!1 = metadata !{metadata !"red", metadata !0}
!2 = metadata !{metadata !"blu", metadata !0}
!3 = metadata !{metadata !"outer space"}
!4 = metadata !{metadata !"brick red", metadata !1}
!1 = metadata !{metadata !5, metadata !5, i64 0}
!2 = metadata !{metadata !6, metadata !6, i64 0}
!3 = metadata !{metadata !7, metadata !7, i64 0}
!4 = metadata !{metadata !8, metadata !8, i64 0}
!5 = metadata !{metadata !"red", metadata !0}
!6 = metadata !{metadata !"blu", metadata !0}
!7 = metadata !{metadata !"outer space"}
!8 = metadata !{metadata !"brick red", metadata !5}

View File

@ -26,5 +26,7 @@ declare void @llvm.arm.neon.vst1.v8i16(i8*, <8 x i16>, i32) nounwind
; CHECK: attributes [[NUW]] = { nounwind }
!0 = metadata !{metadata !"tbaa root", null}
!1 = metadata !{metadata !"A", metadata !0}
!2 = metadata !{metadata !"B", metadata !0}
!1 = metadata !{metadata !3, metadata !3, i64 0}
!2 = metadata !{metadata !4, metadata !4, i64 0}
!3 = metadata !{metadata !"A", metadata !0}
!4 = metadata !{metadata !"B", metadata !0}

View File

@ -30,8 +30,8 @@ for.end: ; preds = %for.body, %entry
}
!0 = metadata !{metadata !"root", null}
!1 = metadata !{metadata !"pointer", metadata !0}
!2 = metadata !{metadata !"double", metadata !0}
!1 = metadata !{metadata !6, metadata !6, i64 0}
!2 = metadata !{metadata !7, metadata !7, i64 0}
; LICM shouldn't hoist anything here.
@ -56,6 +56,10 @@ loop:
br label %loop
}
!3 = metadata !{metadata !"pointer", metadata !4}
!4 = metadata !{metadata !"char", metadata !5}
!5 = metadata !{metadata !"root", null}
!3 = metadata !{metadata !"pointer", metadata !8}
!4 = metadata !{metadata !8, metadata !8, i64 0}
!5 = metadata !{metadata !9, metadata !9, i64 0}
!6 = metadata !{metadata !"pointer", metadata !0}
!7 = metadata !{metadata !"double", metadata !0}
!8 = metadata !{metadata !"char", metadata !9}
!9 = metadata !{metadata !"root", null}

View File

@ -7,7 +7,7 @@ target datalayout = "e-p:64:64:64"
; CHECK: @foo
; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p, i8* %q, i64 16, i32 1, i1 false), !tbaa !0
; CHECK-NEXT: store i8 2, i8* %s, align 1, !tbaa !2
; CHECK-NEXT: store i8 2, i8* %s, align 1, !tbaa [[TAGA:!.*]]
; CHECK-NEXT: ret void
define void @foo(i8* nocapture %p, i8* nocapture %q, i8* nocapture %s) nounwind {
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p, i8* %q, i64 16, i32 1, i1 false), !tbaa !2
@ -18,6 +18,10 @@ define void @foo(i8* nocapture %p, i8* nocapture %q, i8* nocapture %s) nounwind
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
; CHECK [[TAGA]] = metadata !{metadata [[TYPEA:!.*]], metadata [[TYPEA]], i64 0}
; CHECK [[TYPEA]] = metadata !{metadata !"A", metadata !{{.*}}}
!0 = metadata !{metadata !"tbaa root", null}
!1 = metadata !{metadata !"A", metadata !0}
!2 = metadata !{metadata !"B", metadata !0}
!1 = metadata !{metadata !3, metadata !3, i64 0}
!2 = metadata !{metadata !4, metadata !4, i64 0}
!3 = metadata !{metadata !"A", metadata !0}
!4 = metadata !{metadata !"B", metadata !0}

View File

@ -18,7 +18,7 @@
; Basic AA says MayAlias, TBAA says NoAlias
; CHECK: MayAlias: i64* %i5, i8** %p
; CHECK: NoAlias: store i64 %conv, i64* %i5, align 8, !tbaa !4 <-> store i8* null, i8** %p, align 8, !tbaa !3
; CHECK: NoAlias: store i64 %conv, i64* %i5, align 8, !tbaa !6 <-> store i8* null, i8** %p, align 8, !tbaa !9
%struct.Foo = type { i64 }
%struct.Bar = type { i8* }
@ -32,10 +32,10 @@ entry:
store i32 %n, i32* %n.addr, align 4, !tbaa !0
%call = call noalias i8* @_Znwm(i64 8)
%0 = bitcast i8* %call to %struct.Foo*
store %struct.Foo* %0, %struct.Foo** %f, align 8, !tbaa !3
%1 = load %struct.Foo** %f, align 8, !tbaa !3
store %struct.Foo* %0, %struct.Foo** %f, align 8, !tbaa !4
%1 = load %struct.Foo** %f, align 8, !tbaa !4
%i = getelementptr inbounds %struct.Foo* %1, i32 0, i32 0
store i64 1, i64* %i, align 8, !tbaa !4
store i64 1, i64* %i, align 8, !tbaa !6
store i32 0, i32* %i1, align 4, !tbaa !0
br label %for.cond
@ -46,7 +46,7 @@ for.cond:
br i1 %cmp, label %for.body, label %for.end
for.body:
%4 = load %struct.Foo** %f, align 8, !tbaa !3
%4 = load %struct.Foo** %f, align 8, !tbaa !4
%5 = bitcast %struct.Foo* %4 to i8*
%new.isnull = icmp eq i8* %5, null
br i1 %new.isnull, label %new.cont, label %new.notnull
@ -57,11 +57,11 @@ new.notnull:
new.cont:
%7 = phi %struct.Bar* [ %6, %new.notnull ], [ null, %for.body ]
store %struct.Bar* %7, %struct.Bar** %b, align 8, !tbaa !3
%8 = load %struct.Bar** %b, align 8, !tbaa !3
store %struct.Bar* %7, %struct.Bar** %b, align 8, !tbaa !4
%8 = load %struct.Bar** %b, align 8, !tbaa !4
%p = getelementptr inbounds %struct.Bar* %8, i32 0, i32 0
store i8* null, i8** %p, align 8, !tbaa !3
%9 = load %struct.Foo** %f, align 8, !tbaa !3
store i8* null, i8** %p, align 8, !tbaa !9
%9 = load %struct.Foo** %f, align 8, !tbaa !4
%10 = bitcast %struct.Foo* %9 to i8*
%new.isnull2 = icmp eq i8* %10, null
br i1 %new.isnull2, label %new.cont4, label %new.notnull3
@ -72,12 +72,12 @@ new.notnull3:
new.cont4:
%12 = phi %struct.Foo* [ %11, %new.notnull3 ], [ null, %new.cont ]
store %struct.Foo* %12, %struct.Foo** %f, align 8, !tbaa !3
store %struct.Foo* %12, %struct.Foo** %f, align 8, !tbaa !4
%13 = load i32* %i1, align 4, !tbaa !0
%conv = sext i32 %13 to i64
%14 = load %struct.Foo** %f, align 8, !tbaa !3
%14 = load %struct.Foo** %f, align 8, !tbaa !4
%i5 = getelementptr inbounds %struct.Foo* %14, i32 0, i32 0
store i64 %conv, i64* %i5, align 8, !tbaa !4
store i64 %conv, i64* %i5, align 8, !tbaa !6
br label %for.inc
for.inc:
@ -87,9 +87,9 @@ for.inc:
br label %for.cond
for.end:
%16 = load %struct.Foo** %f, align 8, !tbaa !3
%16 = load %struct.Foo** %f, align 8, !tbaa !4
%i6 = getelementptr inbounds %struct.Foo* %16, i32 0, i32 0
%17 = load i64* %i6, align 8, !tbaa !4
%17 = load i64* %i6, align 8, !tbaa !6
ret i64 %17
}
@ -97,8 +97,14 @@ declare noalias i8* @_Znwm(i64)
attributes #0 = { nounwind }
!0 = metadata !{metadata !"int", metadata !1}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA"}
!3 = metadata !{metadata !"any pointer", metadata !1}
!4 = metadata !{metadata !"long", metadata !1}
!0 = metadata !{metadata !1, metadata !1, i64 0}
!1 = metadata !{metadata !"int", metadata !2, i64 0}
!2 = metadata !{metadata !"omnipotent char", metadata !3, i64 0}
!3 = metadata !{metadata !"Simple C/C++ TBAA"}
!4 = metadata !{metadata !5, metadata !5, i64 0}
!5 = metadata !{metadata !"any pointer", metadata !2, i64 0}
!6 = metadata !{metadata !7, metadata !8, i64 0}
!7 = metadata !{metadata !"_ZTS3Foo", metadata !8, i64 0}
!8 = metadata !{metadata !"long", metadata !2, i64 0}
!9 = metadata !{metadata !10, metadata !5, i64 0}
!10 = metadata !{metadata !"_ZTS3Bar", metadata !5, i64 0}

View File

@ -39,8 +39,12 @@ entry:
ret i64 %tmp3
}
!0 = metadata !{metadata !"int", metadata !1}
!0 = metadata !{metadata !2, metadata !2, i64 0}
!1 = metadata !{metadata !"simple"}
!3 = metadata !{metadata !"float", metadata !1}
!4 = metadata !{metadata !"long", metadata !1}
!5 = metadata !{metadata !"small", metadata !1}
!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}

View File

@ -1,7 +1,7 @@
; RUN: opt -tbaa -sink -S < %s | FileCheck %s
; CHECK: a:
; CHECK: %f = load float* %p, !tbaa !2
; CHECK: %f = load float* %p, !tbaa [[TAGA:!.*]]
; CHECK: store float %f, float* %q
define void @foo(float* %p, i1 %c, float* %q, float* %r) {
@ -15,6 +15,10 @@ b:
ret void
}
!0 = metadata !{metadata !"A", metadata !2}
!1 = metadata !{metadata !"B", metadata !2}
; CHECK: [[TAGA]] = metadata !{metadata [[TYPEA:!.*]], metadata [[TYPEA]], i64 0}
; CHECK: [[TYPEA]] = metadata !{metadata !"A", metadata !{{.*}}}
!0 = metadata !{metadata !3, metadata !3, i64 0}
!1 = metadata !{metadata !4, metadata !4, i64 0}
!2 = metadata !{metadata !"test"}
!3 = metadata !{metadata !"A", metadata !2}
!4 = metadata !{metadata !"B", metadata !2}

View File

@ -1,5 +1,5 @@
; RUN: opt < %s -tbaa -basicaa -struct-path-tbaa -aa-eval -evaluate-tbaa -print-no-aliases -print-may-aliases -disable-output 2>&1 | FileCheck %s
; RUN: opt < %s -tbaa -basicaa -struct-path-tbaa -gvn -S | FileCheck %s --check-prefix=OPT
; RUN: opt < %s -tbaa -basicaa -aa-eval -evaluate-tbaa -print-no-aliases -print-may-aliases -disable-output 2>&1 | FileCheck %s
; RUN: opt < %s -tbaa -basicaa -gvn -S | FileCheck %s --check-prefix=OPT
; Generated from clang/test/CodeGen/tbaa.cpp with "-O1 -struct-path-tbaa -disable-llvm-optzns".
%struct.StructA = type { i16, i32, i16, i32 }

View File

@ -386,5 +386,7 @@ define void @f32(i64 *%ptr1, i64 *%ptr2) {
}
!0 = metadata !{ metadata !"root" }
!1 = metadata !{ metadata !"set1", metadata !0 }
!2 = metadata !{ metadata !"set2", metadata !0 }
!1 = metadata !{ metadata !3, metadata !3, i64 0 }
!2 = metadata !{ metadata !4, metadata !4, i64 0 }
!3 = metadata !{ metadata !"set1", metadata !0 }
!4 = metadata !{ metadata !"set2", metadata !0 }

View File

@ -64,8 +64,10 @@ entry:
ret void
}
!0 = metadata !{metadata !"any pointer", metadata !1}
!0 = metadata !{metadata !5, metadata !5, i64 0}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
!3 = metadata !{metadata !"int", metadata !1}
!3 = metadata !{metadata !6, metadata !6, i64 0}
!4 = metadata !{i32 156132, i32 156164, i32 156205, i32 156238, i32 156282, i32 156332, i32 156370, i32 156408, i32 156447, i32 156486, i32 156536, i32 156574, i32 156612, i32 156651, i32 156690, i32 156740, i32 156778, i32 156816, i32 156855, i32 156894, i32 156944, i32 156982, i32 157020, i32 157059, i32 157098, i32 157148, i32 157186, i32 157224, i32 157263, i32 157302, i32 157352, i32 157390, i32 157428, i32 157467, i32 157506, i32 157556, i32 157594, i32 157632, i32 157671, i32 157710, i32 157760, i32 157798, i32 157836, i32 157875, i32 157914, i32 157952, i32 157996, i32 158046, i32 158099, i32 158140, i32 158179, i32 158218, i32 158268, i32 158321, i32 158362, i32 158401, i32 158440, i32 158490, i32 158543, i32 158584, i32 158623, i32 158662, i32 158712, i32 158765, i32 158806, i32 158845, i32 158884, i32 158922, i32 158963, i32 158996, i32 159029, i32 159062, i32 159109, i32 159154, i32 159199, i32 159243, i32 159286, i32 159329, i32 159375, i32 159422, i32 159478, i32 159522, i32 159566}
!5 = metadata !{metadata !"any pointer", metadata !1}
!6 = metadata !{metadata !"int", metadata !1}

View File

@ -41,7 +41,7 @@ entry:
define void @call_virtual_func(%struct.Foo* %f) uwtable {
entry:
%0 = bitcast %struct.Foo* %f to void (%struct.Foo*)***
%vtable = load void (%struct.Foo*)*** %0, align 8, !tbaa !3
%vtable = load void (%struct.Foo*)*** %0, align 8, !tbaa !2
%1 = load void (%struct.Foo*)** %vtable, align 8
call void %1(%struct.Foo* %f)
ret void
@ -54,8 +54,6 @@ entry:
; CHECK: = load
; CHECK: ret void
!0 = metadata !{metadata !"int", metadata !1}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
!3 = metadata !{metadata !"vtable pointer", metadata !2}
!0 = metadata !{metadata !"Simple C/C++ TBAA", null}
!1 = metadata !{metadata !"vtable pointer", metadata !0}
!2 = metadata !{metadata !1, metadata !1, i64 0}

View File

@ -8,6 +8,6 @@ entry:
%0 = load i8* %a, align 8, !tbaa !0
ret i8 %0
}
!0 = metadata !{metadata !"vtable pointer", metadata !1}
!0 = metadata !{metadata !2, metadata !2, i64 0}
!1 = metadata !{metadata !"Simple C/C++ TBAA", null}
!2 = metadata !{metadata !"vtable pointer", metadata !1}

View File

@ -8,6 +8,6 @@ entry:
store i8* %b, i8** %a, align 8, !tbaa !0
ret void
}
!0 = metadata !{metadata !"vtable pointer", metadata !1}
!0 = metadata !{metadata !2, metadata !2, i64 0}
!1 = metadata !{metadata !"Simple C/C++ TBAA", null}
!2 = metadata !{metadata !"vtable pointer", metadata !1}

View File

@ -25,6 +25,7 @@ for.end: ; preds = %for.body, %entry
ret void
}
!0 = metadata !{metadata !"short", metadata !1}
!0 = metadata !{metadata !3, metadata !3, i64 0}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
!3 = metadata !{metadata !"short", metadata !1}

View File

@ -13,7 +13,7 @@ define i32 @test1(i8* %p, i8* %q) {
define i32 @test2(i8* %p, i8* %q) {
; CHECK: @test2(i8* %p, i8* %q)
; CHECK: call i32 @foo(i8* %p), !tbaa !0
; CHECK: call i32 @foo(i8* %p), !tbaa [[TAGC:!.*]]
; CHECK: %c = add i32 %a, %a
%a = call i32 @foo(i8* %p), !tbaa !0
%b = call i32 @foo(i8* %p), !tbaa !0
@ -23,7 +23,7 @@ define i32 @test2(i8* %p, i8* %q) {
define i32 @test3(i8* %p, i8* %q) {
; CHECK: @test3(i8* %p, i8* %q)
; CHECK: call i32 @foo(i8* %p), !tbaa !3
; CHECK: call i32 @foo(i8* %p), !tbaa [[TAGB:!.*]]
; CHECK: %c = add i32 %a, %a
%a = call i32 @foo(i8* %p), !tbaa !3
%b = call i32 @foo(i8* %p), !tbaa !3
@ -33,7 +33,7 @@ define i32 @test3(i8* %p, i8* %q) {
define i32 @test4(i8* %p, i8* %q) {
; CHECK: @test4(i8* %p, i8* %q)
; CHECK: call i32 @foo(i8* %p), !tbaa !1
; CHECK: call i32 @foo(i8* %p), !tbaa [[TAGA:!.*]]
; CHECK: %c = add i32 %a, %a
%a = call i32 @foo(i8* %p), !tbaa !1
%b = call i32 @foo(i8* %p), !tbaa !0
@ -43,7 +43,7 @@ define i32 @test4(i8* %p, i8* %q) {
define i32 @test5(i8* %p, i8* %q) {
; CHECK: @test5(i8* %p, i8* %q)
; CHECK: call i32 @foo(i8* %p), !tbaa !1
; CHECK: call i32 @foo(i8* %p), !tbaa [[TAGA:!.*]]
; CHECK: %c = add i32 %a, %a
%a = call i32 @foo(i8* %p), !tbaa !0
%b = call i32 @foo(i8* %p), !tbaa !1
@ -53,7 +53,7 @@ define i32 @test5(i8* %p, i8* %q) {
define i32 @test6(i8* %p, i8* %q) {
; CHECK: @test6(i8* %p, i8* %q)
; CHECK: call i32 @foo(i8* %p), !tbaa !1
; CHECK: call i32 @foo(i8* %p), !tbaa [[TAGA:!.*]]
; CHECK: %c = add i32 %a, %a
%a = call i32 @foo(i8* %p), !tbaa !0
%b = call i32 @foo(i8* %p), !tbaa !3
@ -74,8 +74,18 @@ define i32 @test7(i8* %p, i8* %q) {
declare i32 @foo(i8*) readonly
!0 = metadata !{metadata !"C", metadata !1}
!1 = metadata !{metadata !"A", metadata !2}
; 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 !"B", metadata !1}
!4 = metadata !{metadata !"another 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}

View File

@ -113,7 +113,8 @@ for.end: ; preds = %for.cond
; CHECK-NEXT: store i32 %storemerge, i32* %gi, align 4, !tbaa !0
}
!0 = metadata !{metadata !"int", metadata !1}
!0 = metadata !{metadata !4, metadata !4, i64 0}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA"}
!3 = metadata !{metadata !"float", metadata !1}
!4 = metadata !{metadata !"int", metadata !1}

View File

@ -35,10 +35,12 @@ define i32 (i8*, i32*, double*)*** @test2() {
ret i32 (i8*, i32*, double*)*** %tmp2
}
; CHECK: !0 = metadata !{metadata !"float", metadata !1}
; CHECK: !0 = metadata !{metadata !1, metadata !1, i64 0}
; CHECK: !1 = metadata !{metadata !"float", metadata !2}
!0 = metadata !{metadata !"Simple C/C++ TBAA"}
!1 = metadata !{metadata !"omnipotent char", metadata !0}
!2 = metadata !{metadata !"float", metadata !0}
!2 = metadata !{metadata !5, metadata !5, i64 0}
!3 = metadata !{i64 0, i64 4, metadata !2}
!4 = metadata !{i64 0, i64 8, null}
!5 = metadata !{metadata !"float", metadata !0}

View File

@ -75,7 +75,7 @@ bb3: ; preds = %bb1
ret i32 %res.0
}
!0 = metadata !{metadata !"int", metadata !1}
!0 = metadata !{metadata !3, metadata !3, i64 0}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
!3 = metadata !{metadata !"int", metadata !1}

View File

@ -30,8 +30,10 @@ for.end: ; preds = %for.inc
ret void
}
!0 = metadata !{metadata !"any pointer", metadata !1}
!0 = metadata !{metadata !5, metadata !5, i64 0}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
!3 = metadata !{metadata !"short", metadata !1}
!4 = metadata !{metadata !"int", metadata !1}
!4 = metadata !{metadata !6, metadata !6, i64 0}
!5 = metadata !{metadata !"any pointer", metadata !1}
!6 = metadata !{metadata !"int", metadata !1}

View File

@ -37,5 +37,7 @@ for.end: ; preds = %for.cond.for.end_cr
}
!0 = metadata !{metadata !"minimal TBAA"}
!1 = metadata !{metadata !"float", metadata !0}
!2 = metadata !{metadata !"int", metadata !0}
!1 = metadata !{metadata !3, metadata !3, i64 0}
!2 = metadata !{metadata !4, metadata !4, i64 0}
!3 = metadata !{metadata !"float", metadata !0}
!4 = metadata !{metadata !"int", metadata !0}

View File

@ -181,7 +181,9 @@ for.end: ; preds = %for.cond.for.end_cr
; CHECK-NEXT: store i32 %inc, i32* %gi, align 4, !tbaa !0
}
!0 = metadata !{metadata !"int", metadata !1}
!0 = metadata !{metadata !4, metadata !4, i64 0}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA"}
!3 = metadata !{metadata !"float", metadata !1}
!3 = metadata !{metadata !5, metadata !5, i64 0}
!4 = metadata !{metadata !"int", metadata !1}
!5 = metadata !{metadata !"float", metadata !1}