diff options
author | Alkis Evlogimenos <alkis@evlogimenos.com> | 2003-10-08 05:20:08 +0000 |
---|---|---|
committer | Alkis Evlogimenos <alkis@evlogimenos.com> | 2003-10-08 05:20:08 +0000 |
commit | 73ff5120eb8b8c0ccbfed8a17f1024c67a75f319 (patch) | |
tree | ea737ea5c41b893d3584c3c2d2f0ba5e118d929d /lib/CodeGen/LiveVariables.cpp | |
parent | 6b8b22585c8ee1ee9bed9c218c604dfb3d88a851 (diff) |
Change MRegisterDesc::AliasSet, TargetInstrDescriptor::ImplicitDefs
and TargetInstrDescriptor::ImplicitUses to always point to a null
terminated array and never be null. So there is no need to check for
pointer validity when iterating over those sets. Code that looked
like:
if (const unsigned* AS = TID.ImplicitDefs) {
for (int i = 0; AS[i]; ++i) {
// use AS[i]
}
}
was changed to:
for (const unsigned* AS = TID.ImplicitDefs; *AS; ++AS) {
// use *AS
}
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8960 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveVariables.cpp')
-rw-r--r-- | lib/CodeGen/LiveVariables.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/lib/CodeGen/LiveVariables.cpp b/lib/CodeGen/LiveVariables.cpp index d38ed274e3..2a9b70d3b0 100644 --- a/lib/CodeGen/LiveVariables.cpp +++ b/lib/CodeGen/LiveVariables.cpp @@ -108,12 +108,14 @@ void LiveVariables::HandlePhysRegUse(unsigned Reg, MachineInstr *MI) { if (PhysRegInfo[Reg]) { PhysRegInfo[Reg] = MI; PhysRegUsed[Reg] = true; - } else if (const unsigned *AliasSet = RegInfo->getAliasSet(Reg)) { - for (; unsigned NReg = AliasSet[0]; ++AliasSet) - if (MachineInstr *LastUse = PhysRegInfo[NReg]) { - PhysRegInfo[NReg] = MI; - PhysRegUsed[NReg] = true; + } else { + for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg); + *AliasSet; ++AliasSet) { + if (MachineInstr *LastUse = PhysRegInfo[*AliasSet]) { + PhysRegInfo[*AliasSet] = MI; + PhysRegUsed[*AliasSet] = true; } + } } } @@ -124,15 +126,17 @@ void LiveVariables::HandlePhysRegDef(unsigned Reg, MachineInstr *MI) { RegistersKilled.insert(std::make_pair(LastUse, Reg)); else RegistersDead.insert(std::make_pair(LastUse, Reg)); - } else if (const unsigned *AliasSet = RegInfo->getAliasSet(Reg)) { - for (; unsigned NReg = AliasSet[0]; ++AliasSet) - if (MachineInstr *LastUse = PhysRegInfo[NReg]) { - if (PhysRegUsed[NReg]) - RegistersKilled.insert(std::make_pair(LastUse, NReg)); + } else { + for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg); + *AliasSet; ++AliasSet) { + if (MachineInstr *LastUse = PhysRegInfo[*AliasSet]) { + if (PhysRegUsed[*AliasSet]) + RegistersKilled.insert(std::make_pair(LastUse, *AliasSet)); else - RegistersDead.insert(std::make_pair(LastUse, NReg)); - PhysRegInfo[NReg] = 0; // Kill the aliased register + RegistersDead.insert(std::make_pair(LastUse, *AliasSet)); + PhysRegInfo[*AliasSet] = 0; // Kill the aliased register } + } } PhysRegInfo[Reg] = MI; PhysRegUsed[Reg] = false; @@ -206,9 +210,9 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &MF) { NumOperandsToProcess = 1; // Loop over implicit uses, using them. - if (const unsigned *ImplicitUses = MID.ImplicitUses) - for (unsigned i = 0; ImplicitUses[i]; ++i) - HandlePhysRegUse(ImplicitUses[i], MI); + for (const unsigned *ImplicitUses = MID.ImplicitUses; + *ImplicitUses; ++ImplicitUses) + HandlePhysRegUse(*ImplicitUses, MI); // Process all explicit uses... for (unsigned i = 0; i != NumOperandsToProcess; ++i) { |