diff options
author | Chris Lattner <sabre@nondot.org> | 2004-02-19 18:28:02 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-02-19 18:28:02 +0000 |
commit | 5ed001b6afe2225343ec79f58645a9aaf35c1fd2 (patch) | |
tree | 141364a1c04bd8a6fe967e0f7406e85f234a82b5 /lib/CodeGen/LiveVariables.cpp | |
parent | 7c955fdb446fa0629e1341f88f4541ee9a929942 (diff) |
Add method to update livevar when an instruction moves
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11625 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveVariables.cpp')
-rw-r--r-- | lib/CodeGen/LiveVariables.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/CodeGen/LiveVariables.cpp b/lib/CodeGen/LiveVariables.cpp index 0554bae87b..c4c8d63929 100644 --- a/lib/CodeGen/LiveVariables.cpp +++ b/lib/CodeGen/LiveVariables.cpp @@ -33,6 +33,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Support/CFG.h" #include "Support/DepthFirstIterator.h" +#include "Support/STLExtras.h" using namespace llvm; static RegisterAnalysis<LiveVariables> X("livevars", "Live Variable Analysis"); @@ -313,3 +314,36 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &MF) { return false; } + +/// instructionChanged - When the address of an instruction changes, this +/// method should be called so that live variables can update its internal +/// data structures. This removes the records for OldMI, transfering them to +/// the records for NewMI. +void LiveVariables::instructionChanged(MachineInstr *OldMI, + MachineInstr *NewMI) { + // If the instruction defines any virtual registers, update the VarInfo for + // the instruction. + for (unsigned i = 0, e = NewMI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = NewMI->getOperand(i); + if (MO.isRegister() && MO.isDef() && + MRegisterInfo::isVirtualRegister(MO.getReg())) { + unsigned Reg = MO.getReg(); + VarInfo &VI = getVarInfo(Reg); + if (VI.DefInst == OldMI) + VI.DefInst = NewMI; + } + } + + // Move the killed information over... + killed_iterator I, E; + tie(I, E) = killed_range(OldMI); + for (killed_iterator A = I; A != E; ++A) + RegistersKilled.insert(std::make_pair(NewMI, A->second)); + RegistersKilled.erase(I, E); + + // Move the dead information over... + tie(I, E) = dead_range(OldMI); + for (killed_iterator A = I; A != E; ++A) + RegistersDead.insert(std::make_pair(NewMI, A->second)); + RegistersDead.erase(I, E); +} |