aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
AgeCommit message (Collapse)AuthorFilesLines
2012-11-20Fix physical register liveness calculations:Tim Northover1-6/+9
+ Take account of clobbers + Give outputs priority over inputs since they happen later. llvm-svn: 168360
2012-10-26Make sure I is not the end iterator when isInsideBundle is called. Akira Hatanaka1-2/+3
llvm-svn: 166784
2012-10-08Move TargetData to DataLayout.Micah Villmow1-1/+1
llvm-svn: 165402
2012-09-12Add a function computeRegisterLiveness() to MachineBasicBlock. This uses ↵James Molloy1-0/+74
analyzePhysReg() from r163694 to heuristically try and determine the liveness state of a physical register upon arrival at a particular instruction in a block. The search for liveness is clipped to a specific number of instructions around the target MachineInstr, in order to avoid degenerating into an O(N^2) algorithm. It tries to use various clues about how instructions around (both before and after) a given MachineInstr use that register, to determine its state at the MachineInstr. llvm-svn: 163695
2012-09-11Release build: guard dump functions withManman Ren1-1/+1
"#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)" No functional change. Update r163339. llvm-svn: 163653
2012-09-06Release build: guard dump functions with "ifndef NDEBUG"Manman Ren1-0/+2
No functional change. llvm-svn: 163339
2012-08-22Add a getName function to MachineFunction. Use it in places that previously ↵Craig Topper1-1/+1
did getFunction()->getName(). Remove includes of Function.h that are no longer needed. llvm-svn: 162347
2012-08-20Fix a quadratic algorithm in MachineBranchProbabilityInfo.Jakob Stoklund Olesen1-3/+2
The getSumForBlock function was quadratic in the number of successors because getSuccWeight would perform a linear search for an already known iterator. This patch was originally committed as r161460, but reverted again because of assertion failures. Now that duplicate Machine CFG edges have been eliminated, this works properly. llvm-svn: 162233
2012-08-13Transfer weights in transferSuccessorsAndUpdatePHIs().Jakob Stoklund Olesen1-5/+7
llvm-svn: 161805
2012-08-13Print out MachineBasicBlock successor weights when available.Jakob Stoklund Olesen1-1/+4
llvm-svn: 161804
2012-08-10Update edge weights correctly in replaceSuccessor().Jakob Stoklund Olesen1-9/+33
When replacing Old with New, it can happen that New is already a successor. Add the old and new edge weights instead of creating a duplicate edge. llvm-svn: 161653
2012-08-09Move use list management into MachineRegisterInfo.Jakob Stoklund Olesen1-1/+2
Register MachineOperands are kept in linked lists accessible via MRI's reg_iterator interfaces. The linked list management was handled partly by MachineOperand methods, partly by MRI methods. Move all of the list management into MRI, delete MO::AddRegOperandToRegInfo() and MO::RemoveRegOperandFromRegInfo(). Be more explicit about handling the cases where an MRI pointer isn't available. llvm-svn: 161632
2012-08-08Revert "Fix a quadratic algorithm in MachineBranchProbabilityInfo."Jakob Stoklund Olesen1-2/+3
It caused an assertion failure when compiling consumer-typeset. llvm-svn: 161463
2012-08-08Fix a quadratic algorithm in MachineBranchProbabilityInfo.Jakob Stoklund Olesen1-3/+2
The getSumForBlock function was quadratic in the number of successors because getSuccWeight would perform a linear search for an already known iterator. llvm-svn: 161460
2012-07-30Add MachineBasicBlock::isPredecessor().Jakob Stoklund Olesen1-2/+5
A->isPredecessor(B) is the same as B->isSuccessor(A), but it can tolerate a B that is null or dangling. This shouldn't happen normally, but it it useful for verification code. llvm-svn: 160968
2012-07-19Remove tabs.Bill Wendling1-1/+1
llvm-svn: 160475
2012-06-15Remove assignments which aren't used afterwards.Bill Wendling1-3/+1
llvm-svn: 158535
2012-04-24MachineBasicBlock::SplitCriticalEdge() should follow LLVM IR variant and ↵Evan Cheng1-0/+5
refuse to break edge to EH landing pad. rdar://11300144 llvm-svn: 155470
2012-04-16Fix updateTerminator to be resiliant to degenerate terminators whereChandler Carruth1-7/+29
both fallthrough and a conditional branch target the same successor. Gracefully delete the conditional branch and introduce any unconditional branch needed to reach the actual successor. This fixes memory corruption in 2009-06-15-RegScavengerAssert.ll and possibly other tests. Also, while I'm here fix a latent bug I spotted by inspection. I never applied the same fundamental fix to this fallthrough successor finding logic that I did to the logic used when there are no conditional branches. As a consequence it would have selected landing pads had they be aligned in just the right way here. I don't have a test case as I spotted this by inspection, and the previous time I found this required have of TableGen's source code to produce it. =/ I hate backend bugs. ;] Thanks to Jim Grosbach for helping me reason through this and reviewing the fix. llvm-svn: 154867
2012-03-28Allow removeLiveIn to be called with a register that isn't live-in.Jakob Stoklund Olesen1-2/+2
This avoids the silly double search: if (isLiveIn(Reg)) removeLiveIn(Reg); llvm-svn: 153592
2012-03-07Added MachineBasicBlock::getFullName() to standardize/factor codegen ↵Andrew Trick1-0/+12
diagnostics. llvm-svn: 152176
2012-02-10Cache iterators. Some of these are expensive to create.Benjamin Kramer1-14/+16
llvm-svn: 150214
2012-02-09Preserve physreg kills in MachineBasicBlock::SplitCriticalEdge.Lang Hames1-4/+7
Failure to preserve kills was causing LiveIntervals to miss some EFLAGS live ranges. Unfortunately I've been unable to reduce a good test case yet. llvm-svn: 150152
2012-01-26Update comment for r149070.Chad Rosier1-3/+1
llvm-svn: 149075
2012-01-26Replace the use of isPredicable() with isPredicated() inChad Rosier1-3/+2
MachineBasicBlock::canFallThrough(). We're interested in the state of the instruction (i.e., is this a barrier or not?), not if the instruction is predicable or not. rdar://10501092 llvm-svn: 149070
2011-12-20Add some constantness to BranchProbabilityInfo and BlockFrequnencyInfo.Jakub Staszak1-2/+12
llvm-svn: 146986
2011-12-14- Add MachineInstrBundle.h and MachineInstrBundle.cpp. This includes a functionEvan Cheng1-20/+58
to finalize MI bundles (i.e. add BUNDLE instruction and computing register def and use lists of the BUNDLE instruction) and a pass to unpack bundles. - Teach more of MachineBasic and MachineInstr methods to be bundle aware. - Switch Thumb2 IT block to MI bundles and delete the hazard recognizer hack to prevent IT blocks from being broken apart. llvm-svn: 146542
2011-12-07Add bundle aware API for querying instruction properties and switch the codeEvan Cheng1-3/+3
generator to it. For non-bundle instructions, these behave exactly the same as the MC layer API. For properties like mayLoad / mayStore, look into the bundle and if any of the bundled instructions has the property it would return true. For properties like isPredicable, only return true if *all* of the bundled instructions have the property. For properties like canFoldAsLoad, isCompare, conservatively return false for bundles. llvm-svn: 146026
2011-12-06First chunk of MachineInstr bundle support.Evan Cheng1-26/+69
1. Added opcode BUNDLE 2. Taught MachineInstr class to deal with bundled MIs 3. Changed MachineBasicBlock iterator to skip over bundled MIs; added an iterator to walk all the MIs 4. Taught MachineBasicBlock methods about bundled MIs llvm-svn: 145975
2011-12-06Pretty-print basic block alignment.Jakob Stoklund Olesen1-2/+6
llvm-svn: 145965
2011-11-23Handle the case of a no-return invoke correctly. It actually still hasChandler Carruth1-0/+8
successors, they just are all landing pad successors. We handle this the same way as no successors. Comments attached for the next person to wade through here and another lovely test case courtesy of Benjamin Kramer's bugpoint reduction. llvm-svn: 145098
2011-11-22Fix a devilish miscompile exposed by block placement. TheChandler Carruth1-2/+8
updateTerminator code didn't correctly handle EH terminators in one very specific case. AnalyzeBranch would find no terminator instruction, and so the fallback in updateTerminator is to assume fallthrough. This is correct, but the destination of the fallthrough was assumed to be the first successor. This is *almost always* true, but in certain cases the loop transformations will cause the landing pad to be the first successor! Instead of this brittle logic, actually look through the successors for a non-landing-pad accessor, and to assert if more than one is found. This will hopefully fix some (if not all) of the self host miscompiles with block placement. Thanks to Benjamin Kramer for reporting, Nick Lewycky for an initial stab at a reduction, and Duncan for endless advice on EH (which I know nothing about) as well as reviewing the actual fix. llvm-svn: 145062
2011-10-14Update live-in lists when splitting critical edges.Jakob Stoklund Olesen1-0/+5
Fixes PR10814. Patch by Jan Sjödin! llvm-svn: 141960
2011-06-28- Rename TargetInstrDesc, TargetOperandInfo to MCInstrDesc and MCOperandInfo andEvan Cheng1-1/+0
sink them into MC layer. - Added MCInstrInfo, which captures the tablegen generated static data. Chang TargetInstrInfo so it's based off MCInstrInfo. llvm-svn: 134021
2011-06-17getSuccWeight returns now default 0 if Weights vector is empty.Jakub Staszak1-2/+4
llvm-svn: 133271
2011-06-17Allow empty Weights vector.Jakub Staszak1-1/+2
llvm-svn: 133265
2011-06-16Introduce MachineBranchProbabilityInfo class, which has similar API toJakub Staszak1-7/+69
BranchProbabilityInfo (expect setEdgeWeight which is not available here). Branch Weights are kept in MachineBasicBlocks. To turn off this analysis set -use-mbpi=false. llvm-svn: 133184
2011-06-16Test commit.Jakub Staszak1-7/+7
llvm-svn: 133174
2011-05-29Fix PR10046 by updating LiveVariables kill info when splitting live ranges.Jakob Stoklund Olesen1-2/+39
This only affects targets like Mips where branch instructions may kill virtual registers. Most other targets branch on flag values, so virtual registers are not involved. The problem is that MachineBasicBlock::updateTerminator deletes branches and inserts new ones while LiveVariables keeps a list of pointers to instructions that kill virtual registers. That list wasn't properly updated in MBB::SplitCriticalEdge. llvm-svn: 132298
2011-04-18Simplify declarations slightly by using typedefs.Eli Friedman1-4/+2
llvm-svn: 129720
2011-02-04Add LiveIntervals::getLastSplitPoint().Jakob Stoklund Olesen1-0/+10
A live range cannot be split everywhere in a basic block. A split must go before the first terminator, and if the variable is live into a landing pad, the split must happen before the call that can throw. llvm-svn: 124894
2011-01-14Try for the third time to teach getFirstTerminator() about debug values.Jakob Stoklund Olesen1-2/+3
This time let's rephrase to trick gcc-4.3 into not miscompiling. llvm-svn: 123432
2011-01-14Revert r123419. It still breaks llvm-gcc-i386-linux-selfhost.Jakob Stoklund Olesen1-16/+5
llvm-svn: 123423
2011-01-14Try again to teach getFirstTerminator() about debug values.Jakob Stoklund Olesen1-5/+16
Fix some callers to better deal with debug values. llvm-svn: 123419
2011-01-13Teach frame lowering to ignore debug values after the terminators.Jakob Stoklund Olesen1-0/+12
llvm-svn: 123399
2011-01-13Speculatively revert r123384 to make llvm-gcc-i386-linux-selfhost buildbot ↵Devang Patel1-16/+5
happy. llvm-svn: 123389
2011-01-13Teach MachineBasicBlock::getFirstTerminator to ignore debug values.Jakob Stoklund Olesen1-5/+16
It will still return an iterator that points to the first terminator or end(), but there may be DBG_VALUE instructions following the first terminator. llvm-svn: 123384
2011-01-13Add missing space in debug outputJakob Stoklund Olesen1-1/+1
llvm-svn: 123351
2011-01-09Replace TargetRegisterInfo::printReg with a PrintReg class that also works ↵Jakob Stoklund Olesen1-12/+1
without a TRI instance. Print virtual registers numbered from 0 instead of the arbitrary FirstVirtualRegister. The first virtual register is printed as %vreg0. TRI::NoRegister is printed as %noreg. llvm-svn: 123107
2010-11-02Don't try to split weird critical edges that really aren't:Jakob Stoklund Olesen1-2/+12
BB#1: derived from LLVM BB %bb.nph28 Live Ins: %AL Predecessors according to CFG: BB#0 TEST8rr %reg16384<kill>, %reg16384, %EFLAGS<imp-def>; GR8:%reg16384 JNE_4 <BB#2>, %EFLAGS<imp-use,kill> JMP_4 <BB#2> Successors according to CFG: BB#2 BB#2 These double CFG edges only ever occur in bugpoint-generated code, so there is no need to attempt something clever. llvm-svn: 117992