diff options
| author | Justin Bogner <mail@justinbogner.com> | 2014-01-06 22:27:43 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2014-01-06 22:27:43 +0000 |
| commit | e0e019f6a2d76e140221d9c10159a444839e2563 (patch) | |
| tree | e17e8b4c7d49c80b85dae49d6a0de39b9b3dd2f5 /lib/CodeGen/CGExpr.cpp | |
| parent | f4c386bdd1f95c0ee746a5baac574bf9723cc5de (diff) | |
| download | clang-e0e019f6a2d76e140221d9c10159a444839e2563.tar.gz clang-e0e019f6a2d76e140221d9c10159a444839e2563.tar.bz2 clang-e0e019f6a2d76e140221d9c10159a444839e2563.tar.xz | |
CodeGen: Initial instrumentation based PGO implementation
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198640 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | lib/CodeGen/CGExpr.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 92966d0eb1..9c108e9375 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -2651,6 +2651,7 @@ EmitConditionalOperatorLValue(const AbstractConditionalOperator *expr) { } OpaqueValueMapping binding(*this, expr); + RegionCounter Cnt = getPGORegionCounter(expr); const Expr *condExpr = expr->getCond(); bool CondExprBool; @@ -2658,8 +2659,12 @@ EmitConditionalOperatorLValue(const AbstractConditionalOperator *expr) { const Expr *live = expr->getTrueExpr(), *dead = expr->getFalseExpr(); if (!CondExprBool) std::swap(live, dead); - if (!ContainsLabel(dead)) + if (!ContainsLabel(dead)) { + // If the true case is live, we need to track its region + if (CondExprBool) + Cnt.beginRegion(Builder); return EmitLValue(live); + } } llvm::BasicBlock *lhsBlock = createBasicBlock("cond.true"); @@ -2667,13 +2672,15 @@ EmitConditionalOperatorLValue(const AbstractConditionalOperator *expr) { llvm::BasicBlock *contBlock = createBasicBlock("cond.end"); ConditionalEvaluation eval(*this); - EmitBranchOnBoolExpr(condExpr, lhsBlock, rhsBlock); + EmitBranchOnBoolExpr(condExpr, lhsBlock, rhsBlock, Cnt.getCount()); // Any temporaries created here are conditional. EmitBlock(lhsBlock); + Cnt.beginRegion(Builder); eval.begin(*this); LValue lhs = EmitLValue(expr->getTrueExpr()); eval.end(*this); + Cnt.adjustFallThroughCount(); if (!lhs.isSimple()) return EmitUnsupportedLValue(expr, "conditional operator"); @@ -2683,14 +2690,17 @@ EmitConditionalOperatorLValue(const AbstractConditionalOperator *expr) { // Any temporaries created here are conditional. EmitBlock(rhsBlock); + Cnt.beginElseRegion(); eval.begin(*this); LValue rhs = EmitLValue(expr->getFalseExpr()); eval.end(*this); + Cnt.adjustFallThroughCount(); if (!rhs.isSimple()) return EmitUnsupportedLValue(expr, "conditional operator"); rhsBlock = Builder.GetInsertBlock(); EmitBlock(contBlock); + Cnt.applyAdjustmentsToRegion(); llvm::PHINode *phi = Builder.CreatePHI(lhs.getAddress()->getType(), 2, "cond-lvalue"); |
