summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorIvan A. Kosarev <ikosarev@accesssoftek.com>2017-10-02 11:10:04 +0000
committerIvan A. Kosarev <ikosarev@accesssoftek.com>2017-10-02 11:10:04 +0000
commit5c8e7596e6e886544cf99a9e9ee62d9bf0fc9ba3 (patch)
tree41294d0c4ccba0b3e11699a30ec1141edfdceb15 /clang/lib
parent3ccd23e1166ff7d79eb89579c0cd5056934a8f6c (diff)
downloadbcm5719-llvm-5c8e7596e6e886544cf99a9e9ee62d9bf0fc9ba3.tar.gz
bcm5719-llvm-5c8e7596e6e886544cf99a9e9ee62d9bf0fc9ba3.zip
[CodeGen] Have a special function to get TBAA info for may-alias accesses
This is part of D37826 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38408 llvm-svn: 314660
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp13
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp6
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h4
-rw-r--r--clang/lib/CodeGen/CodeGenTBAA.cpp4
-rw-r--r--clang/lib/CodeGen/CodeGenTBAA.h4
5 files changed, 23 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index b37036659cc..ba970b9bde1 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1522,7 +1522,7 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool Volatile,
if (TBAAAccessType) {
bool MayAlias = BaseInfo.getMayAlias();
llvm::MDNode *TBAA = MayAlias
- ? CGM.getTBAATypeInfo(getContext().CharTy)
+ ? CGM.getTBAAMayAliasTypeInfo()
: CGM.getTBAAStructTagInfo(TBAABaseType, TBAAAccessType, TBAAOffset);
if (TBAA)
CGM.DecorateInstructionWithTBAA(Load, TBAA, MayAlias);
@@ -1613,7 +1613,7 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr,
if (TBAAAccessType) {
bool MayAlias = BaseInfo.getMayAlias();
llvm::MDNode *TBAA = MayAlias
- ? CGM.getTBAATypeInfo(getContext().CharTy)
+ ? CGM.getTBAAMayAliasTypeInfo()
: CGM.getTBAAStructTagInfo(TBAABaseType, TBAAAccessType, TBAAOffset);
if (TBAA)
CGM.DecorateInstructionWithTBAA(Store, TBAA, MayAlias);
@@ -3724,11 +3724,8 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
// Loading the reference will disable path-aware TBAA.
TBAAPath = false;
if (CGM.shouldUseTBAA()) {
- llvm::MDNode *tbaa;
- if (mayAlias)
- tbaa = CGM.getTBAATypeInfo(getContext().CharTy);
- else
- tbaa = CGM.getTBAATypeInfo(type);
+ llvm::MDNode *tbaa = mayAlias ? CGM.getTBAAMayAliasTypeInfo() :
+ CGM.getTBAATypeInfo(type);
if (tbaa)
CGM.DecorateInstructionWithTBAA(load, tbaa);
}
@@ -3780,7 +3777,7 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
// FIXME: this should get propagated down through anonymous structs
// and unions.
if (mayAlias && LV.getTBAAAccessType())
- LV.setTBAAAccessType(CGM.getTBAATypeInfo(getContext().CharTy));
+ LV.setTBAAAccessType(CGM.getTBAAMayAliasTypeInfo());
return LV;
}
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 25779c044bb..ec122b795ce 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -599,6 +599,12 @@ llvm::MDNode *CodeGenModule::getTBAAStructTagInfo(QualType BaseTy,
return TBAA->getTBAAStructTagInfo(BaseTy, AccessN, O);
}
+llvm::MDNode *CodeGenModule::getTBAAMayAliasTypeInfo() {
+ if (!TBAA)
+ return nullptr;
+ return TBAA->getMayAliasTypeInfo();
+}
+
/// Decorate the instruction with a TBAA tag. For both scalar TBAA
/// and struct-path aware TBAA, the tag has the same format:
/// base type, access type and offset.
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index fdbf84416ca..1f26be6f2bd 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -662,6 +662,10 @@ public:
llvm::MDNode *getTBAAStructTagInfo(QualType BaseTy, llvm::MDNode *AccessN,
uint64_t O);
+ /// getTBAAMayAliasTypeInfo - Get TBAA information that represents
+ /// may-alias accesses.
+ llvm::MDNode *getTBAAMayAliasTypeInfo();
+
bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor);
bool isPaddedAtomicType(QualType type);
diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp b/clang/lib/CodeGen/CodeGenTBAA.cpp
index b341754ba09..7b8a023b794 100644
--- a/clang/lib/CodeGen/CodeGenTBAA.cpp
+++ b/clang/lib/CodeGen/CodeGenTBAA.cpp
@@ -326,3 +326,7 @@ CodeGenTBAA::getTBAAScalarTagInfo(llvm::MDNode *AccessNode) {
return ScalarTagMetadataCache[AccessNode] =
MDHelper.createTBAAStructTagNode(AccessNode, AccessNode, 0);
}
+
+llvm::MDNode *CodeGenTBAA::getMayAliasTypeInfo() {
+ return getChar();
+}
diff --git a/clang/lib/CodeGen/CodeGenTBAA.h b/clang/lib/CodeGen/CodeGenTBAA.h
index 9ff9e881d93..71c53d43f79 100644
--- a/clang/lib/CodeGen/CodeGenTBAA.h
+++ b/clang/lib/CodeGen/CodeGenTBAA.h
@@ -116,6 +116,10 @@ public:
/// Get the scalar tag MDNode for a given scalar type.
llvm::MDNode *getTBAAScalarTagInfo(llvm::MDNode *AccessNode);
+
+ /// getMayAliasTypeInfo - Get TBAA information that represents may-alias
+ /// accesses.
+ llvm::MDNode *getMayAliasTypeInfo();
};
} // end namespace CodeGen
OpenPOWER on IntegriCloud