1 //===- TypeBasedAliasAnalysis.cpp - Type-Based Alias Analysis -------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the TypeBasedAliasAnalysis pass, which implements
11 // metadata-based TBAA.
13 // In LLVM IR, memory does not have types, so LLVM's own type system is not
14 // suitable for doing TBAA. Instead, metadata is added to the IR to describe
15 // a type system of a higher level language. This can be used to implement
16 // typical C/C++ TBAA, but it can also be used to implement custom alias
17 // analysis behavior for other languages.
19 // We now support two types of metadata format: scalar TBAA and struct-path
20 // aware TBAA. After all testing cases are upgraded to use struct-path aware
21 // TBAA and we can auto-upgrade existing bc files, the support for scalar TBAA
24 // The scalar TBAA metadata format is very simple. TBAA MDNodes have up to
25 // three fields, e.g.:
26 // !0 = !{ !"an example type tree" }
27 // !1 = !{ !"int", !0 }
28 // !2 = !{ !"float", !0 }
29 // !3 = !{ !"const float", !2, i64 1 }
31 // The first field is an identity field. It can be any value, usually
32 // an MDString, which uniquely identifies the type. The most important
33 // name in the tree is the name of the root node. Two trees with
34 // different root node names are entirely disjoint, even if they
35 // have leaves with common names.
37 // The second field identifies the type's parent node in the tree, or
38 // is null or omitted for a root node. A type is considered to alias
39 // all of its descendants and all of its ancestors in the tree. Also,
40 // a type is considered to alias all types in other trees, so that
41 // bitcode produced from multiple front-ends is handled conservatively.
43 // If the third field is present, it's an integer which if equal to 1
44 // indicates that the type is "constant" (meaning pointsToConstantMemory
45 // should return true; see
46 // http://llvm.org/docs/AliasAnalysis.html#OtherItfs).
48 // With struct-path aware TBAA, the MDNodes attached to an instruction using
49 // "!tbaa" are called path tag nodes.
51 // The path tag node has 4 fields with the last field being optional.
53 // The first field is the base type node, it can be a struct type node
54 // or a scalar type node. The second field is the access type node, it
55 // must be a scalar type node. The third field is the offset into the base type.
56 // The last field has the same meaning as the last field of our scalar TBAA:
57 // it's an integer which if equal to 1 indicates that the access is "constant".
59 // The struct type node has a name and a list of pairs, one pair for each member
60 // of the struct. The first element of each pair is a type node (a struct type
61 // node or a scalar type node), specifying the type of the member, the second
62 // element of each pair is the offset of the member.
73 // For an access to B.a.s, we attach !5 (a path tag node) to the load/store
74 // instruction. The base type is !4 (struct B), the access type is !2 (scalar
75 // type short) and the offset is 4.
77 // !0 = !{!"Simple C/C++ TBAA"}
78 // !1 = !{!"omnipotent char", !0} // Scalar type node
79 // !2 = !{!"short", !1} // Scalar type node
80 // !3 = !{!"A", !2, i64 0} // Struct type node
81 // !4 = !{!"B", !2, i64 0, !3, i64 4}
82 // // Struct type node
83 // !5 = !{!4, !2, i64 4} // Path tag node
85 // The struct type nodes and the scalar type nodes form a type DAG.
87 // char (!1) -- edge to Root
88 // short (!2) -- edge to char
89 // A (!3) -- edge with offset 0 to short
90 // B (!4) -- edge with offset 0 to short and edge with offset 4 to A
92 // To check if two tags (tagX and tagY) can alias, we start from the base type
93 // of tagX, follow the edge with the correct offset in the type DAG and adjust
94 // the offset until we reach the base type of tagY or until we reach the Root
96 // If we reach the base type of tagY, compare the adjusted offset with
97 // offset of tagY, return Alias if the offsets are the same, return NoAlias
99 // If we reach the Root node, perform the above starting from base type of tagY
100 // to see if we reach base type of tagX.
102 // If they have different roots, they're part of different potentially
103 // unrelated type systems, so we return Alias to be conservative.
104 // If neither node is an ancestor of the other and they have the same root,
105 // then we say NoAlias.
107 //===----------------------------------------------------------------------===//
109 #include "llvm/Analysis/TypeBasedAliasAnalysis.h"
110 #include "llvm/ADT/SetVector.h"
111 #include "llvm/Analysis/AliasAnalysis.h"
112 #include "llvm/Analysis/MemoryLocation.h"
113 #include "llvm/IR/Constants.h"
114 #include "llvm/IR/DerivedTypes.h"
115 #include "llvm/IR/Instruction.h"
116 #include "llvm/IR/LLVMContext.h"
117 #include "llvm/IR/Metadata.h"
118 #include "llvm/Pass.h"
119 #include "llvm/Support/Casting.h"
120 #include "llvm/Support/CommandLine.h"
121 #include "llvm/Support/ErrorHandling.h"
125 using namespace llvm;
127 // A handy option for disabling TBAA functionality. The same effect can also be
128 // achieved by stripping the !tbaa tags from IR, but this option is sometimes
130 static cl::opt<bool> EnableTBAA("enable-tbaa", cl::init(true), cl::Hidden);
134 /// isNewFormatTypeNode - Return true iff the given type node is in the new
135 /// size-aware format.
136 static bool isNewFormatTypeNode(const MDNode *N) {
137 if (N->getNumOperands() < 3)
139 // In the old format the first operand is a string.
140 if (!isa<MDNode>(N->getOperand(0)))
145 /// This is a simple wrapper around an MDNode which provides a higher-level
146 /// interface by hiding the details of how alias analysis information is encoded
148 template<typename MDNodeTy>
150 MDNodeTy *Node = nullptr;
153 TBAANodeImpl() = default;
154 explicit TBAANodeImpl(MDNodeTy *N) : Node(N) {}
156 /// getNode - Get the MDNode for this TBAANode.
157 MDNodeTy *getNode() const { return Node; }
159 /// isNewFormat - Return true iff the wrapped type node is in the new
160 /// size-aware format.
161 bool isNewFormat() const { return isNewFormatTypeNode(Node); }
163 /// getParent - Get this TBAANode's Alias tree parent.
164 TBAANodeImpl<MDNodeTy> getParent() const {
166 return TBAANodeImpl(cast<MDNodeTy>(Node->getOperand(0)));
168 if (Node->getNumOperands() < 2)
169 return TBAANodeImpl<MDNodeTy>();
170 MDNodeTy *P = dyn_cast_or_null<MDNodeTy>(Node->getOperand(1));
172 return TBAANodeImpl<MDNodeTy>();
173 // Ok, this node has a valid parent. Return it.
174 return TBAANodeImpl<MDNodeTy>(P);
177 /// Test if this TBAANode represents a type for objects which are
178 /// not modified (by any means) in the context where this
179 /// AliasAnalysis is relevant.
180 bool isTypeImmutable() const {
181 if (Node->getNumOperands() < 3)
183 ConstantInt *CI = mdconst::dyn_extract<ConstantInt>(Node->getOperand(2));
186 return CI->getValue()[0];
190 /// \name Specializations of \c TBAANodeImpl for const and non const qualified
193 using TBAANode = TBAANodeImpl<const MDNode>;
194 using MutableTBAANode = TBAANodeImpl<MDNode>;
197 /// This is a simple wrapper around an MDNode which provides a
198 /// higher-level interface by hiding the details of how alias analysis
199 /// information is encoded in its operands.
200 template<typename MDNodeTy>
201 class TBAAStructTagNodeImpl {
202 /// This node should be created with createTBAAAccessTag().
206 explicit TBAAStructTagNodeImpl(MDNodeTy *N) : Node(N) {}
208 /// Get the MDNode for this TBAAStructTagNode.
209 MDNodeTy *getNode() const { return Node; }
211 /// isNewFormat - Return true iff the wrapped access tag is in the new
212 /// size-aware format.
213 bool isNewFormat() const {
214 if (Node->getNumOperands() < 4)
216 if (MDNodeTy *AccessType = getAccessType())
217 if (!TBAANodeImpl<MDNodeTy>(AccessType).isNewFormat())
222 MDNodeTy *getBaseType() const {
223 return dyn_cast_or_null<MDNode>(Node->getOperand(0));
226 MDNodeTy *getAccessType() const {
227 return dyn_cast_or_null<MDNode>(Node->getOperand(1));
230 uint64_t getOffset() const {
231 return mdconst::extract<ConstantInt>(Node->getOperand(2))->getZExtValue();
234 uint64_t getSize() const {
237 return mdconst::extract<ConstantInt>(Node->getOperand(3))->getZExtValue();
240 /// Test if this TBAAStructTagNode represents a type for objects
241 /// which are not modified (by any means) in the context where this
242 /// AliasAnalysis is relevant.
243 bool isTypeImmutable() const {
244 unsigned OpNo = isNewFormat() ? 4 : 3;
245 if (Node->getNumOperands() < OpNo + 1)
247 ConstantInt *CI = mdconst::dyn_extract<ConstantInt>(Node->getOperand(OpNo));
250 return CI->getValue()[0];
254 /// \name Specializations of \c TBAAStructTagNodeImpl for const and non const
255 /// qualified \c MDNods.
257 using TBAAStructTagNode = TBAAStructTagNodeImpl<const MDNode>;
258 using MutableTBAAStructTagNode = TBAAStructTagNodeImpl<MDNode>;
261 /// This is a simple wrapper around an MDNode which provides a
262 /// higher-level interface by hiding the details of how alias analysis
263 /// information is encoded in its operands.
264 class TBAAStructTypeNode {
265 /// This node should be created with createTBAATypeNode().
266 const MDNode *Node = nullptr;
269 TBAAStructTypeNode() = default;
270 explicit TBAAStructTypeNode(const MDNode *N) : Node(N) {}
272 /// Get the MDNode for this TBAAStructTypeNode.
273 const MDNode *getNode() const { return Node; }
275 /// isNewFormat - Return true iff the wrapped type node is in the new
276 /// size-aware format.
277 bool isNewFormat() const { return isNewFormatTypeNode(Node); }
279 bool operator==(const TBAAStructTypeNode &Other) const {
280 return getNode() == Other.getNode();
283 /// getId - Return type identifier.
284 Metadata *getId() const {
285 return Node->getOperand(isNewFormat() ? 2 : 0);
288 unsigned getNumFields() const {
289 unsigned FirstFieldOpNo = isNewFormat() ? 3 : 1;
290 unsigned NumOpsPerField = isNewFormat() ? 3 : 2;
291 return (getNode()->getNumOperands() - FirstFieldOpNo) / NumOpsPerField;
294 TBAAStructTypeNode getFieldType(unsigned FieldIndex) const {
295 unsigned FirstFieldOpNo = isNewFormat() ? 3 : 1;
296 unsigned NumOpsPerField = isNewFormat() ? 3 : 2;
297 unsigned OpIndex = FirstFieldOpNo + FieldIndex * NumOpsPerField;
298 auto *TypeNode = cast<MDNode>(getNode()->getOperand(OpIndex));
299 return TBAAStructTypeNode(TypeNode);
302 /// Get this TBAAStructTypeNode's field in the type DAG with
303 /// given offset. Update the offset to be relative to the field type.
304 TBAAStructTypeNode getField(uint64_t &Offset) const {
305 bool NewFormat = isNewFormat();
307 // New-format root and scalar type nodes have no fields.
308 if (Node->getNumOperands() < 6)
309 return TBAAStructTypeNode();
311 // Parent can be omitted for the root node.
312 if (Node->getNumOperands() < 2)
313 return TBAAStructTypeNode();
315 // Fast path for a scalar type node and a struct type node with a single
317 if (Node->getNumOperands() <= 3) {
318 uint64_t Cur = Node->getNumOperands() == 2
320 : mdconst::extract<ConstantInt>(Node->getOperand(2))
323 MDNode *P = dyn_cast_or_null<MDNode>(Node->getOperand(1));
325 return TBAAStructTypeNode();
326 return TBAAStructTypeNode(P);
330 // Assume the offsets are in order. We return the previous field if
331 // the current offset is bigger than the given offset.
332 unsigned FirstFieldOpNo = NewFormat ? 3 : 1;
333 unsigned NumOpsPerField = NewFormat ? 3 : 2;
335 for (unsigned Idx = FirstFieldOpNo; Idx < Node->getNumOperands();
336 Idx += NumOpsPerField) {
337 uint64_t Cur = mdconst::extract<ConstantInt>(Node->getOperand(Idx + 1))
340 assert(Idx >= FirstFieldOpNo + NumOpsPerField &&
341 "TBAAStructTypeNode::getField should have an offset match!");
342 TheIdx = Idx - NumOpsPerField;
346 // Move along the last field.
348 TheIdx = Node->getNumOperands() - NumOpsPerField;
349 uint64_t Cur = mdconst::extract<ConstantInt>(Node->getOperand(TheIdx + 1))
352 MDNode *P = dyn_cast_or_null<MDNode>(Node->getOperand(TheIdx));
354 return TBAAStructTypeNode();
355 return TBAAStructTypeNode(P);
359 } // end anonymous namespace
361 /// Check the first operand of the tbaa tag node, if it is a MDNode, we treat
362 /// it as struct-path aware TBAA format, otherwise, we treat it as scalar TBAA
364 static bool isStructPathTBAA(const MDNode *MD) {
365 // Anonymous TBAA root starts with a MDNode and dragonegg uses it as
367 return isa<MDNode>(MD->getOperand(0)) && MD->getNumOperands() >= 3;
370 AliasResult TypeBasedAAResult::alias(const MemoryLocation &LocA,
371 const MemoryLocation &LocB) {
373 return AAResultBase::alias(LocA, LocB);
375 // If accesses may alias, chain to the next AliasAnalysis.
376 if (Aliases(LocA.AATags.TBAA, LocB.AATags.TBAA))
377 return AAResultBase::alias(LocA, LocB);
379 // Otherwise return a definitive result.
383 bool TypeBasedAAResult::pointsToConstantMemory(const MemoryLocation &Loc,
386 return AAResultBase::pointsToConstantMemory(Loc, OrLocal);
388 const MDNode *M = Loc.AATags.TBAA;
390 return AAResultBase::pointsToConstantMemory(Loc, OrLocal);
392 // If this is an "immutable" type, we can assume the pointer is pointing
393 // to constant memory.
394 if ((!isStructPathTBAA(M) && TBAANode(M).isTypeImmutable()) ||
395 (isStructPathTBAA(M) && TBAAStructTagNode(M).isTypeImmutable()))
398 return AAResultBase::pointsToConstantMemory(Loc, OrLocal);
401 FunctionModRefBehavior
402 TypeBasedAAResult::getModRefBehavior(const CallBase *Call) {
404 return AAResultBase::getModRefBehavior(Call);
406 FunctionModRefBehavior Min = FMRB_UnknownModRefBehavior;
408 // If this is an "immutable" type, we can assume the call doesn't write
410 if (const MDNode *M = Call->getMetadata(LLVMContext::MD_tbaa))
411 if ((!isStructPathTBAA(M) && TBAANode(M).isTypeImmutable()) ||
412 (isStructPathTBAA(M) && TBAAStructTagNode(M).isTypeImmutable()))
413 Min = FMRB_OnlyReadsMemory;
415 return FunctionModRefBehavior(AAResultBase::getModRefBehavior(Call) & Min);
418 FunctionModRefBehavior TypeBasedAAResult::getModRefBehavior(const Function *F) {
419 // Functions don't have metadata. Just chain to the next implementation.
420 return AAResultBase::getModRefBehavior(F);
423 ModRefInfo TypeBasedAAResult::getModRefInfo(const CallBase *Call,
424 const MemoryLocation &Loc) {
426 return AAResultBase::getModRefInfo(Call, Loc);
428 if (const MDNode *L = Loc.AATags.TBAA)
429 if (const MDNode *M = Call->getMetadata(LLVMContext::MD_tbaa))
431 return ModRefInfo::NoModRef;
433 return AAResultBase::getModRefInfo(Call, Loc);
436 ModRefInfo TypeBasedAAResult::getModRefInfo(const CallBase *Call1,
437 const CallBase *Call2) {
439 return AAResultBase::getModRefInfo(Call1, Call2);
441 if (const MDNode *M1 = Call1->getMetadata(LLVMContext::MD_tbaa))
442 if (const MDNode *M2 = Call2->getMetadata(LLVMContext::MD_tbaa))
443 if (!Aliases(M1, M2))
444 return ModRefInfo::NoModRef;
446 return AAResultBase::getModRefInfo(Call1, Call2);
449 bool MDNode::isTBAAVtableAccess() const {
450 if (!isStructPathTBAA(this)) {
451 if (getNumOperands() < 1)
453 if (MDString *Tag1 = dyn_cast<MDString>(getOperand(0))) {
454 if (Tag1->getString() == "vtable pointer")
460 // For struct-path aware TBAA, we use the access type of the tag.
461 TBAAStructTagNode Tag(this);
462 TBAAStructTypeNode AccessType(Tag.getAccessType());
463 if(auto *Id = dyn_cast<MDString>(AccessType.getId()))
464 if (Id->getString() == "vtable pointer")
469 static bool matchAccessTags(const MDNode *A, const MDNode *B,
470 const MDNode **GenericTag = nullptr);
472 MDNode *MDNode::getMostGenericTBAA(MDNode *A, MDNode *B) {
473 const MDNode *GenericTag;
474 matchAccessTags(A, B, &GenericTag);
475 return const_cast<MDNode*>(GenericTag);
478 static const MDNode *getLeastCommonType(const MDNode *A, const MDNode *B) {
485 SmallSetVector<const MDNode *, 4> PathA;
487 while (TA.getNode()) {
488 if (PathA.count(TA.getNode()))
489 report_fatal_error("Cycle found in TBAA metadata.");
490 PathA.insert(TA.getNode());
494 SmallSetVector<const MDNode *, 4> PathB;
496 while (TB.getNode()) {
497 if (PathB.count(TB.getNode()))
498 report_fatal_error("Cycle found in TBAA metadata.");
499 PathB.insert(TB.getNode());
503 int IA = PathA.size() - 1;
504 int IB = PathB.size() - 1;
506 const MDNode *Ret = nullptr;
507 while (IA >= 0 && IB >= 0) {
508 if (PathA[IA] == PathB[IB])
519 void Instruction::getAAMetadata(AAMDNodes &N, bool Merge) const {
522 MDNode::getMostGenericTBAA(N.TBAA, getMetadata(LLVMContext::MD_tbaa));
524 N.TBAA = getMetadata(LLVMContext::MD_tbaa);
527 N.Scope = MDNode::getMostGenericAliasScope(
528 N.Scope, getMetadata(LLVMContext::MD_alias_scope));
530 N.Scope = getMetadata(LLVMContext::MD_alias_scope);
534 MDNode::intersect(N.NoAlias, getMetadata(LLVMContext::MD_noalias));
536 N.NoAlias = getMetadata(LLVMContext::MD_noalias);
539 static const MDNode *createAccessTag(const MDNode *AccessType) {
540 // If there is no access type or the access type is the root node, then
541 // we don't have any useful access tag to return.
542 if (!AccessType || AccessType->getNumOperands() < 2)
545 Type *Int64 = IntegerType::get(AccessType->getContext(), 64);
546 auto *OffsetNode = ConstantAsMetadata::get(ConstantInt::get(Int64, 0));
548 if (TBAAStructTypeNode(AccessType).isNewFormat()) {
549 // TODO: Take access ranges into account when matching access tags and
550 // fix this code to generate actual access sizes for generic tags.
551 uint64_t AccessSize = UINT64_MAX;
553 ConstantAsMetadata::get(ConstantInt::get(Int64, AccessSize));
554 Metadata *Ops[] = {const_cast<MDNode*>(AccessType),
555 const_cast<MDNode*>(AccessType),
556 OffsetNode, SizeNode};
557 return MDNode::get(AccessType->getContext(), Ops);
560 Metadata *Ops[] = {const_cast<MDNode*>(AccessType),
561 const_cast<MDNode*>(AccessType),
563 return MDNode::get(AccessType->getContext(), Ops);
566 static bool hasField(TBAAStructTypeNode BaseType,
567 TBAAStructTypeNode FieldType) {
568 for (unsigned I = 0, E = BaseType.getNumFields(); I != E; ++I) {
569 TBAAStructTypeNode T = BaseType.getFieldType(I);
570 if (T == FieldType || hasField(T, FieldType))
576 /// Return true if for two given accesses, one of the accessed objects may be a
577 /// subobject of the other. The \p BaseTag and \p SubobjectTag parameters
578 /// describe the accesses to the base object and the subobject respectively.
579 /// \p CommonType must be the metadata node describing the common type of the
580 /// accessed objects. On return, \p MayAlias is set to true iff these accesses
581 /// may alias and \p Generic, if not null, points to the most generic access
582 /// tag for the given two.
583 static bool mayBeAccessToSubobjectOf(TBAAStructTagNode BaseTag,
584 TBAAStructTagNode SubobjectTag,
585 const MDNode *CommonType,
586 const MDNode **GenericTag,
588 // If the base object is of the least common type, then this may be an access
590 if (BaseTag.getAccessType() == BaseTag.getBaseType() &&
591 BaseTag.getAccessType() == CommonType) {
593 *GenericTag = createAccessTag(CommonType);
598 // If the access to the base object is through a field of the subobject's
599 // type, then this may be an access to that field. To check for that we start
600 // from the base type, follow the edge with the correct offset in the type DAG
601 // and adjust the offset until we reach the field type or until we reach the
603 bool NewFormat = BaseTag.isNewFormat();
604 TBAAStructTypeNode BaseType(BaseTag.getBaseType());
605 uint64_t OffsetInBase = BaseTag.getOffset();
608 // In the old format there is no distinction between fields and parent
609 // types, so in this case we consider all nodes up to the root.
610 if (!BaseType.getNode()) {
611 assert(!NewFormat && "Did not see access type in access path!");
615 if (BaseType.getNode() == SubobjectTag.getBaseType()) {
616 bool SameMemberAccess = OffsetInBase == SubobjectTag.getOffset();
618 *GenericTag = SameMemberAccess ? SubobjectTag.getNode() :
619 createAccessTag(CommonType);
621 MayAlias = SameMemberAccess;
625 // With new-format nodes we stop at the access type.
626 if (NewFormat && BaseType.getNode() == BaseTag.getAccessType())
629 // Follow the edge with the correct offset. Offset will be adjusted to
630 // be relative to the field type.
631 BaseType = BaseType.getField(OffsetInBase);
634 // If the base object has a direct or indirect field of the subobject's type,
635 // then this may be an access to that field. We need this to check now that
636 // we support aggregates as access types.
638 // TBAAStructTypeNode BaseAccessType(BaseTag.getAccessType());
639 TBAAStructTypeNode FieldType(SubobjectTag.getBaseType());
640 if (hasField(BaseType, FieldType)) {
642 *GenericTag = createAccessTag(CommonType);
651 /// matchTags - Return true if the given couple of accesses are allowed to
652 /// overlap. If \arg GenericTag is not null, then on return it points to the
653 /// most generic access descriptor for the given two.
654 static bool matchAccessTags(const MDNode *A, const MDNode *B,
655 const MDNode **GenericTag) {
662 // Accesses with no TBAA information may alias with any other accesses.
665 *GenericTag = nullptr;
669 // Verify that both input nodes are struct-path aware. Auto-upgrade should
670 // have taken care of this.
671 assert(isStructPathTBAA(A) && "Access A is not struct-path aware!");
672 assert(isStructPathTBAA(B) && "Access B is not struct-path aware!");
674 TBAAStructTagNode TagA(A), TagB(B);
675 const MDNode *CommonType = getLeastCommonType(TagA.getAccessType(),
676 TagB.getAccessType());
678 // If the final access types have different roots, they're part of different
679 // potentially unrelated type systems, so we must be conservative.
682 *GenericTag = nullptr;
686 // If one of the accessed objects may be a subobject of the other, then such
687 // accesses may alias.
689 if (mayBeAccessToSubobjectOf(/* BaseTag= */ TagA, /* SubobjectTag= */ TagB,
690 CommonType, GenericTag, MayAlias) ||
691 mayBeAccessToSubobjectOf(/* BaseTag= */ TagB, /* SubobjectTag= */ TagA,
692 CommonType, GenericTag, MayAlias))
695 // Otherwise, we've proved there's no alias.
697 *GenericTag = createAccessTag(CommonType);
701 /// Aliases - Test whether the access represented by tag A may alias the
702 /// access represented by tag B.
703 bool TypeBasedAAResult::Aliases(const MDNode *A, const MDNode *B) const {
704 return matchAccessTags(A, B);
707 AnalysisKey TypeBasedAA::Key;
709 TypeBasedAAResult TypeBasedAA::run(Function &F, FunctionAnalysisManager &AM) {
710 return TypeBasedAAResult();
713 char TypeBasedAAWrapperPass::ID = 0;
714 INITIALIZE_PASS(TypeBasedAAWrapperPass, "tbaa", "Type-Based Alias Analysis",
717 ImmutablePass *llvm::createTypeBasedAAWrapperPass() {
718 return new TypeBasedAAWrapperPass();
721 TypeBasedAAWrapperPass::TypeBasedAAWrapperPass() : ImmutablePass(ID) {
722 initializeTypeBasedAAWrapperPassPass(*PassRegistry::getPassRegistry());
725 bool TypeBasedAAWrapperPass::doInitialization(Module &M) {
726 Result.reset(new TypeBasedAAResult());
730 bool TypeBasedAAWrapperPass::doFinalization(Module &M) {
735 void TypeBasedAAWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
736 AU.setPreservesAll();