diff options
author | Chris Lattner <sabre@nondot.org> | 2006-08-24 22:43:55 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-08-24 22:43:55 +0000 |
commit | f7da2c7b0c6293c268881628fc351bed7763f1f4 (patch) | |
tree | 0226e9d0eeec331bfd216448cb6660854ae2b6d4 /lib/CodeGen/VirtRegMap.cpp | |
parent | 4869d7fa8e7daeaafc8b86c6f54efd41517f0f14 (diff) | |
download | external_llvm-f7da2c7b0c6293c268881628fc351bed7763f1f4.zip external_llvm-f7da2c7b0c6293c268881628fc351bed7763f1f4.tar.gz external_llvm-f7da2c7b0c6293c268881628fc351bed7763f1f4.tar.bz2 |
Take advantage of the recent improvements to the liveintervals set (tracking
instructions which define each value#) to simplify and improve the coallescer.
In particular, this patch:
1. Implements iterative coallescing.
2. Reverts an unsafe hack from handlePhysRegDef, superceeding it with a
better solution.
3. Implements PR865, "coallescing" away the second copy in code like:
A = B
...
B = A
This also includes changes to symbolically print registers in intervals
when possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29862 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/VirtRegMap.cpp')
-rw-r--r-- | lib/CodeGen/VirtRegMap.cpp | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp index 7e6d09b..bc56945 100644 --- a/lib/CodeGen/VirtRegMap.cpp +++ b/lib/CodeGen/VirtRegMap.cpp @@ -521,7 +521,6 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) { // Process all of the spilled uses and all non spilled reg references. for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { MachineOperand &MO = MI.getOperand(i); - if (!MO.isRegister() || MO.getReg() == 0) continue; // Ignore non-register operands. @@ -791,37 +790,16 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) { } if (!OpTakenCareOf) { + // Check to see if this is a noop copy. If so, eliminate the + // instruction before considering the dest reg to be changed. unsigned Src, Dst; - if (TII->isMoveInstr(MI, Src, Dst)) { - if (Src == Dst) { - // Check to see if this is a noop copy. If so, eliminate - // the instruction before considering the dest reg to be - // changed. - ++NumDCE; - DEBUG(std::cerr << "Removing now-noop copy: " << MI); - MBB.erase(&MI); - VRM.RemoveFromFoldedVirtMap(&MI); - goto ProcessNextInst; - } else if (MII != MBB.begin()) { - // Check to see if this is a sequence of the form: - // mov R0, R1 - // mov R1, R0 - // Eliminate the second move if so. - MachineBasicBlock::iterator PrevMII = MII; --PrevMII; - MachineInstr& PrevMI = *PrevMII; - unsigned PrevSrc, PrevDst; - - if (TII->isMoveInstr(PrevMI, PrevSrc, PrevDst)) - if (PrevSrc == Dst && PrevDst == Src) { - ++NumDCE; - DEBUG(std::cerr << "Removing now-noop copy: " << MI); - MBB.erase(&MI); - VRM.RemoveFromFoldedVirtMap(&MI); - goto ProcessNextInst; - } - } + if (TII->isMoveInstr(MI, Src, Dst) && Src == Dst) { + ++NumDCE; + DEBUG(std::cerr << "Removing now-noop copy: " << MI); + MBB.erase(&MI); + VRM.RemoveFromFoldedVirtMap(&MI); + goto ProcessNextInst; } - Spills.ClobberPhysReg(VirtReg); continue; } @@ -883,6 +861,8 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) { } } + + llvm::Spiller* llvm::createSpiller() { switch (SpillerOpt) { default: assert(0 && "Unreachable!"); |