diff options
| author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-08-04 22:35:11 +0000 |
|---|---|---|
| committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-08-04 22:35:11 +0000 |
| commit | 7fd4905f08f68e79477249be6b2cdd85def45c4c (patch) | |
| tree | 2d31bf1e95ad2ede21440a5aec9da1370be0e370 /llvm/lib | |
| parent | d81ef1c85c62ae5627ab651e1a6489fe48af8cd7 (diff) | |
| download | bcm5719-llvm-7fd4905f08f68e79477249be6b2cdd85def45c4c.tar.gz bcm5719-llvm-7fd4905f08f68e79477249be6b2cdd85def45c4c.zip | |
Coalesce stack slot accesses that arise when spilling both sides of a COPY.
This helps avoid silly code:
%R0<def = LOAD <fi#5>
STORE <fi#5>, %R0<kill>
llvm-svn: 110266
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/InlineSpiller.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp index d9dcbc0fdd4..872a829df59 100644 --- a/llvm/lib/CodeGen/InlineSpiller.cpp +++ b/llvm/lib/CodeGen/InlineSpiller.cpp @@ -85,6 +85,7 @@ private: bool reMaterializeFor(MachineBasicBlock::iterator MI); void reMaterializeAll(); + bool coalesceStackAccess(MachineInstr *MI); bool foldMemoryOperand(MachineBasicBlock::iterator MI, const SmallVectorImpl<unsigned> &Ops); void insertReload(LiveInterval &NewLI, MachineBasicBlock::iterator MI); @@ -291,6 +292,24 @@ void InlineSpiller::reMaterializeAll() { } } +/// If MI is a load or store of stackSlot_, it can be removed. +bool InlineSpiller::coalesceStackAccess(MachineInstr *MI) { + int FI = 0; + unsigned reg; + if (!(reg = tii_.isLoadFromStackSlot(MI, FI)) && + !(reg = tii_.isStoreToStackSlot(MI, FI))) + return false; + + // We have a stack access. Is it the right register and slot? + if (reg != li_->reg || FI != stackSlot_) + return false; + + DEBUG(dbgs() << "Coalescing stack access: " << *MI); + lis_.RemoveMachineInstrFromMaps(MI); + MI->eraseFromParent(); + return true; +} + /// foldMemoryOperand - Try folding stack slot references in Ops into MI. /// Return true on success, and MI will be erased. bool InlineSpiller::foldMemoryOperand(MachineBasicBlock::iterator MI, @@ -399,6 +418,10 @@ void InlineSpiller::spill(LiveInterval *li, continue; } + // Stack slot accesses may coalesce away. + if (coalesceStackAccess(MI)) + continue; + // Analyze instruction. bool Reads, Writes; SmallVector<unsigned, 8> Ops; |

