diff options
| author | Ivan A. Kosarev <ikosarev@accesssoftek.com> | 2018-01-25 14:21:55 +0000 |
|---|---|---|
| committer | Ivan A. Kosarev <ikosarev@accesssoftek.com> | 2018-01-25 14:21:55 +0000 |
| commit | 9660f4bc0062e8c71f2b8310b6ed0520177ee317 (patch) | |
| tree | 837a3813c7cd598d0ee7fc799bd1435b1685a21c /lib/CodeGen/CGExprAgg.cpp | |
| parent | f949e0451d222ba394d169f052a0658b259a4af3 (diff) | |
| download | clang-9660f4bc0062e8c71f2b8310b6ed0520177ee317.tar.gz | |
[CodeGen] Decorate aggregate accesses with TBAA tags
Differential Revision: https://reviews.llvm.org/D41539
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323421 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprAgg.cpp')
| -rw-r--r-- | lib/CodeGen/CGExprAgg.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 0f05cab66d..d2b29e06ae 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -298,7 +298,9 @@ void AggExprEmitter::EmitCopy(QualType type, const AggValueSlot &dest, // If the result of the assignment is used, copy the LHS there also. // It's volatile if either side is. Use the minimum alignment of // the two sides. - CGF.EmitAggregateCopy(dest.getAddress(), src.getAddress(), type, + LValue DestLV = CGF.MakeAddrLValue(dest.getAddress(), type); + LValue SrcLV = CGF.MakeAddrLValue(src.getAddress(), type); + CGF.EmitAggregateCopy(DestLV, SrcLV, type, dest.isVolatile() || src.isVolatile()); } @@ -1541,12 +1543,14 @@ LValue CodeGenFunction::EmitAggExprToLValue(const Expr *E) { return LV; } -void CodeGenFunction::EmitAggregateCopy(Address DestPtr, - Address SrcPtr, QualType Ty, - bool isVolatile, +void CodeGenFunction::EmitAggregateCopy(LValue Dest, LValue Src, + QualType Ty, bool isVolatile, bool isAssignment) { assert(!Ty->isAnyComplexType() && "Shouldn't happen for complex"); + Address DestPtr = Dest.getAddress(); + Address SrcPtr = Src.getAddress(); + if (getLangOpts().CPlusPlus) { if (const RecordType *RT = Ty->getAs<RecordType>()) { CXXRecordDecl *Record = cast<CXXRecordDecl>(RT->getDecl()); @@ -1562,7 +1566,7 @@ void CodeGenFunction::EmitAggregateCopy(Address DestPtr, return; } } - + // Aggregate assignment turns into llvm.memcpy. This is almost valid per // C99 6.5.16.1p3, which states "If the value being stored in an object is // read from another object that overlaps in anyway the storage of the first @@ -1657,4 +1661,10 @@ void CodeGenFunction::EmitAggregateCopy(Address DestPtr, // the optimizer wishes to expand it in to scalar memory operations. if (llvm::MDNode *TBAAStructTag = CGM.getTBAAStructInfo(Ty)) Inst->setMetadata(llvm::LLVMContext::MD_tbaa_struct, TBAAStructTag); + + if (CGM.getCodeGenOpts().NewStructPathTBAA) { + TBAAAccessInfo TBAAInfo = CGM.mergeTBAAInfoForMemoryTransfer( + Dest.getTBAAInfo(), Src.getTBAAInfo()); + CGM.DecorateInstructionWithTBAA(Inst, TBAAInfo); + } } |
