aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/BranchFolding.cpp
AgeCommit message (Collapse)AuthorFilesLines
2010-08-06Reapply r110396, with fixes to appease the Linux buildbot gods.Owen Anderson1-1/+1
llvm-svn: 110460
2010-08-06Revert r110396 to fix buildbots.Owen Anderson1-1/+1
llvm-svn: 110410
2010-08-05Don't use PassInfo* as a type identifier for passes. Instead, use the ↵Owen Anderson1-1/+1
address of the static ID member as the sole unique type identifier. Clean up APIs related to this change. llvm-svn: 110396
2010-06-22Tail merging pass shall not break up IT blocks. rdar://8115404Evan Cheng1-5/+18
llvm-svn: 106517
2010-06-18Allow ARM if-converter to be run after post allocation scheduling.Evan Cheng1-16/+2
- This fixed a number of bugs in if-converter, tail merging, and post-allocation scheduler. If-converter now runs branch folding / tail merging first to maximize if-conversion opportunities. - Also changed the t2IT instruction slightly. It now defines the ITSTATE register which is read by instructions in the IT block. - Added Thumb2 specific hazard recognizer to ensure the scheduler doesn't change the instruction ordering in the IT block (since IT mask has been finalized). It also ensures no other instructions can be scheduled between instructions in the IT block. This is not yet enabled. llvm-svn: 106344
2010-06-17Add a DebugLoc parameter to TargetInstrInfo::InsertBranch(). ThisStuart Hastings1-13/+18
addresses a longstanding deficiency noted in many FIXMEs scattered across all the targets. This effectively moves the problem up one level, replacing eleven FIXMEs in the targets with eight FIXMEs in CodeGen, plus one path through FastISel where we actually supply a DebugLoc, fixing Radar 7421831. llvm-svn: 106243
2010-05-03Fix a bug which prevented tail merging of return instructions inDan Gohman1-24/+5
beneficial cases. See the changes in test/CodeGen/X86/tail-opts.ll and test/CodeGen/ARM/ifcvt2.ll for details. The fix is to change HashEndOfMBB to hash at most one instruction, instead of trying to apply heuristics about when it will be profitable to consider more than one instruction. The regular tail-merging heuristics are already prepared to handle the same cases, and they're more precise. Also, make test/CodeGen/ARM/ifcvt5.ll and test/CodeGen/Thumb2/thumb2-branch.ll slightly more complex so that they continue to test what they're intended to test. And, this eliminates the problem in test/CodeGen/Thumb2/2009-10-15-ITBlockBranch.ll, the testcase from PR5204. Update it accordingly. llvm-svn: 102907
2010-04-02Teach AnalyzeBranch, RemoveBranch and the branchDale Johannesen1-3/+9
folder to be tolerant of debug info following the branch(es) at the end of a block. llvm-svn: 100168
2010-03-19Stop trying to merge identical jump tables. This had been inadvertentlyBob Wilson1-28/+6
disabled for several months (since svn r88806) and no one noticed. My fix for pr6543 yesterday reenabled it, but broke the ARM port's code for using TBB/TBH. Rather than adding a target hook to disable merging for Thumb2 only, I'm just taking this out. It is not common to have identical jump tables, the code we used to merge them was O(N^2), and it only helps code size, not performance. llvm-svn: 98977
2010-03-16Remove a check that can no longer be true, after r84803.Bob Wilson1-16/+0
llvm-svn: 98694
2010-03-14eliminate InvalidateLabel and LabelIDList from MMI and replaceChris Lattner1-11/+0
them with a counter. llvm-svn: 98462
2010-03-10Fix another place where DEBUG_VALUE affected codegen.Dale Johannesen1-1/+12
llvm-svn: 98181
2010-03-10This survived a bootstrap, so let's try 98104 again.Dale Johannesen1-4/+69
llvm-svn: 98137
2010-03-10Speculatively revert 98104; could be what's causing crashesDale Johannesen1-56/+3
llvm-svn: 98108
2010-03-09Ever more complicated DEBUG_VALUE fixes for branch folding.Dale Johannesen1-3/+56
llvm-svn: 98104
2010-03-08Fix dbg value handling in tail merging.Dale Johannesen1-3/+25
llvm-svn: 97938
2010-03-05Fix some more places where dbg_value affected codegen.Dale Johannesen1-1/+5
llvm-svn: 97765
2010-02-09move target-independent opcodes out of TargetInstrInfoChris Lattner1-2/+2
into TargetOpcodes.h. #include the new TargetOpcodes.h into MachineInstr. Add new inline accessors (like isPHI()) to MachineInstr, and start using them throughout the codebase. llvm-svn: 95687
2010-01-25Rearrange handling of jump tables. Highlights:Chris Lattner1-44/+49
1. MachineJumpTableInfo is now created lazily for a function the first time it actually makes a jump table instead of for every function. 2. The encoding of jump table entries is now described by the MachineJumpTableInfo::JTEntryKind enum. This enum is determined by the TLI::getJumpTableEncoding() hook, instead of by lots of code scattered throughout the compiler that "knows" that jump table entries are always 32-bits in pic mode (for example). 3. The size and alignment of jump table entries is now calculated based on their kind, instead of at machinefunction creation time. Future work includes using the EntryKind in more places in the compiler, eliminating other logic that "knows" the layout of jump tables in various situations. llvm-svn: 94470
2009-12-24Change errs() to dbgs().David Greene1-13/+13
llvm-svn: 92097
2009-12-16Initialize uninitialized variables.Bill Wendling1-1/+1
llvm-svn: 91477
2009-12-16Initialize uninitialized variables.Bill Wendling1-1/+1
llvm-svn: 91475
2009-12-15Revert these. They may have been causing 483_xalancbmk to fail:Bill Wendling1-23/+19
$ svn merge -c -91161 https://llvm.org/svn/llvm-project/llvm/trunk --- Reverse-merging r91161 into '.': U lib/CodeGen/BranchFolding.cpp U lib/CodeGen/MachineBasicBlock.cpp $ svn merge -c -91113 https://llvm.org/svn/llvm-project/llvm/trunk --- Reverse-merging r91113 into '.': G lib/CodeGen/MachineBasicBlock.cpp $ svn merge -c -91101 https://llvm.org/svn/llvm-project/llvm/trunk --- Reverse-merging r91101 into '.': U include/llvm/CodeGen/MachineBasicBlock.h G lib/CodeGen/MachineBasicBlock.cpp $ svn merge -c -91092 https://llvm.org/svn/llvm-project/llvm/trunk --- Reverse-merging r91092 into '.': G include/llvm/CodeGen/MachineBasicBlock.h G lib/CodeGen/MachineBasicBlock.cpp llvm-svn: 91376
2009-12-11Don't try to move a MBB into the fall-through position if it's a landing pad orBill Wendling1-19/+23
branches only to a landing pad. Without this check, the compiler would go into an infinite loop because the branch to a landing pad is an "abnormal" edge which wasn't being taken into account. This is the meat of that fix: if (!PrevBB.canFallThrough() && !MBB->BranchesToLandingPad(MBB)) { The other stuff is simplification of the "branches to a landing pad" code. llvm-svn: 91161
2009-12-05Remove the target hook TargetInstrInfo::BlockHasNoFallThrough in favor ofDan Gohman1-1/+1
MachineBasicBlock::canFallThrough(), which is target-independent and more thorough. llvm-svn: 90634
2009-12-03improve portability to avoid conflicting with std::next in c++'0x.Chris Lattner1-4/+4
Patch by Howard Hinnant! llvm-svn: 90365
2009-11-26Split tail duplication into a separate pass. This is needed to avoidBob Wilson1-231/+6
running tail duplication when doing branch folding for if-conversion, and we also want to be able to run tail duplication earlier to fix some reg alloc problems. Move the CanFallThrough function from BranchFolding to MachineBasicBlock so that it can be shared by TailDuplication. llvm-svn: 89904
2009-11-24Refactor target hook for tail duplication as requested by Chris.Bob Wilson1-3/+12
Make tail duplication of indirect branches much more aggressive (for targets that indicate that it is profitable), based on further experience with this transformation. I compiled 3 large applications with and without this more aggressive tail duplication and measured minimal changes in code size. ("size" on Darwin seems to round the text size up to the nearest page boundary, so I can only say that any code size increase was less than one 4k page.) Radar 7421267. llvm-svn: 89814
2009-11-18There should be no need to keep renumbering blocks during tail duplication.Bob Wilson1-3/+0
llvm-svn: 89275
2009-11-18Tail duplication still needs to iterate. Duplicating new instructions ontoBob Wilson1-3/+7
the tail of a block may make that block a new candidate for duplication. llvm-svn: 89264
2009-11-18Add another statistic to measure code size due to tail duplication.Bob Wilson1-0/+3
llvm-svn: 89254
2009-11-18Add statistics for tail duplication.Bob Wilson1-0/+4
llvm-svn: 89225
2009-11-18Add a target hook to allow changing the tail duplication limit based on theBob Wilson1-4/+5
contents of the block to be duplicated. Use this for ARM Cortex A8/9 to be more aggressive tail duplicating indirect branches, since it makes it much more likely that they will be predicted in the branch target buffer. Testcase coming soon. llvm-svn: 89187
2009-11-17Remove a special case for tail merging that seems to be both broken andBob Wilson1-33/+0
unnecessary. It is broken because the "isIdenticalTo" check should be negated. If that is fixed, this code causes the CodeGen/X86/tail-opts.ll test to fail, in the dont_merge_oddly function. And, I confirmed that the regression is real -- the generated code is worse. As far as I can tell, that tail-opts.ll test is checking for what this code is supposed to handle and we're doing the right thing anyway. llvm-svn: 89121
2009-11-17Set MadeChange instead of MadeChangeThisIteration.Dan Gohman1-1/+1
llvm-svn: 89114
2009-11-17Update a comment, now that tail duplication happens after other branchBob Wilson1-2/+2
folding optimizations. llvm-svn: 89109
2009-11-17Perform tail duplication only once, after tail merging is complete.Bob Wilson1-30/+66
It was too difficult to keep the heuristics for merging and duplication consistent. llvm-svn: 89105
2009-11-16Fix a comment.Bob Wilson1-1/+1
llvm-svn: 88940
2009-11-16Fix some comments.Bob Wilson1-5/+4
llvm-svn: 88932
2009-11-16Whitespace: be consistent with pointer syntax.Bob Wilson1-6/+6
llvm-svn: 88929
2009-11-16Clean up whitespace.Bob Wilson1-6/+6
llvm-svn: 88927
2009-11-13When optimizing for size, don't tail-merge unless it's likely to be aDan Gohman1-9/+12
code-size win, and not when it's only likely to be code-size neutral, such as when only a single instruction would be eliminated and a new branch would be required. This fixes rdar://7392894. llvm-svn: 88692
2009-11-12Make the BranchFolderPass class local to BranchFolding.cpp.Dan Gohman1-0/+14
llvm-svn: 86928
2009-11-12Minor code cleanups.Dan Gohman1-9/+9
llvm-svn: 86926
2009-11-12Tail merge at any size when there are two potentials blocks and oneDan Gohman1-10/+34
can be made to fall through into the other. llvm-svn: 86909
2009-11-11Promote MergePotentialsElt and SameTailElt to be regular classesDan Gohman1-56/+58
instead of typedefs for std::pair. This simplifies the type of SameTails, which previously was std::vector<std::pair<std::vector<std::pair<unsigned, MachineBasicBlock *> >::iterator, MachineBasicBlock::iterator> llvm-svn: 86885
2009-11-11Revert this line of 86871.Dan Gohman1-1/+1
llvm-svn: 86875
2009-11-11Add support for tail duplication to BranchFolding, and extendDan Gohman1-49/+295
tail merging support to handle more cases. - Recognize several cases where tail merging is beneficial even when the tail size is smaller than the generic threshold. - Make use of MachineInstrDesc::isBarrier to help detect non-fallthrough blocks. - Check for and avoid disrupting fall-through edges in more cases. llvm-svn: 86871
2009-11-11Fix indentation level.Dan Gohman1-8/+8
llvm-svn: 86856
2009-11-11Whitespace cleanups.Dan Gohman1-93/+92
llvm-svn: 86855