summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/BranchFolding.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Rearrange handling of jump tables. Highlights:Chris Lattner2010-01-251-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
* Change errs() to dbgs().David Greene2009-12-241-13/+13
| | | | llvm-svn: 92097
* Initialize uninitialized variables.Bill Wendling2009-12-161-1/+1
| | | | llvm-svn: 91477
* Initialize uninitialized variables.Bill Wendling2009-12-161-1/+1
| | | | llvm-svn: 91475
* Revert these. They may have been causing 483_xalancbmk to fail:Bill Wendling2009-12-151-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
* Don't try to move a MBB into the fall-through position if it's a landing pad orBill Wendling2009-12-111-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
* Remove the target hook TargetInstrInfo::BlockHasNoFallThrough in favor ofDan Gohman2009-12-051-1/+1
| | | | | | | MachineBasicBlock::canFallThrough(), which is target-independent and more thorough. llvm-svn: 90634
* improve portability to avoid conflicting with std::next in c++'0x.Chris Lattner2009-12-031-4/+4
| | | | | | Patch by Howard Hinnant! llvm-svn: 90365
* Split tail duplication into a separate pass. This is needed to avoidBob Wilson2009-11-261-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
* Refactor target hook for tail duplication as requested by Chris.Bob Wilson2009-11-241-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
* There should be no need to keep renumbering blocks during tail duplication.Bob Wilson2009-11-181-3/+0
| | | | llvm-svn: 89275
* Tail duplication still needs to iterate. Duplicating new instructions ontoBob Wilson2009-11-181-3/+7
| | | | | | the tail of a block may make that block a new candidate for duplication. llvm-svn: 89264
* Add another statistic to measure code size due to tail duplication.Bob Wilson2009-11-181-0/+3
| | | | llvm-svn: 89254
* Add statistics for tail duplication.Bob Wilson2009-11-181-0/+4
| | | | llvm-svn: 89225
* Add a target hook to allow changing the tail duplication limit based on theBob Wilson2009-11-181-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
* Remove a special case for tail merging that seems to be both broken andBob Wilson2009-11-171-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
* Set MadeChange instead of MadeChangeThisIteration.Dan Gohman2009-11-171-1/+1
| | | | llvm-svn: 89114
* Update a comment, now that tail duplication happens after other branchBob Wilson2009-11-171-2/+2
| | | | | | folding optimizations. llvm-svn: 89109
* Perform tail duplication only once, after tail merging is complete.Bob Wilson2009-11-171-30/+66
| | | | | | | It was too difficult to keep the heuristics for merging and duplication consistent. llvm-svn: 89105
* Fix a comment.Bob Wilson2009-11-161-1/+1
| | | | llvm-svn: 88940
* Fix some comments.Bob Wilson2009-11-161-5/+4
| | | | llvm-svn: 88932
* Whitespace: be consistent with pointer syntax.Bob Wilson2009-11-161-6/+6
| | | | llvm-svn: 88929
* Clean up whitespace.Bob Wilson2009-11-161-6/+6
| | | | llvm-svn: 88927
* When optimizing for size, don't tail-merge unless it's likely to be aDan Gohman2009-11-131-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
* Make the BranchFolderPass class local to BranchFolding.cpp.Dan Gohman2009-11-121-0/+14
| | | | llvm-svn: 86928
* Minor code cleanups.Dan Gohman2009-11-121-9/+9
| | | | llvm-svn: 86926
* Tail merge at any size when there are two potentials blocks and oneDan Gohman2009-11-121-10/+34
| | | | | | can be made to fall through into the other. llvm-svn: 86909
* Promote MergePotentialsElt and SameTailElt to be regular classesDan Gohman2009-11-111-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
* Revert this line of 86871.Dan Gohman2009-11-111-1/+1
| | | | llvm-svn: 86875
* Add support for tail duplication to BranchFolding, and extendDan Gohman2009-11-111-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
* Fix indentation level.Dan Gohman2009-11-111-8/+8
| | | | llvm-svn: 86856
* Whitespace cleanups.Dan Gohman2009-11-111-93/+92
| | | | llvm-svn: 86855
* Prefix MBB numbers with "BB#" in debug output to make it clear whatDan Gohman2009-11-111-3/+3
| | | | | | the numbers mean. llvm-svn: 86854
* Minor code simplification.Dan Gohman2009-11-111-9/+8
| | | | llvm-svn: 86853
* Remove an unused variable.Dan Gohman2009-11-101-1/+0
| | | | llvm-svn: 86642
* Minor code simplification.Dan Gohman2009-11-101-1/+1
| | | | llvm-svn: 86641
* Fix branch folding bug for indirect branches: for a block containing onlyBob Wilson2009-11-031-1/+2
| | | | | | | | | | | | | | | an unconditional branch (possibly from tail merging), this code is trying to redirect all of its predecessors to go directly to the branch target, but that isn't feasible for indirect branches. The other predecessors (that don't end with indirect branches) could theoretically still be handled, but that is not easily done right now. The AnalyzeBranch interface doesn't currently let us distinguish jump table branches from indirect branches, and this code is currently handling jump tables. To avoid punting on address-taken blocks, we would have to give up handling jump tables. That seems like a bad tradeoff. llvm-svn: 85975
* Don't delete blocks which have their address taken.Dan Gohman2009-10-301-2/+3
| | | | llvm-svn: 85572
* Refactor complicated predicate into a separate function.Bob Wilson2009-10-291-17/+33
| | | | llvm-svn: 85519
* Reimplement BranchFolding change to avoid tail merging for a 1 instructionBob Wilson2009-10-281-13/+15
| | | | | | | common tail, except when the OptimizeForSize function attribute is present. Radar 7338114. llvm-svn: 85441
* Revert r85346 change to control tail merging by CodeGenOpt::Level.Bob Wilson2009-10-281-9/+5
| | | | | | I'm going to redo this using the OptimizeForSize function attribute. llvm-svn: 85426
* Record CodeGen optimization level in the BranchFolding pass so that we canBob Wilson2009-10-271-5/+9
| | | | | | | | | | | | | | | | use it to control tail merging when there is a tradeoff between performance and code size. When there is only 1 instruction in the common tail, we have been merging. That can be good for code size but is a definite loss for performance. Now we will avoid tail merging in that case when the optimization level is "Aggressive", i.e., "-O3". Radar 7338114. Since the IfConversion pass invokes BranchFolding, it too needs to know the optimization level. Note that I removed the RegisterPass instantiation for IfConversion because it required a default constructor. If someone wants to keep that for some reason, we can add a default constructor with a hard-wired optimization level. llvm-svn: 85346
* Revert the main portion of r31856. It was causing BranchFoldingDan Gohman2009-10-221-5/+5
| | | | | | | | | | | | to break up CFG diamonds by banishing one of the blocks to the end of the function, which is bad for code density and branch size. This does pessimize MultiSource/Benchmarks/Ptrdist/yacr2, the benchmark cited as the reason for the change, however I've examined the code and it looks more like a case of gaming a particular branch than of being generally applicable. llvm-svn: 84803
* Run branch folding if if-converter make some transformations.Evan Cheng2009-09-041-84/+63
| | | | llvm-svn: 80994
* Funky indentation.Evan Cheng2009-09-031-1/+2
| | | | llvm-svn: 80971
* Convert DOUT to DEBUG(errs()...).Bill Wendling2009-08-221-9/+10
| | | | llvm-svn: 79747
* Make tail merging handle blocks with repeated predecessors correctly, andDan Gohman2009-08-181-25/+4
| | | | | | | | | | | | | | | | | | | | remove RemoveDuplicateSuccessor, as it is no longer necessary, and because it breaks assumptions made in MachineBasicBlock::isOnlyReachableByFallthrough. Convert test/CodeGen/X86/omit-label.ll to FileCheck and add a testcase for PR4732. test/CodeGen/Thumb2/thumb2-ifcvt2.ll sees a diff with this commit due to it being bugpoint-reduced to the point where it doesn't matter what the condition for the branch is. Add some more interesting code to test/CodeGen/X86/2009-08-06-branchfolder-crash.ll, which is the testcase that originally motivated the RemoveDuplicateSuccessor code, to help verify that the original problem isn't being re-broken. llvm-svn: 79338
* Rewrite previous patch to follow Chris' stylisticDale Johannesen2009-08-071-14/+22
| | | | | | preference; no functional change. llvm-svn: 78391
* Fix PR 4626, a crash in branch folding after OptimizeBlockDale Johannesen2009-08-061-1/+17
| | | | | | produced a CFG it wasn't prepared for. llvm-svn: 78351
* llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.Torok Edwin2009-07-141-1/+1
| | | | | | | | | This adds location info for all llvm_unreachable calls (which is a macro now) in !NDEBUG builds. In NDEBUG builds location info and the message is off (it only prints "UREACHABLE executed"). llvm-svn: 75640
OpenPOWER on IntegriCloud