[llvm-commits] CVS: llvm/lib/CodeGen/LiveVariables.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Aug 23 17:09:44 PDT 2005
Changes in directory llvm/lib/CodeGen:
LiveVariables.cpp updated: 1.51 -> 1.52
---
Log message:
Implement LiveVariables.h change
---
Diffs of the changes: (+30 -0)
LiveVariables.cpp | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+)
Index: llvm/lib/CodeGen/LiveVariables.cpp
diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.51 llvm/lib/CodeGen/LiveVariables.cpp:1.52
--- llvm/lib/CodeGen/LiveVariables.cpp:1.51 Tue Aug 23 18:42:17 2005
+++ llvm/lib/CodeGen/LiveVariables.cpp Tue Aug 23 19:09:33 2005
@@ -34,6 +34,7 @@
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Config/alloca.h"
+#include <algorithm>
using namespace llvm;
static RegisterAnalysis<LiveVariables> X("livevars", "Live Variable Analysis");
@@ -51,6 +52,25 @@
return VirtRegInfo[RegIdx];
}
+bool LiveVariables::KillsRegister(MachineInstr *MI, unsigned Reg) const {
+ std::map<MachineInstr*, std::vector<unsigned> >::const_iterator I =
+ RegistersKilled.find(MI);
+ if (I == RegistersKilled.end()) return false;
+
+ // Do a binary search, as these lists can grow pretty big, particularly for
+ // call instructions on targets with lots of call-clobbered registers.
+ return std::binary_search(I->second.begin(), I->second.end(), Reg);
+}
+
+bool LiveVariables::RegisterDefIsDead(MachineInstr *MI, unsigned Reg) const {
+ std::map<MachineInstr*, std::vector<unsigned> >::const_iterator I =
+ RegistersDead.find(MI);
+ if (I == RegistersDead.end()) return false;
+
+ // Do a binary search, as these lists can grow pretty big, particularly for
+ // call instructions on targets with lots of call-clobbered registers.
+ return std::binary_search(I->second.begin(), I->second.end(), Reg);
+}
void LiveVariables::MarkVirtRegAliveInBlock(VarInfo &VRInfo,
@@ -301,6 +321,16 @@
i + MRegisterInfo::FirstVirtualRegister);
}
+ // Walk through the RegistersKilled/Dead sets, and sort the registers killed
+ // or dead. This allows us to use efficient binary search for membership
+ // testing.
+ for (std::map<MachineInstr*, std::vector<unsigned> >::iterator
+ I = RegistersKilled.begin(), E = RegistersKilled.end(); I != E; ++I)
+ std::sort(I->second.begin(), I->second.end());
+ for (std::map<MachineInstr*, std::vector<unsigned> >::iterator
+ I = RegistersDead.begin(), E = RegistersDead.end(); I != E; ++I)
+ std::sort(I->second.begin(), I->second.end());
+
// Check to make sure there are no unreachable blocks in the MC CFG for the
// function. If so, it is due to a bug in the instruction selector or some
// other part of the code generator if this happens.
More information about the llvm-commits
mailing list