diff options
author | Dan Gohman <gohman@apple.com> | 2010-06-24 22:23:02 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-06-24 22:23:02 +0000 |
commit | fe5e4dabbf05f3b7b8c6d652adb6b500e5dec8cd (patch) | |
tree | 619dbedc7b8ae8534fca64d1c00849787ab73213 /lib/CodeGen | |
parent | f241b26792c12ca1819685d8640ea08d676c9cc0 (diff) | |
download | external_llvm-fe5e4dabbf05f3b7b8c6d652adb6b500e5dec8cd.zip external_llvm-fe5e4dabbf05f3b7b8c6d652adb6b500e5dec8cd.tar.gz external_llvm-fe5e4dabbf05f3b7b8c6d652adb6b500e5dec8cd.tar.bz2 |
Teach EmitLiveInCopies to omit copies for unused virtual registers,
and to clean up unused incoming physregs from the live-in list.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106805 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/MachineRegisterInfo.cpp | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/lib/CodeGen/MachineRegisterInfo.cpp b/lib/CodeGen/MachineRegisterInfo.cpp index 631c43c..64a3753 100644 --- a/lib/CodeGen/MachineRegisterInfo.cpp +++ b/lib/CodeGen/MachineRegisterInfo.cpp @@ -182,21 +182,32 @@ MachineRegisterInfo::EmitLiveInCopies(MachineBasicBlock *EntryMBB, const TargetRegisterInfo &TRI, const TargetInstrInfo &TII) { // Emit the copies into the top of the block. - for (MachineRegisterInfo::livein_iterator LI = livein_begin(), - E = livein_end(); LI != E; ++LI) - if (LI->second) { - const TargetRegisterClass *RC = getRegClass(LI->second); - bool Emitted = TII.copyRegToReg(*EntryMBB, EntryMBB->begin(), - LI->second, LI->first, RC, RC, - DebugLoc()); - assert(Emitted && "Unable to issue a live-in copy instruction!\n"); - (void) Emitted; + for (unsigned i = 0, e = LiveIns.size(); i != e; ++i) + if (LiveIns[i].second) { + if (use_empty(LiveIns[i].second)) { + // The livein has no uses. Drop it. + // + // It would be preferable to have isel avoid creating live-in + // records for unused arguments in the first place, but it's + // complicated by the debug info code for arguments. + LiveIns.erase(LiveIns.begin() + i); + --i; --e; + } else { + // Emit a copy. + const TargetRegisterClass *RC = getRegClass(LiveIns[i].second); + bool Emitted = TII.copyRegToReg(*EntryMBB, EntryMBB->begin(), + LiveIns[i].second, LiveIns[i].first, + RC, RC, DebugLoc()); + assert(Emitted && "Unable to issue a live-in copy instruction!\n"); + (void) Emitted; + + // Add the register to the entry block live-in set. + EntryMBB->addLiveIn(LiveIns[i].first); + } + } else { + // Add the register to the entry block live-in set. + EntryMBB->addLiveIn(LiveIns[i].first); } - - // Add function live-ins to entry block live-in set. - for (MachineRegisterInfo::livein_iterator I = livein_begin(), - E = livein_end(); I != E; ++I) - EntryMBB->addLiveIn(I->first); } void MachineRegisterInfo::closePhysRegsUsed(const TargetRegisterInfo &TRI) { |