From 46759f4f46e51976ba459b18d163b8e1e354665f Mon Sep 17 00:00:00 2001 From: John McCall Date: Fri, 26 Aug 2011 07:31:35 +0000 Subject: Since the 'is aliased' bit is critical for correctness in C++, it really shouldn't be optional. Fix the remaining place where a temporary was being passed as potentially-aliased memory. Fixes PR10756. llvm-svn: 138627 --- clang/lib/CodeGen/CGExprAgg.cpp | 9 ++++++--- clang/lib/CodeGen/CGExprCXX.cpp | 3 ++- clang/lib/CodeGen/CGValue.h | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'clang/lib') diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index c42c87b1ac8..632e016f0ea 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -444,7 +444,8 @@ void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) { LValue RHS = CGF.EmitLValue(E->getRHS()); LValue LHS = CGF.EmitLValue(E->getLHS()); Dest = AggValueSlot::forLValue(LHS, AggValueSlot::IsDestructed, - needsGC(E->getLHS()->getType())); + needsGC(E->getLHS()->getType()), + AggValueSlot::IsAliased); EmitFinalDestCopy(E, RHS, true); return; } @@ -469,7 +470,8 @@ void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) { // Codegen the RHS so that it stores directly into the LHS. AggValueSlot LHSSlot = AggValueSlot::forLValue(LHS, AggValueSlot::IsDestructed, - needsGC(E->getLHS()->getType())); + needsGC(E->getLHS()->getType()), + AggValueSlot::IsAliased); CGF.EmitAggExpr(E->getRHS(), LHSSlot, false); EmitFinalDestCopy(E, LHS, true); } @@ -1052,7 +1054,8 @@ LValue CodeGenFunction::EmitAggExprToLValue(const Expr *E) { llvm::Value *Temp = CreateMemTemp(E->getType()); LValue LV = MakeAddrLValue(Temp, E->getType()); EmitAggExpr(E, AggValueSlot::forLValue(LV, AggValueSlot::IsNotDestructed, - AggValueSlot::DoesNotNeedGCBarriers)); + AggValueSlot::DoesNotNeedGCBarriers, + AggValueSlot::IsNotAliased)); return LV; } diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index cdab82eaab6..b638e5ba0d6 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -705,7 +705,8 @@ static void StoreAnyExprIntoOneUnit(CodeGenFunction &CGF, const CXXNewExpr *E, AggValueSlot Slot = AggValueSlot::forAddr(NewPtr, AllocType.getQualifiers(), AggValueSlot::IsDestructed, - AggValueSlot::DoesNotNeedGCBarriers); + AggValueSlot::DoesNotNeedGCBarriers, + AggValueSlot::IsNotAliased); CGF.EmitAggExpr(Init, Slot); } } diff --git a/clang/lib/CodeGen/CGValue.h b/clang/lib/CodeGen/CGValue.h index c448949d134..36b318fb2fd 100644 --- a/clang/lib/CodeGen/CGValue.h +++ b/clang/lib/CodeGen/CGValue.h @@ -383,7 +383,7 @@ public: static AggValueSlot forAddr(llvm::Value *addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, - IsAliased_t isAliased = IsAliased, + IsAliased_t isAliased, IsZeroed_t isZeroed = IsNotZeroed) { AggValueSlot AV; AV.Addr = addr; @@ -397,7 +397,7 @@ public: static AggValueSlot forLValue(LValue LV, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, - IsAliased_t isAliased = IsAliased, + IsAliased_t isAliased, IsZeroed_t isZeroed = IsNotZeroed) { return forAddr(LV.getAddress(), LV.getQuals(), isDestructed, needsGC, isAliased, isZeroed); -- cgit v1.2.3