[cfe-commits] r129652 - in /cfe/trunk: lib/CodeGen/CGCleanup.cpp lib/CodeGen/CGStmt.cpp lib/CodeGen/CodeGenFunction.h test/CodeGen/switch-dce.c
John McCall
rjmccall at apple.com
Tue Apr 19 13:29:07 PDT 2011
On Apr 16, 2011, at 5:54 PM, Chris Lattner wrote:
> Author: lattner
> Date: Sat Apr 16 19:54:30 2011
> New Revision: 129652
>
> URL: http://llvm.org/viewvc/llvm-project?rev=129652&view=rev
> Log:
> implement rdar://9289524 - case followed immediately by break results in empty IR block,
> a -O0 code quality issue.
Awesome, thanks!
> + // If the body of the case is just a 'break', try to not emit an empty block.
> + if (isa<BreakStmt>(S.getSubStmt())) {
> + JumpDest Block = BreakContinueStack.back().BreakBlock;
> +
> + // Only do this optimization if there are no cleanups that need emitting.
> + if (isObviouslyBranchWithoutCleanups(Block)) {
> + llvm::APSInt CaseVal = S.getLHS()->EvaluateAsInt(getContext());
This is common between these two code paths and would be nice to hoist.
John.
More information about the cfe-commits
mailing list