summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprAgg.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-01-26 04:00:11 +0000
committerJohn McCall <rjmccall@apple.com>2011-01-26 04:00:11 +0000
commitce1de6172cbf7c7bf5cbbb4bbaba4940023a5c2e (patch)
treeacde425e78a9f0b1877783b716b4073a9dc67717 /clang/lib/CodeGen/CGExprAgg.cpp
parent5499235d13418d034b2f341c66ff35545f9b742f (diff)
downloadbcm5719-llvm-ce1de6172cbf7c7bf5cbbb4bbaba4940023a5c2e.tar.gz
bcm5719-llvm-ce1de6172cbf7c7bf5cbbb4bbaba4940023a5c2e.zip
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
Diffstat (limited to 'clang/lib/CodeGen/CGExprAgg.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprAgg.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 03690777976..3a758a81027 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);
}
OpenPOWER on IntegriCloud