r314660 - [CodeGen] Have a special function to get TBAA info for may-alias accesses
Ivan A. Kosarev via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 2 04:10:04 PDT 2017
Author: kosarev
Date: Mon Oct 2 04:10:04 2017
New Revision: 314660
URL: http://llvm.org/viewvc/llvm-project?rev=314660&view=rev
Log:
[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
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
cfe/trunk/lib/CodeGen/CodeGenTBAA.h
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=314660&r1=314659&r2=314660&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Oct 2 04:10:04 2017
@@ -1522,7 +1522,7 @@ llvm::Value *CodeGenFunction::EmitLoadOf
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(
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::EmitLValueForFie
// 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::EmitLValueForFie
// 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;
}
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=314660&r1=314659&r2=314660&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Oct 2 04:10:04 2017
@@ -599,6 +599,12 @@ llvm::MDNode *CodeGenModule::getTBAAStru
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.
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=314660&r1=314659&r2=314660&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Mon Oct 2 04:10:04 2017
@@ -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);
Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=314660&r1=314659&r2=314660&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Mon Oct 2 04:10:04 2017
@@ -326,3 +326,7 @@ CodeGenTBAA::getTBAAScalarTagInfo(llvm::
return ScalarTagMetadataCache[AccessNode] =
MDHelper.createTBAAStructTagNode(AccessNode, AccessNode, 0);
}
+
+llvm::MDNode *CodeGenTBAA::getMayAliasTypeInfo() {
+ return getChar();
+}
Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.h?rev=314660&r1=314659&r2=314660&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.h Mon Oct 2 04:10:04 2017
@@ -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
More information about the cfe-commits
mailing list