Commit Graph

136 Commits

Author SHA1 Message Date
Evan Cheng ba2410b7ca Avoid adding a duplicate def. This fixes PR4478.
llvm-svn: 74857
2009-07-06 21:34:05 +00:00
Evan Cheng c6a8d0dbe9 Fix PR4419: handle defs of partial uses.
llvm-svn: 73816
2009-06-20 04:34:51 +00:00
Evan Cheng d29fc6655f If there is a def of a super-register followed by a use of a sub-register, do *not* add an implicit def of the sub-register. e.g.
EAX = ..., AX<imp-def>
...
    = AX

This creates a double-def. Apparently this used to be necessary but is no longer needed.

Thanks to Anton for pointing this out. Anton, I cannot create a test case without your uncommitted ARM patches. Please check in a test case for me.

llvm-svn: 72755
2009-06-03 05:15:46 +00:00
Jeffrey Yasskin 7d287cb7ed LiveVariables::VarInfo contains an AliveBlocks BitVector, which has as many
entries as there are basic blocks in the function.  LiveVariables::getVarInfo
creates a VarInfo struct for every register in the function, leading to
quadratic space use.  This patch changes the BitVector to a SparseBitVector,
which doesn't help the worst-case memory use but does reduce the actual use in
very long functions with short-lived variables.

llvm-svn: 72426
2009-05-26 18:27:15 +00:00
Evan Cheng 7061ee968c Eliminate VarInfo::UsedBlocks.
llvm-svn: 72411
2009-05-26 06:25:46 +00:00
Evan Cheng f1e873a221 Fix PR3243: a LiveVariables bug. When HandlePhysRegKill is checking whether the last reference is also the last def (i.e. dead def), it should also check if last reference is the current machine instruction being processed. This can happen when it is processing a physical register use and setting the current machine instruction as sub-register's last ref.
llvm-svn: 62617
2009-01-20 21:25:12 +00:00
Devang Patel cb181bb203 Silence unused variable warnings.
llvm-svn: 59841
2008-11-21 20:00:59 +00:00
Dan Gohman 8fed4ce0b8 Use find_first/find_next to iterate through all the set bits in a
BitVector, instead of manually testing each bit.

llvm-svn: 59246
2008-11-13 16:31:27 +00:00
Dan Gohman 0d1e9a8e04 Switch the MachineOperand accessors back to the short names like
isReg, etc., from isRegister, etc.

llvm-svn: 57006
2008-10-03 15:45:36 +00:00
Dan Gohman ae9d9f4d3f Factor out code into HandleVirtRegDef, for consistency with
Handle{Virt,Phys}Reg{Def,Use}. Remove a redundant check
for register zero, and redundant checks for isPhysicalRegister.

llvm-svn: 56412
2008-09-21 21:11:41 +00:00
Owen Anderson 14738120ba Use SmallSet instead of std::set to save allocations.
llvm-svn: 54810
2008-08-14 23:41:38 +00:00
Owen Anderson a102290bdc - Fix SelectionDAG to generate correct CFGs.
- Add a basic machine-level dead block eliminator.

These two have to go together, since many other parts of the code generator are unable to handle the unreachable blocks otherwise created.

llvm-svn: 54333
2008-08-04 23:54:43 +00:00
Evan Cheng 7d98a48f15 - Remove calls to copyKillDeadInfo which is an N^2 function. Instead, propagate kill / dead markers as new instructions are constructed in foldMemoryOperand, convertToThressAddress, etc.
- Also remove LiveVariables::instructionChanged, etc. Replace all calls with cheaper calls which update VarInfo kill list.

llvm-svn: 53097
2008-07-03 09:09:37 +00:00
Evan Cheng 9f8b66f3f1 Use std::replace instead of std::find and push_back.
llvm-svn: 53063
2008-07-03 00:28:27 +00:00
Evan Cheng 7a265d83bf - Add LiveVariables::replaceKillInstruction. This does a subset of instructionChanged. That is, it only update the VarInfo.kills if the new instruction is known to have the correct dead and kill markers.
- CommuteInstruction copies kill / dead markers over to new instruction. So use replaceKillInstruction instead.

llvm-svn: 53061
2008-07-03 00:07:19 +00:00
Owen Anderson 413f7d90db Use a SmallSet when we can to reduce memory allocations.
This speeds up a particular testcase from 0.0302s to 0.0222s in LiveVariables.

