diff options
author | John McCall <rjmccall@apple.com> | 2011-01-26 04:00:11 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-01-26 04:00:11 +0000 |
commit | 150b462afc7a713edd19bcbbbb22381fe060d4f5 (patch) | |
tree | d90a44bc497a080b64d9143f25f9ef32b6c1228f /lib/CodeGen/CGExprAgg.cpp | |
parent | 83f51722ed2b8134810cb178f39e44da811de7cd (diff) |
Better framework for conditional cleanups; untested as yet.
I'm separately committing this because it incidentally changes some
block orderings and minor IR issues, like using a phi instead of
an unnecessary alloca.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124277 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprAgg.cpp')
-rw-r--r-- | lib/CodeGen/CGExprAgg.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 0369077797..3a758a8102 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -367,8 +367,8 @@ void AggExprEmitter::VisitBinComma(const BinaryOperator *E) { } void AggExprEmitter::VisitStmtExpr(const StmtExpr *E) { + CodeGenFunction::StmtExprEvaluation eval(CGF); CGF.EmitCompoundStmt(*E->getSubStmt(), true, Dest); - CGF.EnsureInsertPoint(); } void AggExprEmitter::VisitBinaryOperator(const BinaryOperator *E) { @@ -423,20 +423,19 @@ void AggExprEmitter::VisitConditionalOperator(const ConditionalOperator *E) { llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("cond.false"); llvm::BasicBlock *ContBlock = CGF.createBasicBlock("cond.end"); + CodeGenFunction::ConditionalEvaluation eval(CGF); CGF.EmitBranchOnBoolExpr(E->getCond(), LHSBlock, RHSBlock); - CGF.BeginConditionalBranch(); - CGF.EmitBlock(LHSBlock); - // Save whether the destination's lifetime is externally managed. bool DestLifetimeManaged = Dest.isLifetimeExternallyManaged(); + eval.begin(CGF); + CGF.EmitBlock(LHSBlock); Visit(E->getLHS()); - CGF.EndConditionalBranch(); - CGF.EmitBranch(ContBlock); + eval.end(CGF); - CGF.BeginConditionalBranch(); - CGF.EmitBlock(RHSBlock); + assert(CGF.HaveInsertPoint() && "expression evaluation ended with no IP!"); + CGF.Builder.CreateBr(ContBlock); // If the result of an agg expression is unused, then the emission // of the LHS might need to create a destination slot. That's fine @@ -444,9 +443,10 @@ void AggExprEmitter::VisitConditionalOperator(const ConditionalOperator *E) { // we shouldn't claim that its lifetime is externally managed. Dest.setLifetimeExternallyManaged(DestLifetimeManaged); + eval.begin(CGF); + CGF.EmitBlock(RHSBlock); Visit(E->getRHS()); - CGF.EndConditionalBranch(); - CGF.EmitBranch(ContBlock); + eval.end(CGF); CGF.EmitBlock(ContBlock); } |