From 85ef073903c139db79807cbb8217aa2f4a941b1c Mon Sep 17 00:00:00 2001 From: "Ivan A. Kosarev" Date: Fri, 13 Oct 2017 16:50:50 +0000 Subject: [PATCH] [CodeGen] EmitLoadOfReference() to generate TBAA info along with LValue base info This patch should not bring in any functional changes. Differential Revision: https://reviews.llvm.org/D38793 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315705 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 12 ++++++++---- lib/CodeGen/CodeGenFunction.h | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index bb2e8550bd..2e609deabf 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -2149,7 +2149,11 @@ static LValue EmitThreadPrivateVarDeclLValue( Address CodeGenFunction::EmitLoadOfReference(Address Addr, const ReferenceType *RefTy, - LValueBaseInfo *BaseInfo) { + LValueBaseInfo *BaseInfo, + TBAAAccessInfo *TBAAInfo) { + if (TBAAInfo) + *TBAAInfo = CGM.getTBAAAccessInfo(RefTy->getPointeeType()); + llvm::Value *Ptr = Builder.CreateLoad(Addr); return Address(Ptr, getNaturalTypeAlignment(RefTy->getPointeeType(), BaseInfo, /*forPointee*/ true)); @@ -2158,9 +2162,9 @@ Address CodeGenFunction::EmitLoadOfReference(Address Addr, LValue CodeGenFunction::EmitLoadOfReferenceLValue(Address RefAddr, const ReferenceType *RefTy) { LValueBaseInfo BaseInfo; - Address Addr = EmitLoadOfReference(RefAddr, RefTy, &BaseInfo); - return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo, - CGM.getTBAAAccessInfo(RefTy->getPointeeType())); + TBAAAccessInfo TBAAInfo; + Address Addr = EmitLoadOfReference(RefAddr, RefTy, &BaseInfo, &TBAAInfo); + return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo, TBAAInfo); } Address CodeGenFunction::EmitLoadOfPointer(Address Ptr, diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 2b8720a5de..1f046faaa7 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -1944,7 +1944,8 @@ public: LValueBaseInfo *BaseInfo = nullptr); Address EmitLoadOfReference(Address Ref, const ReferenceType *RefTy, - LValueBaseInfo *BaseInfo = nullptr); + LValueBaseInfo *BaseInfo = nullptr, + TBAAAccessInfo *TBAAInfo = nullptr); LValue EmitLoadOfReferenceLValue(Address Ref, const ReferenceType *RefTy); Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy, -- 2.40.0