From ce1de6172cbf7c7bf5cbbb4bbaba4940023a5c2e Mon Sep 17 00:00:00 2001 From: John McCall Date: Wed, 26 Jan 2011 04:00:11 +0000 Subject: 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. llvm-svn: 124277 --- clang/lib/CodeGen/CGExprAgg.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'clang/lib/CodeGen/CGExprAgg.cpp') diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index 0369077..3a758a8 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/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); } -- cgit v1.1