llvm-svn: 52819
2008-06-27 07:05:59 +00:00
Dan Gohman 39b07db75a Fix the text in an assert string.
llvm-svn: 52744
2008-06-25 22:14:43 +00:00
Bill Wendling c44659b92a This situation can occur:
,------.
    |      |
    |      v
    |   t2 = phi ... t1 ...
    |      |
    |      v
    |   t1 = ...
    |  ... = ... t1 ...
    |      |
    `------'

where there is a use in a PHI node that's a predecessor to the defining
block. We don't want to mark all predecessors as having the value "alive" in
this case. Also, the assert was too restrictive and didn't handle this case.

llvm-svn: 52655
2008-06-23 23:41:14 +00:00
Evan Cheng e45b8f89c5 Rewrite LiveVariable liveness computation. The new implementation is much simplified. It eliminated the nasty recursive routines and removed the partial def / use bookkeeping. There is also potential for performance improvement by replacing the conservative handling of partial physical register definitions. The code is currently disabled until live interval analysis is taught of the name scheme.
This patch also fixed a couple of nasty corner cases.

llvm-svn: 49784
2008-04-16 09:46:40 +00:00
Evan Cheng d8616064d8 Now that I am told MachineRegisterInfo also tracks physical register uses / defs, I can do away with the horribleness I introduced a while back. It's impossible to detect if there is any use of a physical register below an instruction (and before any def of the register) with some cheap book keeping.
llvm-svn: 49105
2008-04-02 18:04:08 +00:00
Evan Cheng 44c0b4f754 Fix live variables issues:
1. If part of a register is re-defined, an implicit kill and an implicit def are added to denote read / mod / write. However, this should only be necessary if the register is actually read later. This is a performance issue.
2. If a sub-register is being defined, and it doesn't have a previous use, do not add a implicit kill to the last use of a super-register:
   = EAX, AX<imp-use,kill>
...
AX =
In this case, EAX is live but AX is killed, this is wrong and will cause the coalescer to do bad things.

llvm-svn: 48521
2008-03-19 00:52:20 +00:00
Evan Cheng 6325446666 Refactor code. Remove duplicated functions that basically do the same thing as
findRegisterUseOperandIdx, findRegisterDefOperandIndx. Fix some naming inconsistencies.

llvm-svn: 47927
2008-03-05 00:59:57 +00:00
Bill Wendling 15526b2e52 Clear PhysRegPartUse for the sub register as well.
llvm-svn: 47453
2008-02-21 19:35:27 +00:00
Bill Wendling eac9e5ef21 Remove one of the fixmes that I put in there. From Evan:
No need to go up more levels. A def of a register also sets its sub-registers
(so if PhysRegInfo[SuperReg] is NULL, it means SuperReg's super registers are
not previously defined).

llvm-svn: 47399
2008-02-20 20:56:45 +00:00
Bill Wendling cf2d1aa485 Improve some comments explaining the "handle kills" stuff better.
llvm-svn: 47395
2008-02-20 19:35:34 +00:00
Bill Wendling 0b72219681 Fix comment.
llvm-svn: 47389
2008-02-20 19:09:14 +00:00
Bill Wendling b912351ec9 Added some comments and reformatted others. No functionality change.
Added two "FIXMEs" for code that looks dubious to me (but I could be
wrong).

llvm-svn: 47366
2008-02-20 09:15:16 +00:00
Bill Wendling 406fdbd3ad More constification of things. More comments added. No functionality
changes. (Sorry for any formatting changes that creeped in.)

llvm-svn: 47362
2008-02-20 07:36:31 +00:00
Bill Wendling 59cc15955f No functionality change:
- Constified some MachineOperand values.
 - Added/Modified some comments.

llvm-svn: 47358
2008-02-20 06:10:21 +00:00
Dan Gohman 3a4be0fdef Rename MRegisterInfo to TargetRegisterInfo.
llvm-svn: 46930
2008-02-10 18:45:23 +00:00
Evan Cheng 8d78b0597b If a vr is already marked alive in a bb, then it has PHI uses that are visited earlier, then it is not killed in the def block (i.e. not dead).
llvm-svn: 46763
2008-02-05 20:04:18 +00:00
Owen Anderson 2a8a485630 Move some functionality for adding flags to MachineInstr's into methods on MachineInstr rather than LiveVariables.
llvm-svn: 46295
2008-01-24 01:10:07 +00:00
Owen Anderson 897aed9109 Move some calls to getVRegDef higher in the callgraph, so they don't get executed as frequently in performance sensitive code.
llvm-svn: 46027
2008-01-15 22:58:11 +00:00
Owen Anderson 1ba66e0cec Remove DefInst from LiveVariables::VarInfo. Use the facilities on MachineRegisterInfo instead.
llvm-svn: 46016
2008-01-15 22:02:46 +00:00
Chris Lattner 03ad885039 rename TargetInstrDescriptor -> TargetInstrDesc.
Make MachineInstr::getDesc return a reference instead
of a pointer, since it can never be null.

llvm-svn: 45695
2008-01-07 07:27:27 +00:00
Chris Lattner b0d06b4381 Move a bunch more accessors from TargetInstrInfo to TargetInstrDescriptor
llvm-svn: 45680
2008-01-07 03:13:06 +00:00
Chris Lattner a10fff51d9 Rename SSARegMap -> MachineRegisterInfo in keeping with the idea
that "machine" classes are used to represent the current state of
the code being compiled.  Given this expanded name, we can start 
moving other stuff into it.  For now, move the UsedPhysRegs and
LiveIn/LoveOuts vectors from MachineFunction into it.

Update all the clients to match.

This also reduces some needless #includes, such as MachineModuleInfo
from MachineFunction.

llvm-svn: 45467
2007-12-31 04:13:23 +00:00
Chris Lattner a5bb370aa4 Add new shorter predicates for testing machine operands for various types:
e.g. MO.isMBB() instead of MO.isMachineBasicBlock().  I don't plan on 
switching everything over, so new clients should just start using the 
shorter names.

Remove old long accessors, switching everything over to use the short
accessor: getMachineBasicBlock() -> getMBB(), 
getConstantPoolIndex() -> getIndex(), setMachineBasicBlock -> setMBB(), etc.

llvm-svn: 45464
2007-12-30 23:10:15 +00:00
Chris Lattner 6005589faf More cleanups for MachineOperand:
- Eliminate the static "print" method for operands, moving it
    into MachineOperand::print.
  - Change various set* methods for register flags to take a bool
    for the value to set it to.  Remove unset* methods.
  - Group methods more logically by operand flavor in MachineOperand.h

llvm-svn: 45461
2007-12-30 21:56:09 +00:00
Chris Lattner e35dfb827f Start using the simplified methods for adding operands.
llvm-svn: 45432
2007-12-30 00:41:17 +00:00
Chris Lattner f3ebc3f3d2 Remove attribution from file headers, per discussion on llvmdev.
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Evan Cheng 8e22379303 Live interval splitting:
When a live interval is being spilled, rather than creating short, non-spillable
intervals for every def / use, split the interval at BB boundaries. That is, for
every BB where the live interval is defined or used, create a new interval that
covers all the defs and uses in the BB.

This is designed to eliminate one common problem: multiple reloads of the same
value in a single basic block. Note, it does *not* decrease the number of spills
since no copies are inserted so the split intervals are *connected* through
spill and reloads (or rematerialization). The newly created intervals can be
spilled again, in that case, since it does not span multiple basic blocks, it's
spilled in the usual manner. However, it can reuse the same stack slot as the
previously split interval.

This is currently controlled by -split-intervals-at-bb.

llvm-svn: 44198
2007-11-17 00:40:40 +00:00
Owen Anderson 9d86ef12c8 Bring UsedBlocks back. StrongPHIElimination needs this information.
llvm-svn: 43866
2007-11-08 01:20:48 +00:00
Evan Cheng a406b47f14 Handle cases where a register and one of its super-register are both marked as
defined on the same instruction. This fixes PR1767.

llvm-svn: 43699
2007-11-05 03:11:55 +00:00
Dan Gohman 9da02f5ee2 Remove isReg, isImm, and isMBB, and change all their users to use
isRegister, isImmediate, and isMachineBasicBlock, which are equivalent,
and more popular.

llvm-svn: 41958
2007-09-14 20:33:02 +00:00
Evan Cheng d8317967aa Fixed a typo that's causing a missing kill marker.
llvm-svn: 41893
2007-09-12 23:02:04 +00:00
Evan Cheng c16847b157 Sometimes a MI can define a register as well as defining a super-register at the
same time. Do not mark the "smaller" def as dead.

llvm-svn: 41871
2007-09-11 22:34:47 +00:00
Evan Cheng d8ded48468 Bugs: missing partial uses and redundant partial defs.
llvm-svn: 40688
2007-08-01 20:18:21 +00:00
Dan Gohman 147d9fa57d Don't assume that only Uses can be kills. Defs are marked as kills initially
when there are no uses. This fixes a dangling-pointer bug, where pointers to
deleted instructions were not removed from kills lists. More info here:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-July/009749.html

llvm-svn: 40131
2007-07-20 23:17:34 +00:00
Evan Cheng f9ef70560e Dead code.
llvm-svn: 39979
2007-07-17 20:01:19 +00:00