summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenTBAA.h
diff options
context:
space:
mode:
authorIvan A. Kosarev <ikosarev@accesssoftek.com>2017-10-03 10:52:39 +0000
committerIvan A. Kosarev <ikosarev@accesssoftek.com>2017-10-03 10:52:39 +0000
commita511ed75013f049eaf6f1978bff15cb7020524d4 (patch)
tree9c6b03cf228792b063641ea2a941a43ed6dbeb24 /clang/lib/CodeGen/CodeGenTBAA.h
parente093bad472ce7ad1715321abbb3b1fdbf42e2693 (diff)
downloadbcm5719-llvm-a511ed75013f049eaf6f1978bff15cb7020524d4.tar.gz
bcm5719-llvm-a511ed75013f049eaf6f1978bff15cb7020524d4.zip
[CodeGen] Introduce generic TBAA access descriptors
With this patch we implement a concept of TBAA access descriptors that are capable of representing both scalar and struct-path accesses in a generic way. This is part of D37826 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38456 llvm-svn: 314780
Diffstat (limited to 'clang/lib/CodeGen/CodeGenTBAA.h')
-rw-r--r--clang/lib/CodeGen/CodeGenTBAA.h51
1 files changed, 39 insertions, 12 deletions
diff --git a/clang/lib/CodeGen/CodeGenTBAA.h b/clang/lib/CodeGen/CodeGenTBAA.h
index 71c53d43f79..2b2c2d4b098 100644
--- a/clang/lib/CodeGen/CodeGenTBAA.h
+++ b/clang/lib/CodeGen/CodeGenTBAA.h
@@ -30,15 +30,43 @@ namespace clang {
class Type;
namespace CodeGen {
- class CGRecordLayout;
+class CGRecordLayout;
+
+struct TBAAPathTag {
+ TBAAPathTag(const Type *B, const llvm::MDNode *A, uint64_t O)
+ : BaseT(B), AccessN(A), Offset(O) {}
+ const Type *BaseT;
+ const llvm::MDNode *AccessN;
+ uint64_t Offset;
+};
+
+// TBAAAccessInfo - Describes a memory access in terms of TBAA.
+struct TBAAAccessInfo {
+ TBAAAccessInfo(QualType BaseType, llvm::MDNode *AccessType, uint64_t Offset)
+ : BaseType(BaseType), AccessType(AccessType), Offset(Offset)
+ {}
+
+ explicit TBAAAccessInfo(llvm::MDNode *AccessType)
+ : TBAAAccessInfo(/* BaseType= */ QualType(), AccessType, /* Offset= */ 0)
+ {}
+
+ TBAAAccessInfo()
+ : TBAAAccessInfo(/* AccessType= */ nullptr)
+ {}
- struct TBAAPathTag {
- TBAAPathTag(const Type *B, const llvm::MDNode *A, uint64_t O)
- : BaseT(B), AccessN(A), Offset(O) {}
- const Type *BaseT;
- const llvm::MDNode *AccessN;
- uint64_t Offset;
- };
+ /// BaseType - The base/leading access type. May be null if this access
+ /// descriptor represents an access that is not considered to be an access
+ /// to an aggregate or union member.
+ QualType BaseType;
+
+ /// AccessType - The final access type. May be null if there is no TBAA
+ /// information available about this access.
+ llvm::MDNode *AccessType;
+
+ /// Offset - The byte offset of the final access within the base one. Must be
+ /// zero if the base access type is not specified.
+ uint64_t Offset;
+};
/// CodeGenTBAA - This class organizes the cross-module state that is used
/// while lowering AST types to LLVM types.
@@ -109,10 +137,9 @@ public:
/// Get the MDNode in the type DAG for given struct type QType.
llvm::MDNode *getTBAAStructTypeInfo(QualType QType);
- /// Get the tag MDNode for a given base type, the actual scalar access MDNode
- /// and offset into the base type.
- llvm::MDNode *getTBAAStructTagInfo(QualType BaseQType,
- llvm::MDNode *AccessNode, uint64_t Offset);
+
+ /// Get path-aware TBAA tag for a given memory access.
+ llvm::MDNode *getTBAAStructTagInfo(TBAAAccessInfo Info);
/// Get the scalar tag MDNode for a given scalar type.
llvm::MDNode *getTBAAScalarTagInfo(llvm::MDNode *AccessNode);
OpenPOWER on IntegriCloud