Commit Graph

126 Commits

Author SHA1 Message Date
Owen Anderson
bbf5583283 Use SmallSet instead of std::set to save allocations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54810 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-14 23:41:38 +00:00
Owen Anderson
bd3ba461eb - 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54333 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-04 23:54:43 +00:00
Evan Cheng
9f1c8317a4 - 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53097 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 09:09:37 +00:00
Evan Cheng
5b9f60bc22 Use std::replace instead of std::find and push_back.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53063 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 00:28:27 +00:00
Evan Cheng
be04dc1413 - 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53061 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 00:07:19 +00:00
Owen Anderson
bffdf66b80 Use a SmallSet when we can to reduce memory allocations.
This speeds up a particular testcase from 0.0302s to 0.0222s in LiveVariables.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52819 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-27 07:05:59 +00:00
Dan Gohman
48b0b882c7 Fix the text in an assert string.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52744 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-25 22:14:43 +00:00
Bill Wendling
ebcba612b5 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52655 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-23 23:41:14 +00:00
Evan Cheng
0d4bdde327 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49784 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-16 09:46:40 +00:00
Evan Cheng
ea1d9cdc4e 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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49105 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-02 18:04:08 +00:00
Evan Cheng
94202018c5 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48521 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-19 00:52:20 +00:00
Evan Cheng
6130f66eaa Refactor code. Remove duplicated functions that basically do the same thing as
findRegisterUseOperandIdx, findRegisterDefOperandIndx. Fix some naming inconsistencies.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47927 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-05 00:59:57 +00:00
Bill Wendling
1d5e8196c0 Clear PhysRegPartUse for the sub register as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47453 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-21 19:35:27 +00:00
Bill Wendling
c927cc8731 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).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47399 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-20 20:56:45 +00:00
Bill Wendling
55574c2cea Improve some comments explaining the "handle kills" stuff better.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47395 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-20 19:35:34 +00:00
Bill Wendling
fe8276cec2 Fix comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47389 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-20 19:09:14 +00:00
Bill Wendling
6d794746b7 Added some comments and reformatted others. No functionality change.
Added two "FIXMEs" for code that looks dubious to me (but I could be
wrong).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47366 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-20 09:15:16 +00:00
Bill Wendling
420cdebbcb More constification of things. More comments added. No functionality
changes. (Sorry for any formatting changes that creeped in.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47362 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-20 07:36:31 +00:00
Bill Wendling
90a3868fe5 No functionality change:
- Constified some MachineOperand values.
 - Added/Modified some comments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47358 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-20 06:10:21 +00:00
Dan Gohman
6f0d024a53 Rename MRegisterInfo to TargetRegisterInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46930 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-10 18:45:23 +00:00
Evan Cheng
bb4151bd1f 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).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46763 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-05 20:04:18 +00:00
Owen Anderson
b487e7215c Move some functionality for adding flags to MachineInstr's into methods on MachineInstr rather than LiveVariables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46295 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-24 01:10:07 +00:00
Owen Anderson
40a627ddf8 Move some calls to getVRegDef higher in the callgraph, so they don't get executed as frequently in performance sensitive code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46027 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15 22:58:11 +00:00
Owen Anderson
7047dd4d22 Remove DefInst from LiveVariables::VarInfo. Use the facilities on MachineRegisterInfo instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46016 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15 22:02:46 +00:00
Chris Lattner
749c6f6b5e rename TargetInstrDescriptor -> TargetInstrDesc.
Make MachineInstr::getDesc return a reference instead
of a pointer, since it can never be null.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45695 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 07:27:27 +00:00
Chris Lattner
349c495200 Move a bunch more accessors from TargetInstrInfo to TargetInstrDescriptor
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45680 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 03:13:06 +00:00
Chris Lattner
84bc5427d6 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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45467 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-31 04:13:23 +00:00
Chris Lattner
8aa797aa51 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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45464 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 23:10:15 +00:00
Chris Lattner
f73823000e 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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45461 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 21:56:09 +00:00
Chris Lattner
8019f41c0b Start using the simplified methods for adding operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45432 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 00:41:17 +00:00
Chris Lattner
4ee451de36 Remove attribution from file headers, per discussion on llvmdev.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45418 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 20:36:04 +00:00
Evan Cheng
81a0382181 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44198 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-17 00:40:40 +00:00
Owen Anderson
a018540807 Bring UsedBlocks back. StrongPHIElimination needs this information.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43866 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-08 01:20:48 +00:00
Evan Cheng
5942efb0e5 Handle cases where a register and one of its super-register are both marked as
defined on the same instruction. This fixes PR1767.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43699 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-05 03:11:55 +00:00
Dan Gohman
92dfe2001e Remove isReg, isImm, and isMBB, and change all their users to use
isRegister, isImmediate, and isMachineBasicBlock, which are equivalent,
and more popular.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41958 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-14 20:33:02 +00:00
Evan Cheng
0d8d31674f Fixed a typo that's causing a missing kill marker.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41893 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-12 23:02:04 +00:00
Evan Cheng
6d6d352ed9 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41871 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-11 22:34:47 +00:00
Evan Cheng
21b3bf0650 Bugs: missing partial uses and redundant partial defs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40688 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-01 20:18:21 +00:00
Dan Gohman
c674a924d4 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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40131 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-20 23:17:34 +00:00
Evan Cheng
f99002c143 Dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39979 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-17 20:01:19 +00:00
Evan Cheng
041040717d Replace std::set with SmallPtrSet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37746 91177308-0d34-0410-b5e6-96231b3b80d8
2007-06-27 05:23:00 +00:00
Evan Cheng
4efe74129f Properly handle kills of a physical register which has sub-registers that are read by later instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37739 91177308-0d34-0410-b5e6-96231b3b80d8
2007-06-26 21:03:35 +00:00
Evan Cheng
8b966d9fd0 When marking a register as being implicitly defined, make sure to clear its partial use info as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37046 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-14 20:39:18 +00:00
Evan Cheng
56184904cd Eliminate MarkVirtRegAliveInBlock recursion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36943 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-08 19:00:00 +00:00
Devang Patel
1997473cf7 Drop 'const'
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36662 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-03 01:11:54 +00:00
Devang Patel
3e15bf33e0 Use 'static const char' instead of 'static const int'.
Due to darwin gcc bug, one version of darwin linker coalesces
static const int, which defauts PassID based pass identification.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36652 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-02 21:39:20 +00:00
Devang Patel
794fd75c67 Do not use typeinfo to identify pass in pass manager.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36632 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-01 21:15:47 +00:00
Evan Cheng
faa510726f Rename findRegisterUseOperand to findRegisterUseOperandIdx to avoid confusion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36483 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-26 19:00:32 +00:00
Evan Cheng
8e29b2192b Minor bug.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36473 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-26 08:24:22 +00:00
Evan Cheng
05350288a6 Be careful when to add implicit kill / dead operands. Don't add them during / post reg-allocation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36458 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-26 01:40:09 +00:00