summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-01-15 07:30:30 +0000
committerJustin Bogner <mail@justinbogner.com>2014-01-15 07:30:30 +0000
commit4c5c99f91a8ffa3fd342801a0b49607e9ebcb8f3 (patch)
tree130dec7fa95bfe42ed6b01449488201e91d8ed28
parent79b75d90483869cfff7b86ab92978b7c88e79fb8 (diff)
downloadbcm5719-llvm-4c5c99f91a8ffa3fd342801a0b49607e9ebcb8f3.tar.gz
bcm5719-llvm-4c5c99f91a8ffa3fd342801a0b49607e9ebcb8f3.zip
CodeGen: Simplify CodeGenFunction::EmitCaseStmt
Way back in r129652 we tried to avoid emitting an empty block at -O0 for switch cases that did nothing but break. This led to a poor debugging experience as reported in PR9796, so we disabled the optimization for -O0 but left it in for higher optimization levels in r154420. Since the whole point of this was to improve -O0, it's silly to keep the complexity at all. llvm-svn: 199302
-rw-r--r--clang/lib/CodeGen/CGCleanup.cpp23
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp24
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h5
3 files changed, 0 insertions, 52 deletions
diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index 65de4d498d1..c4e7880196e 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -883,29 +883,6 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) {
}
}
-/// isObviouslyBranchWithoutCleanups - Return true if a branch to the
-/// specified destination obviously has no cleanups to run. 'false' is always
-/// a conservatively correct answer for this method.
-bool CodeGenFunction::isObviouslyBranchWithoutCleanups(JumpDest Dest) const {
- assert(Dest.getScopeDepth().encloses(EHStack.stable_begin())
- && "stale jump destination");
-
- // Calculate the innermost active normal cleanup.
- EHScopeStack::stable_iterator TopCleanup =
- EHStack.getInnermostActiveNormalCleanup();
-
- // If we're not in an active normal cleanup scope, or if the
- // destination scope is within the innermost active normal cleanup
- // scope, we don't need to worry about fixups.
- if (TopCleanup == EHStack.stable_end() ||
- TopCleanup.encloses(Dest.getScopeDepth())) // works for invalid
- return true;
-
- // Otherwise, we might need some cleanups.
- return false;
-}
-
-
/// Terminate the current block by emitting a branch which might leave
/// the current cleanup-protected scope. The target scope may not yet
/// be known, in which case this will require a fixup.
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 880e801189a..3c059c2b52d 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -1075,30 +1075,6 @@ void CodeGenFunction::EmitCaseStmt(const CaseStmt &S) {
llvm::ConstantInt *CaseVal =
Builder.getInt(S.getLHS()->EvaluateKnownConstInt(getContext()));
- // If the body of the case is just a 'break', try to not emit an empty block.
- // If we're profiling or we're not optimizing, leave the block in for better
- // debug and coverage analysis.
- if (!CGM.getCodeGenOpts().ProfileInstrGenerate &&
- CGM.getCodeGenOpts().OptimizationLevel > 0 &&
- isa<BreakStmt>(S.getSubStmt())) {
- JumpDest Block = BreakContinueStack.back().BreakBlock;
-
- // Only do this optimization if there are no cleanups that need emitting.
- if (isObviouslyBranchWithoutCleanups(Block)) {
- if (SwitchWeights)
- SwitchWeights->push_back(CaseCnt.getCount() - CaseCnt.getParentCount());
- SwitchInsn->addCase(CaseVal, Block.getBlock());
-
- // If there was a fallthrough into this case, make sure to redirect it to
- // the end of the switch as well.
- if (Builder.GetInsertBlock()) {
- Builder.CreateBr(Block.getBlock());
- Builder.ClearInsertionPoint();
- }
- return;
- }
- }
-
EmitBlock(createBasicBlock("sw.bb"));
llvm::BasicBlock *CaseDest = Builder.GetInsertBlock();
if (SwitchWeights)
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 37bbcf3f342..22bb6c3e193 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -581,11 +581,6 @@ public:
/// on to \arg Dest.
void EmitBranchThroughCleanup(JumpDest Dest);
- /// isObviouslyBranchWithoutCleanups - Return true if a branch to the
- /// specified destination obviously has no cleanups to run. 'false' is always
- /// a conservatively correct answer for this method.
- bool isObviouslyBranchWithoutCleanups(JumpDest Dest) const;
-
/// popCatchScope - Pops the catch scope at the top of the EHScope
/// stack, emitting any required code (other than the catch handlers
/// themselves).
OpenPOWER on IntegriCloud