Nick Lewycky
295e397220
Teach simplifycfg to recompute branch weights when merging some branches, and
...
to discard weights when appropriate. Still more to do (and a new TODO), but
it's a start!
llvm-svn: 147286
2011-12-27 04:31:52 +00:00
Nick Lewycky
56e04db381
Update the branch weight metadata when reversing the order of a branch.
...
llvm-svn: 147280
2011-12-26 20:54:14 +00:00
Nick Lewycky
80b1ea7ea3
Sort includes, canonicalize whitespace, fix typos. No functionality change.
...
llvm-svn: 147279
2011-12-26 20:37:40 +00:00
Nick Lewycky
9adbd36737
Make some intrinsics safe to speculatively execute.
...
llvm-svn: 147036
2011-12-21 05:52:02 +00:00
Kevin Enderby
42fffe915a
Revert r146822 at Pete Cooper's request as it broke clang self hosting.
...
Hope I did this correctly :)
llvm-svn: 146834
2011-12-17 19:48:52 +00:00
Pete Cooper
0ec73f6e98
SimplifyCFG now predicts some conditional branches to true or false depending on previous branch on same comparison operands.
...
For example,
if (a == b) {
if (a > b) // this is false
Fixes some of the issues on <rdar://problem/10554090>
llvm-svn: 146822
2011-12-17 06:32:38 +00:00
Dan Gohman
1add31cc93
Move Instruction::isSafeToSpeculativelyExecute out of VMCore and
...
into Analysis as a standalone function, since there's no need for
it to be in VMCore. Also, update it to use isKnownNonZero and
other goodies available in Analysis, making it more precise,
enabling more aggressive optimization.
llvm-svn: 146610
2011-12-14 23:49:11 +00:00
Duncan Sands
d883f9f371
Delete trivial landing pads that just continue unwinding the caught
...
exception.
llvm-svn: 139117
2011-09-05 12:57:57 +00:00
Benjamin Kramer
0e1a09f38c
Address review comments.
...
- Reword comments.
- Allow undefined behavior interfering with undefined behavior.
- Add address space checks.
llvm-svn: 138619
2011-08-26 02:25:55 +00:00
Benjamin Kramer
dc1c57af91
SimplifyCFG: If we have a PHI node that can evaluate to NULL and do a load or store to the address returned by the PHI node then we can consider this incoming value as dead and remove the edge pointing there, unless there are instructions that can affect control flow executed in between.
...
In theory this could be extended to other instructions, eg. division by zero, but it's likely that it will "miscompile" some code because people depend on div by zero not trapping. NULL pointer dereference usually leads to a crash so we should be on the safe side.
This shrinks the size of a Release clang by 16k on x86_64.
llvm-svn: 138618
2011-08-26 01:22:29 +00:00
Bill Wendling
32612231af
I think there was some confusion about what I meant. :-) Replacing the comment.
...
llvm-svn: 137743
2011-08-16 20:41:17 +00:00
Eli Friedman
f969dabf83
After talking with Bill, it seems like the LandingPad handling here is likely
...
to be wrong (or at least somewhat suspect). Leave a FIXME for Bill.
llvm-svn: 137694
2011-08-16 00:41:37 +00:00
Eli Friedman
eb7e5209e5
Minor comment fixes.
...
llvm-svn: 137693
2011-08-16 00:20:11 +00:00
Eli Friedman
6a475e691d
Update SimplifyCFG for atomic operations.
...
This commit includes a mention of the landingpad instruction, but it's not
changing the behavior around it. I think the current behavior is correct,
though. Bill, can you double-check that?
llvm-svn: 137691
2011-08-15 23:59:28 +00:00
Chris Lattner
e1fe7061ce
land David Blaikie's patch to de-constify Type, with a few tweaks.
...
llvm-svn: 135375
2011-07-18 04:54:35 +00:00
Jay Foad
c826df8fb7
Convert CallInst and InvokeInst APIs to use ArrayRef.
...
llvm-svn: 135265
2011-07-15 08:37:34 +00:00
Rafael Espindola
03cd7c7b76
Add r134057 back, but splice the predecessor after the successors phi
...
nodes.
Original message:
Let simplify cfg simplify bb with only debug and lifetime intrinsics.
llvm-svn: 134182
2011-06-30 20:14:24 +00:00
Chad Rosier
fc7dc596a4
Temporarily revert r134057: "Let simplify cfg simplify bb with only debug and
...
lifetime intrinsics" due to buildbot failures.
llvm-svn: 134071
2011-06-29 16:22:11 +00:00
Rafael Espindola
e9e560eb37
Let simplify cfg simplify bb with only debug and lifetime intrinsics.
...
llvm-svn: 134057
2011-06-29 05:25:47 +00:00
Hans Wennborg
e1d53b6e2b
Fix PR10103: Less code for enum type translation.
...
In cases such as the attached test, where the case value for a switch
destination is used in a phi node that follows the destination, it
might be better to replace that value with the condition value of the
switch, so that more blocks can be folded away with
TryToSimplifyUncondBranchFromEmptyBlock because there are less
conflicts in the phi node.
llvm-svn: 133344
2011-06-18 10:28:47 +00:00
Bill Wendling
1da5257929
If the block that we're threading through is jumped to by an indirect branch,
...
then we don't want to set the destination in the indirect branch to the
destination. This is because the indirect branch needs its destinations to have
had their block addresses taken. This isn't so of the new critical edge that's
split during this process. If it turns out that the destination block has only
one predecessor, and that being a BB with an indirect branch, then it won't be
marked as 'used' and may be removed.
PR10072
llvm-svn: 132638
2011-06-04 09:42:04 +00:00
Frits van Bommel
df58ece78a
Add a parameter to ConstantFoldTerminator() that callers can use to ask it to also clean up the condition of any conditional terminator it folds to be unconditional, if that turns the condition into dead code. This just means it calls RecursivelyDeleteTriviallyDeadInstructions() in strategic spots. It defaults to the old behavior.
...
I also changed -simplifycfg, -jump-threading and -codegenprepare to use this to produce slightly better code without any extra cleanup passes (AFAICT this was the only place in -simplifycfg where now-dead conditions of replaced terminators weren't being cleaned up). The only other user of this function is -sccp, but I didn't read that thoroughly enough to figure out whether it might be holding pointers to instructions that could be deleted by this.
llvm-svn: 131855
2011-05-22 16:24:18 +00:00
Devang Patel
8d9eb3b0f7
Reapply r131605. This time with a fix, which is to use NoFolder.
...
llvm-svn: 131673
2011-05-19 20:52:46 +00:00
Rafael Espindola
4ebe940cd4
revert 131605 to fix PR9946.
...
llvm-svn: 131620
2011-05-19 02:26:30 +00:00
Devang Patel
c5390e2f7f
Use IRBuilder.
...
llvm-svn: 131609
2011-05-19 00:13:33 +00:00
Devang Patel
ecb22f0544
Use IRBuilder while simplifying unreachable.
...
llvm-svn: 131607
2011-05-19 00:09:21 +00:00
Devang Patel
fa6d0b4f84
Use IRBuilder while simplifying conditional branch.
...
llvm-svn: 131605
2011-05-18 23:59:51 +00:00
Devang Patel
877a16ea33
Use IRBuilder while simplifying branch.
...
llvm-svn: 131598
2011-05-18 23:18:47 +00:00
Devang Patel
3f94bed4e4
Use IRBuilder while simplifying return instruction.
...
llvm-svn: 131580
2011-05-18 21:33:11 +00:00
Devang Patel
3549e33227
Spread use of IRBuilder even more.
...
llvm-svn: 131571
2011-05-18 20:53:17 +00:00
Devang Patel
fd9b1daf82
Use IRBuilder while simplifying switch instruction.
...
llvm-svn: 131566
2011-05-18 20:35:38 +00:00
Devang Patel
40690a2df4
Use IRBuilder while simplifying unwind.
...
llvm-svn: 131561
2011-05-18 20:01:18 +00:00
Devang Patel
f0b8a243b9
Use IRBuilder while simplifying terminator.
...
llvm-svn: 131552
2011-05-18 18:43:31 +00:00
Devang Patel
faedd704bb
Use IRBuilder while simplifying unconditional branch.
...
llvm-svn: 131551
2011-05-18 18:28:48 +00:00
Devang Patel
9249a85cdc
Use IRBuilder while folding two entry PHINode.
...
llvm-svn: 131548
2011-05-18 18:16:44 +00:00
Devang Patel
6eb1a7bd09
Set up IRBuilder for use during simplification.
...
llvm-svn: 131545
2011-05-18 18:01:27 +00:00
Devang Patel
b75e746499
Preseve line numbers while simplifying CFG.
...
llvm-svn: 131508
2011-05-17 23:29:05 +00:00
Benjamin Kramer
5943d0a3ee
SimplifyCFG: Use ComputeMaskedBits to prune dead cases from switch instructions.
...
llvm-svn: 131345
2011-05-14 15:57:25 +00:00
Peter Collingbourne
d78bf257ad
SimplifyCFG: Expose phi node folding cost threshold as command line parameter
...
llvm-svn: 130528
2011-04-29 18:47:38 +00:00
Peter Collingbourne
0994e869f9
SimplifyCFG: Add CostRemaining parameter to DominatesMergePoint
...
llvm-svn: 130527
2011-04-29 18:47:31 +00:00
Peter Collingbourne
06646aa091
SimplifyCFG: Add Trunc, ZExt and SExt to the list of cheap instructions for phi node folding
...
llvm-svn: 130526
2011-04-29 18:47:25 +00:00
Chris Lattner
88e2acc24c
rework FoldBranchToCommonDest to exit earlier when there is a bonus
...
instruction around, reducing work.
Greatly simplify handling of debug instructions. There is no need to
build up a vector of them and then move them into the one predecessor
if we're processing a block. Instead just rescan the block and *copy*
them into the pred. If a block gets merged into multiple preds, this
will retain more debug info.
llvm-svn: 129502
2011-04-14 02:44:53 +00:00
Chris Lattner
2871dd44cb
comment cleanup, use moveBefore instead of removeFromParent+insertBefore.
...
llvm-svn: 129319
2011-04-11 23:24:57 +00:00
Devang Patel
47e1db49c9
Do not let debug info interfer with branch folding.
...
llvm-svn: 129114
2011-04-07 23:11:25 +00:00
Devang Patel
17670a995c
While hoisting common code from if/else, hoist debug info intrinsics if they match.
...
llvm-svn: 129078
2011-04-07 17:27:36 +00:00
Devang Patel
bb234bb5dd
Simplify. isIdenticalToWhenDefined() checks opcode.
...
llvm-svn: 129041
2011-04-07 00:30:15 +00:00
Devang Patel
12a95842b2
While folding branch to a common destination into a predecessor, copy dbg values also.
...
llvm-svn: 129035
2011-04-06 22:37:20 +00:00
Jay Foad
53632b7c03
Remove PHINode::reserveOperandSpace(). Instead, add a parameter to
...
PHINode::Create() giving the (known or expected) number of operands.
llvm-svn: 128537
2011-03-30 11:28:46 +00:00
Jay Foad
dc5a008237
(Almost) always call reserveOperandSpace() on newly created PHINodes.
...
llvm-svn: 128535
2011-03-30 11:19:20 +00:00
Eli Friedman
c0bfbd0610
PR9450: Make switch optimization in SimplifyCFG not dependent on the ordering
...
of pointers in an std::map.
llvm-svn: 127650
2011-03-15 02:23:35 +00:00