diff options
| author | John McCall <rjmccall@apple.com> | 2011-08-25 20:40:09 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2011-08-25 20:40:09 +0000 |
| commit | 8d6fc9583de6627e4ae5fd7a93e2158516faeba4 (patch) | |
| tree | c72068eed5d1cf013e29a5fde288fafee00a2977 /clang/lib/CodeGen/CGExprAgg.cpp | |
| parent | 7aecbc7661943f398a098b551bfe97560299a771 (diff) | |
| download | bcm5719-llvm-8d6fc9583de6627e4ae5fd7a93e2158516faeba4.tar.gz bcm5719-llvm-8d6fc9583de6627e4ae5fd7a93e2158516faeba4.zip | |
Use stronger typing for the flags on AggValueSlot and require
creators to tell us whether something needs GC barriers.
No functionality change.
llvm-svn: 138581
Diffstat (limited to 'clang/lib/CodeGen/CGExprAgg.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExprAgg.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index 245640bfcf0..4a151fcfb88 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -71,6 +71,12 @@ public: void EmitGCMove(const Expr *E, RValue Src); + AggValueSlot::NeedsGCBarriers_t needsGC(QualType T) { + if (CGF.getLangOptions().getGCMode() && TypeRequiresGCollection(T)) + return AggValueSlot::NeedsGCBarriers; + return AggValueSlot::DoesNotNeedGCBarriers; + } + bool TypeRequiresGCollection(QualType T); //===--------------------------------------------------------------------===// @@ -426,10 +432,8 @@ void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) { // as it may change the 'forwarding' field via call to Block_copy. LValue RHS = CGF.EmitLValue(E->getRHS()); LValue LHS = CGF.EmitLValue(E->getLHS()); - bool GCollection = false; - if (CGF.getContext().getLangOptions().getGCMode()) - GCollection = TypeRequiresGCollection(E->getLHS()->getType()); - Dest = AggValueSlot::forLValue(LHS, true, GCollection); + Dest = AggValueSlot::forLValue(LHS, AggValueSlot::IsDestructed, + needsGC(E->getLHS()->getType())); EmitFinalDestCopy(E, RHS, true); return; } @@ -451,13 +455,10 @@ void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) { } CGF.EmitStoreThroughPropertyRefLValue(Src, LHS); } else { - bool GCollection = false; - if (CGF.getContext().getLangOptions().getGCMode()) - GCollection = TypeRequiresGCollection(E->getLHS()->getType()); - // Codegen the RHS so that it stores directly into the LHS. - AggValueSlot LHSSlot = AggValueSlot::forLValue(LHS, true, - GCollection); + AggValueSlot LHSSlot = + AggValueSlot::forLValue(LHS, AggValueSlot::IsDestructed, + needsGC(E->getLHS()->getType())); CGF.EmitAggExpr(E->getRHS(), LHSSlot, false); EmitFinalDestCopy(E, LHS, true); } @@ -596,7 +597,9 @@ AggExprEmitter::EmitInitializationToLValue(Expr* E, LValue LV) { } else if (type->isAnyComplexType()) { CGF.EmitComplexExprIntoAddr(E, LV.getAddress(), false); } else if (CGF.hasAggregateLLVMType(type)) { - CGF.EmitAggExpr(E, AggValueSlot::forLValue(LV, true, false, + CGF.EmitAggExpr(E, AggValueSlot::forLValue(LV, + AggValueSlot::IsDestructed, + AggValueSlot::DoesNotNeedGCBarriers, Dest.isZeroed())); } else if (LV.isSimple()) { CGF.EmitScalarInit(E, /*D=*/0, LV, /*Captured=*/false); @@ -1036,7 +1039,8 @@ LValue CodeGenFunction::EmitAggExprToLValue(const Expr *E) { assert(hasAggregateLLVMType(E->getType()) && "Invalid argument!"); llvm::Value *Temp = CreateMemTemp(E->getType()); LValue LV = MakeAddrLValue(Temp, E->getType()); - EmitAggExpr(E, AggValueSlot::forLValue(LV, false)); + EmitAggExpr(E, AggValueSlot::forLValue(LV, AggValueSlot::IsNotDestructed, + AggValueSlot::DoesNotNeedGCBarriers)); return LV; } |

