Move local statics to per-instance variables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74132 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2009-06-24 22:28:12 +00:00
parent 02a6218774
commit bd58edf591
2 changed files with 10 additions and 9 deletions

View File

@ -109,6 +109,12 @@ namespace llvm {
///
bool VerboseAsm;
/// Private state for PrintSpecial()
// Assign a unique ID to this machine instruction.
mutable const MachineInstr *LastMI;
mutable const Function *LastFn;
mutable unsigned Counter;
protected:
explicit AsmPrinter(raw_ostream &o, TargetMachine &TM,
const TargetAsmInfo *T, CodeGenOpt::Level OL, bool V);

View File

@ -45,7 +45,7 @@ AsmPrinter::AsmPrinter(raw_ostream &o, TargetMachine &tm,
const TargetAsmInfo *T, CodeGenOpt::Level OL, bool VDef)
: MachineFunctionPass(&ID), FunctionNumber(0), OptLevel(OL), O(o),
TM(tm), TAI(T), TRI(tm.getRegisterInfo()),
IsInTextSection(false) {
IsInTextSection(false), LastMI(0), LastFn(0), Counter(~0U) {
DW = 0; MMI = 0;
switch (AsmVerbose) {
case cl::BOU_UNSET: VerboseAsm = VDef; break;
@ -1315,20 +1315,15 @@ void AsmPrinter::PrintSpecial(const MachineInstr *MI, const char *Code) const {
if (VerboseAsm)
O << TAI->getCommentString();
} else if (!strcmp(Code, "uid")) {
// Assign a unique ID to this machine instruction.
static const MachineInstr *LastMI = 0;
static const Function *F = 0;
static unsigned Counter = 0U-1;
// Comparing the address of MI isn't sufficient, because machineinstrs may
// be allocated to the same address across functions.
const Function *ThisF = MI->getParent()->getParent()->getFunction();
// If this is a new machine instruction, bump the counter.
if (LastMI != MI || F != ThisF) {
// If this is a new LastFn instruction, bump the counter.
if (LastMI != MI || LastFn != ThisF) {
++Counter;
LastMI = MI;
F = ThisF;
LastFn = ThisF;
}
O << Counter;
} else {