diff options
| author | Ivan A. Kosarev <ikosarev@accesssoftek.com> | 2017-10-03 10:52:39 +0000 |
|---|---|---|
| committer | Ivan A. Kosarev <ikosarev@accesssoftek.com> | 2017-10-03 10:52:39 +0000 |
| commit | a511ed75013f049eaf6f1978bff15cb7020524d4 (patch) | |
| tree | 9c6b03cf228792b063641ea2a941a43ed6dbeb24 /clang/lib/CodeGen/CGExpr.cpp | |
| parent | e093bad472ce7ad1715321abbb3b1fdbf42e2693 (diff) | |
| download | bcm5719-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/CGExpr.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index cd2e8e14bc6..74ad9dcf463 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -1375,9 +1375,7 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(LValue lvalue, SourceLocation Loc) { return EmitLoadOfScalar(lvalue.getAddress(), lvalue.isVolatile(), lvalue.getType(), Loc, lvalue.getBaseInfo(), - lvalue.getTBAAAccessType(), - lvalue.getTBAABaseType(), lvalue.getTBAAOffset(), - lvalue.isNontemporal()); + lvalue.getTBAAInfo(), lvalue.isNontemporal()); } static bool hasBooleanRepresentation(QualType Ty) { @@ -1487,9 +1485,7 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty, SourceLocation Loc, LValueBaseInfo BaseInfo, - llvm::MDNode *TBAAAccessType, - QualType TBAABaseType, - uint64_t TBAAOffset, + TBAAAccessInfo TBAAInfo, bool isNontemporal) { if (!CGM.getCodeGenOpts().PreserveVec3Type) { // For better performance, handle vector loads differently. @@ -1518,7 +1514,7 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool Volatile, // Atomic operations have to be done on integral types. LValue AtomicLValue = - LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAAccessType); + LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo.AccessType); if (Ty->isAtomicType() || LValueIsSuitableForInlineAtomic(AtomicLValue)) { return EmitAtomicLoad(AtomicLValue, Loc).getScalarVal(); } @@ -1529,11 +1525,11 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool Volatile, Load->getContext(), llvm::ConstantAsMetadata::get(Builder.getInt32(1))); Load->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node); } - if (TBAAAccessType) { + if (TBAAInfo.AccessType) { bool MayAlias = BaseInfo.getMayAlias(); llvm::MDNode *TBAA = MayAlias ? CGM.getTBAAMayAliasTypeInfo() - : CGM.getTBAAStructTagInfo(TBAABaseType, TBAAAccessType, TBAAOffset); + : CGM.getTBAAStructTagInfo(TBAAInfo); if (TBAA) CGM.DecorateInstructionWithTBAA(Load, TBAA, MayAlias); } @@ -1576,11 +1572,8 @@ llvm::Value *CodeGenFunction::EmitFromMemory(llvm::Value *Value, QualType Ty) { void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, LValueBaseInfo BaseInfo, - llvm::MDNode *TBAAAccessType, - bool isInit, QualType TBAABaseType, - uint64_t TBAAOffset, - bool isNontemporal) { - + TBAAAccessInfo TBAAInfo, + bool isInit, bool isNontemporal) { if (!CGM.getCodeGenOpts().PreserveVec3Type) { // Handle vectors differently to get better performance. if (Ty->isVectorType()) { @@ -1606,7 +1599,7 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr, Value = EmitToMemory(Value, Ty); LValue AtomicLValue = - LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAAccessType); + LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo.AccessType); if (Ty->isAtomicType() || (!isInit && LValueIsSuitableForInlineAtomic(AtomicLValue))) { EmitAtomicStore(RValue::get(Value), AtomicLValue, isInit); @@ -1620,11 +1613,11 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr, llvm::ConstantAsMetadata::get(Builder.getInt32(1))); Store->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node); } - if (TBAAAccessType) { + if (TBAAInfo.AccessType) { bool MayAlias = BaseInfo.getMayAlias(); llvm::MDNode *TBAA = MayAlias ? CGM.getTBAAMayAliasTypeInfo() - : CGM.getTBAAStructTagInfo(TBAABaseType, TBAAAccessType, TBAAOffset); + : CGM.getTBAAStructTagInfo(TBAAInfo); if (TBAA) CGM.DecorateInstructionWithTBAA(Store, TBAA, MayAlias); } @@ -1634,9 +1627,7 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *value, LValue lvalue, bool isInit) { EmitStoreOfScalar(value, lvalue.getAddress(), lvalue.isVolatile(), lvalue.getType(), lvalue.getBaseInfo(), - lvalue.getTBAAAccessType(), isInit, - lvalue.getTBAABaseType(), lvalue.getTBAAOffset(), - lvalue.isNontemporal()); + lvalue.getTBAAInfo(), isInit, lvalue.isNontemporal()); } /// EmitLoadOfLValue - Given an expression that represents a value lvalue, this @@ -3776,10 +3767,13 @@ LValue CodeGenFunction::EmitLValueForField(LValue base, getContext().getASTRecordLayout(field->getParent()); // Set the base type to be the base type of the base LValue and // update offset to be relative to the base type. - LV.setTBAABaseType(mayAlias ? getContext().CharTy : base.getTBAABaseType()); - LV.setTBAAOffset(mayAlias ? 0 : base.getTBAAOffset() + - Layout.getFieldOffset(field->getFieldIndex()) / - getContext().getCharWidth()); + unsigned CharWidth = getContext().getCharWidth(); + TBAAAccessInfo TBAAInfo = mayAlias ? + TBAAAccessInfo(CGM.getTBAAMayAliasTypeInfo()) : + TBAAAccessInfo(base.getTBAAInfo().BaseType, CGM.getTBAATypeInfo(type), + base.getTBAAInfo().Offset + Layout.getFieldOffset( + field->getFieldIndex()) / CharWidth); + LV.setTBAAInfo(TBAAInfo); } // __weak attribute on a field is ignored. |

