summaryrefslogtreecommitdiff
path: root/lib/CodeGen/BranchFolding.cpp
Commit message (Collapse)AuthorAge
* Fix liveness computations in BranchFolding.Jakob Stoklund Olesen2011-08-05
| | | | | | | | | | | | | | | | | | | | | | | The old code would look at kills and defs in one pass over the instruction operands, causing problems with this code: %R0<def>, %CPSR<def,dead> = tLSLri %R5<kill>, 2, pred:14, pred:%noreg %R0<def>, %CPSR<def,dead> = tADDrr %R4<kill>, %R0<kill>, pred:14, %pred:%noreg The last instruction kills and redefines %R0, so it is still live after the instruction. This caused a register scavenger crash when compiling 483.xalancbmk for armv6. I am not including a test case because it requires too much bad luck to expose this old bug. First you need to convince the register allocator to use %R0 twice on the tADDrr instruction, then you have to convince BranchFolding to do something that causes it to run the register scavenger on he bad block. <rdar://problem/9898200> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136973 91177308-0d34-0410-b5e6-96231b3b80d8
* When tail-merging multiple blocks, make sure to correctly update the live-in ↵Eli Friedman2011-07-06
| | | | | | | | | | | | list on the merged block to correctly account for the live-outs of all the predecessors. They might not be the same in all cases (the testcase I have involves a PHI node where one of the operands is an IMPLICIT_DEF). Unfortunately, the testcase I have is large and confidential, so I don't have a test to commit at the moment; I'll see if I can come up with something smaller where this issue reproduces. <rdar://problem/9716278> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134565 91177308-0d34-0410-b5e6-96231b3b80d8
* - Rename TargetInstrDesc, TargetOperandInfo to MCInstrDesc and MCOperandInfo andEvan Cheng2011-06-28
| | | | | | | | | sink them into MC layer. - Added MCInstrInfo, which captures the tablegen generated static data. Chang TargetInstrInfo so it's based off MCInstrInfo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134021 91177308-0d34-0410-b5e6-96231b3b80d8
* Add 132986 back, but avoid non-determinism if a bb address gets reused.Rafael Espindola2011-06-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132995 91177308-0d34-0410-b5e6-96231b3b80d8
* revert 132986 to see if the bots go green.Rafael Espindola2011-06-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132988 91177308-0d34-0410-b5e6-96231b3b80d8
* Make the threshold used by branch folding softer. Before we would get aRafael Espindola2011-06-14
| | | | | | | sharp all or nothing transition when one extra predecessor was added. Now we still test first ones for merging. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132974 91177308-0d34-0410-b5e6-96231b3b80d8
* Add comment.Devang Patel2011-05-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132149 91177308-0d34-0410-b5e6-96231b3b80d8
* During branch folding avoid inserting redundant DBG_VALUE machine instructions.Devang Patel2011-05-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132148 91177308-0d34-0410-b5e6-96231b3b80d8
* Update comment.Evan Cheng2011-05-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131258 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-enable branchfolding common code hoisting optimization. Fixed a liveness ↵Evan Cheng2011-05-12
| | | | | | test bug and also taught it to update liveins. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131241 91177308-0d34-0410-b5e6-96231b3b80d8
* Temporarily disable the transformation. It's breaking 186.crafty in some ↵Evan Cheng2011-05-12
| | | | | | configuration. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131235 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-commit 131172 with fix. MachineInstr identity checks should check deadEvan Cheng2011-05-12
| | | | | | | | | | markers. In some cases a register def is dead on one path, but not on another. This is passing Clang self-hosting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131214 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert 131172 as it is causing clang to miscompile itself. I will tryRafael Espindola2011-05-11
| | | | | | to provide a reduced testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131176 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a late optimization to BranchFolding that hoist common instruction sequencesEvan Cheng2011-05-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | at the start of basic blocks to their common predecessor. It's actually quite common (e.g. about 50 times in JM/lencod) and has shown to be a nice code size benefit. e.g. pushq %rax testl %edi, %edi jne LBB0_2 ## BB#1: xorb %al, %al popq %rdx ret LBB0_2: xorb %al, %al callq _foo popq %rdx ret => pushq %rax xorb %al, %al testl %edi, %edi je LBB0_2 ## BB#1: callq _foo LBB0_2: popq %rdx ret rdar://9145558 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131172 91177308-0d34-0410-b5e6-96231b3b80d8
* Branch folding is folding a landing pad into a regular BB.Bill Wendling2011-04-22
| | | | | | | | | | | | | | | | An exception is thrown via a call to _cxa_throw, which we don't expect to return. Therefore, the "true" part of the invoke goes to a BB that has 'unreachable' as its only instruction. This is lowered into an empty MachineBB. The landing pad for this invoke, however, is directly after the "true" MBB. When the empty MBB is removed, the landing pad is directly below the BB with the invoke call. The unconditional branch is removed and then the two blocks are merged together. The testcase is too big for a regression test. <rdar://problem/9305728> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129965 91177308-0d34-0410-b5e6-96231b3b80d8
* Add more debugging output.Evan Cheng2011-02-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126158 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r110396, with fixes to appease the Linux buildbot gods.Owen Anderson2010-08-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110460 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r110396 to fix buildbots.Owen Anderson2010-08-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110410 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't use PassInfo* as a type identifier for passes. Instead, use the ↵Owen Anderson2010-08-05
| | | | | | | | | address of the static ID member as the sole unique type identifier. Clean up APIs related to this change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110396 91177308-0d34-0410-b5e6-96231b3b80d8
* Tail merging pass shall not break up IT blocks. rdar://8115404Evan Cheng2010-06-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106517 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow ARM if-converter to be run after post allocation scheduling.Evan Cheng2010-06-18
| | | | | | | | | | | | | | | | | - 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106344 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a DebugLoc parameter to TargetInstrInfo::InsertBranch(). ThisStuart Hastings2010-06-17
| | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106243 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug which prevented tail merging of return instructions inDan Gohman2010-05-03
| | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102907 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach AnalyzeBranch, RemoveBranch and the branchDale Johannesen2010-04-02
| | | | | | | | | folder to be tolerant of debug info following the branch(es) at the end of a block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100168 91177308-0d34-0410-b5e6-96231b3b80d8
* Stop trying to merge identical jump tables. This had been inadvertentlyBob Wilson2010-03-19
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98977 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove a check that can no longer be true, after r84803.Bob Wilson2010-03-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98694 91177308-0d34-0410-b5e6-96231b3b80d8
* eliminate InvalidateLabel and LabelIDList from MMI and replaceChris Lattner2010-03-14
| | | | | | | them with a counter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98462 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix another place where DEBUG_VALUE affected codegen.Dale Johannesen2010-03-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98181 91177308-0d34-0410-b5e6-96231b3b80d8
* This survived a bootstrap, so let's try 98104 again.Dale Johannesen2010-03-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98137 91177308-0d34-0410-b5e6-96231b3b80d8
* Speculatively revert 98104; could be what's causing crashesDale Johannesen2010-03-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98108 91177308-0d34-0410-b5e6-96231b3b80d8
* Ever more complicated DEBUG_VALUE fixes for branch folding.Dale Johannesen2010-03-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98104 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix dbg value handling in tail merging.Dale Johannesen2010-03-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97938 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix some more places where dbg_value affected codegen.Dale Johannesen2010-03-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97765 91177308-0d34-0410-b5e6-96231b3b80d8
* move target-independent opcodes out of TargetInstrInfoChris Lattner2010-02-09
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95687 91177308-0d34-0410-b5e6-96231b3b80d8
* Rearrange handling of jump tables. Highlights:Chris Lattner2010-01-25
| | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94470 91177308-0d34-0410-b5e6-96231b3b80d8
* Change errs() to dbgs().David Greene2009-12-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92097 91177308-0d34-0410-b5e6-96231b3b80d8
* Initialize uninitialized variables.Bill Wendling2009-12-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91477 91177308-0d34-0410-b5e6-96231b3b80d8
* Initialize uninitialized variables.Bill Wendling2009-12-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91475 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert these. They may have been causing 483_xalancbmk to fail:Bill Wendling2009-12-15
| | | | | | | | | | | | | | | | | | | | | | $ 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91376 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't try to move a MBB into the fall-through position if it's a landing pad orBill Wendling2009-12-11
| | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91161 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the target hook TargetInstrInfo::BlockHasNoFallThrough in favor ofDan Gohman2009-12-05
| | | | | | | | MachineBasicBlock::canFallThrough(), which is target-independent and more thorough. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90634 91177308-0d34-0410-b5e6-96231b3b80d8
* improve portability to avoid conflicting with std::next in c++'0x.Chris Lattner2009-12-03
| | | | | | | Patch by Howard Hinnant! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90365 91177308-0d34-0410-b5e6-96231b3b80d8
* Split tail duplication into a separate pass. This is needed to avoidBob Wilson2009-11-26
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89904 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor target hook for tail duplication as requested by Chris.Bob Wilson2009-11-24
| | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89814 91177308-0d34-0410-b5e6-96231b3b80d8
* There should be no need to keep renumbering blocks during tail duplication.Bob Wilson2009-11-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89275 91177308-0d34-0410-b5e6-96231b3b80d8
* Tail duplication still needs to iterate. Duplicating new instructions ontoBob Wilson2009-11-18
| | | | | | | the tail of a block may make that block a new candidate for duplication. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89264 91177308-0d34-0410-b5e6-96231b3b80d8
* Add another statistic to measure code size due to tail duplication.Bob Wilson2009-11-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89254 91177308-0d34-0410-b5e6-96231b3b80d8
* Add statistics for tail duplication.Bob Wilson2009-11-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89225 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a target hook to allow changing the tail duplication limit based on theBob Wilson2009-11-18
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89187 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove a special case for tail merging that seems to be both broken andBob Wilson2009-11-17
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89121 91177308-0d34-0410-b5e6-96231b3b80d8