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 | 1860b520a2327702e1b50455c87882879eb777d3 (patch) | |
tree | 7e232f614a5d8208872ccbdcc452be4855faecd8 /clang/lib/CodeGen/CGExprAgg.cpp | |
parent | 929697bd55fdf384880cd6b15b3f276875085a1c (diff) | |
download | bcm5719-llvm-1860b520a2327702e1b50455c87882879eb777d3.tar.gz bcm5719-llvm-1860b520a2327702e1b50455c87882879eb777d3.zip |
[CodeGen] Decorate aggregate accesses with TBAA tags
Differential Revision: https://reviews.llvm.org/D41539
llvm-svn: 323421
Diffstat (limited to 'clang/lib/CodeGen/CGExprAgg.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprAgg.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index 0f05cab66d7..d2b29e06ae3 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/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); + } } |