diff --git a/SMPBasicBlock.cpp b/SMPBasicBlock.cpp index 7315085772baec1ef6fd23a4ccab154d79bbb549..21dd1bc517abc25b11ab94abf19755bdd4654d53 100644 --- a/SMPBasicBlock.cpp +++ b/SMPBasicBlock.cpp @@ -612,7 +612,7 @@ set<DefOrUse, LessDefUse>::iterator SMPBasicBlock::GetDefFromOpAddr(op_t UseOp, if (this->IsLocalName(UseOp)) { // Search in the local DU chains. unsigned int LocalDUIndex = this->GetLocalDUIndex(UseOp, SSANum); - DefAddr = this->LocalDUChains.ChainsByName.at(LocalDUIndex).DUChains.at(SSANum).GetDef(); + DefAddr = this->LocalDUChains.ChainsByName.at(LocalDUIndex).GetDef(SSANum); DefInstr = this->FindInstr(DefAddr); DefIter = DefInstr->FindDef(UseOp); assert(DefIter != DefInstr->GetLastDef()); @@ -658,7 +658,7 @@ ea_t SMPBasicBlock::GetDefAddrFromUseAddr(op_t UseOp, ea_t InstAddr, int SSANum, if (LocalName) { // Search in the local DU chains. unsigned int LocalDUIndex = this->GetLocalDUIndex(UseOp, SSANum); - DefAddr = this->LocalDUChains.ChainsByName.at(LocalDUIndex).DUChains.at(SSANum).GetDef(); + DefAddr = this->LocalDUChains.ChainsByName.at(LocalDUIndex).GetDef(SSANum); } else { // Global DEF for this SSANum must be in the Phi functions or within a block. @@ -808,13 +808,13 @@ void SMPBasicBlock::CreateGlobalChains() { LocalUseNum++; // Make the DEF be just before the start of the block SMPDefUseChain TempDefChain(UseOp, this->GetFirstAddr() - 1); - this->GlobalDUChains.ChainsByName.at(NameIndex).DUChains.push_back(TempDefChain); + this->GlobalDUChains.ChainsByName.at(NameIndex).PushChain(TempDefChain); #if SMP_COUNT_MEMORY_ALLOCATIONS SMPDefUseChainBytes += sizeof(TempDefChain); #endif } // Push address of USE instruction onto the DEF-USE chain for this LocalUseNum. - this->GlobalDUChains.ChainsByName.at(NameIndex).DUChains.at(LocalUseNum).PushUse((*InstIter)->GetAddr()); + this->GlobalDUChains.ChainsByName.at(NameIndex).PushUse(LocalUseNum, (*InstIter)->GetAddr()); #if SMP_COUNT_MEMORY_ALLOCATIONS SMPDefUseChainBytes += sizeof(ea_t); #endif @@ -836,13 +836,13 @@ void SMPBasicBlock::CreateGlobalChains() { #if 0 // Before the push_back() call, we should have # chains equal to new LocalUseNum int LocalUseNum = LocalUseIndex.at(NameIndex); - assert(LocalUseNum == this->GlobalDUChains.ChainsByName.at(NameIndex).DUChains.size()); + assert(LocalUseNum == this->GlobalDUChains.ChainsByName.at(NameIndex).GetSize()); #endif // Set up a new DU chain and push it onto the vector of DU chains for this // local name. Push the DEF onto the list (it will be the first reference // on the list, because the list was newly created). SMPDefUseChain TempDefChain(DefOp, (*InstIter)->GetAddr()); - this->GlobalDUChains.ChainsByName.at(NameIndex).DUChains.push_back(TempDefChain); + this->GlobalDUChains.ChainsByName.at(NameIndex).PushChain(TempDefChain); #if SMP_COUNT_MEMORY_ALLOCATIONS SMPDefUseChainBytes += sizeof(TempDefChain); #endif @@ -853,7 +853,7 @@ void SMPBasicBlock::CreateGlobalChains() { #if SMP_COUNT_MEMORY_ALLOCATIONS for (size_t ArrayIndex = 0; ArrayIndex < this->GlobalDUChains.ChainsByName.size(); ++ArrayIndex) { - SMPDefUseChainCount += this->GlobalDUChains.ChainsByName.at(ArrayIndex).DUChains.size(); + SMPDefUseChainCount += this->GlobalDUChains.ChainsByName.at(ArrayIndex).GetSize(); } #endif @@ -923,10 +923,10 @@ void SMPBasicBlock::SSALocalRenumber(void) { #endif CurrUse = (*InstIter)->SetUseSSA(UseOp, SSANum); if (SSANum >= 0) { // skip USE before DEF names - if ((size_t) SSANum > this->LocalDUChains.ChainsByName.at(NameIndex).DUChains.size()) + if ((size_t) SSANum > this->LocalDUChains.ChainsByName.at(NameIndex).GetSize()) msg("ERROR: SSANum %d out of range in SSALocalRenumber.\n", SSANum); // Push address of USE instruction onto the DEF-USE chain for this SSANum. - this->LocalDUChains.ChainsByName.at(NameIndex).DUChains.at(SSANum).PushUse((*InstIter)->GetAddr()); + this->LocalDUChains.ChainsByName.at(NameIndex).PushUse(SSANum, (*InstIter)->GetAddr()); } } ++CurrUse; @@ -946,13 +946,13 @@ void SMPBasicBlock::SSALocalRenumber(void) { // Put new SSA number into DEF list entry in the instruction. CurrDef = (*InstIter)->SetDefSSA(DefOp, SSANum); // Before the push_back() call, we should have # chains equal to new SSANum - assert(SSANum == (int) this->LocalDUChains.ChainsByName.at(NameIndex).DUChains.size()); + assert(SSANum == (int) this->LocalDUChains.ChainsByName.at(NameIndex).GetSize()); SetGlobalIndex(&DefOp, NameIndex); // Set up a new DU chain and push it onto the vector of DU chains for this // local name. Push the DEF onto the list (it will be the first reference // on the list, because the list was newly created). SMPDefUseChain TempDefChain(DefOp, (*InstIter)->GetAddr()); - this->LocalDUChains.ChainsByName.at(NameIndex).DUChains.push_back(TempDefChain); + this->LocalDUChains.ChainsByName.at(NameIndex).PushChain(TempDefChain); } ++CurrDef; } // end for all DEFs in the instruction @@ -960,7 +960,7 @@ void SMPBasicBlock::SSALocalRenumber(void) { #if SMP_COUNT_MEMORY_ALLOCATIONS for (size_t ArrayIndex = 0; ArrayIndex < this->LocalDUChains.ChainsByName.size(); ++ArrayIndex) { - SMPDefUseChainCount += this->LocalDUChains.ChainsByName.at(ArrayIndex).DUChains.size(); + SMPDefUseChainCount += this->LocalDUChains.ChainsByName.at(ArrayIndex).GetSize(); } #endif @@ -1008,7 +1008,7 @@ unsigned int SMPBasicBlock::GetLocalDUIndex(op_t DefOp, int SSANum) { // DefOp is in the LocalNames, as expected RegIndex = ExtractGlobalIndex(*NameIter); assert(0 <= SSANum); - assert(SSANum < (int) this->LocalDUChains.ChainsByName.at(RegIndex).DUChains.size()); + assert(SSANum < (int) this->LocalDUChains.ChainsByName.at(RegIndex).GetSize()); } return RegIndex; } // end of SMPBasicBlock::GetLocalDUIndex() @@ -1035,30 +1035,30 @@ unsigned int SMPBasicBlock::GetGlobalDUIndex(op_t DefOp, ea_t DefAddr) { // Any global DU chains for DefOp? bool SMPBasicBlock::HasGlobalDUChain(op_t DefOp, ea_t DefAddr) { unsigned int DUIndex = this->GetGlobalDUIndex(DefOp, DefAddr); - size_t NumChains = this->GlobalDUChains.ChainsByName.at(DUIndex).DUChains.size(); + size_t NumChains = this->GlobalDUChains.ChainsByName.at(DUIndex).GetSize(); return (0 < NumChains); } // Any global DU chains for DUIndex? bool SMPBasicBlock::IsGlobalReferenced(unsigned int DUIndex) { - size_t NumChains = this->GlobalDUChains.ChainsByName.at(DUIndex).DUChains.size(); + size_t NumChains = this->GlobalDUChains.ChainsByName.at(DUIndex).GetSize(); return (0 < NumChains); } // For the local Def-Use chain for DefOp/SSANum, return the IndWrite flag. bool SMPBasicBlock::GetLocalDUChainIndWrite(op_t DefOp, int SSANum) { unsigned int DUIndex = this->GetLocalDUIndex(DefOp, SSANum); - return this->LocalDUChains.ChainsByName.at(DUIndex).DUChains.at(SSANum).HasIndirectWrite(); + return this->LocalDUChains.ChainsByName.at(DUIndex).HasIndirectWrite(SSANum); } // For the global Def-Use chain for DefOp at DefAddr, return the IndWrite flag. bool SMPBasicBlock::GetGlobalDUChainIndWrite(op_t DefOp, ea_t DefAddr) { unsigned int DUIndex = this->GetGlobalDUIndex(DefOp, DefAddr); size_t chain; - size_t NumChains = this->GlobalDUChains.ChainsByName.at(DUIndex).DUChains.size(); + size_t NumChains = this->GlobalDUChains.ChainsByName.at(DUIndex).GetSize(); for (chain = 0; chain < NumChains; ++chain) { - if (DefAddr == this->GlobalDUChains.ChainsByName.at(DUIndex).DUChains.at(chain).GetDef()) { + if (DefAddr == this->GlobalDUChains.ChainsByName.at(DUIndex).GetDef(chain)) { // Found the chain with matching DefAddr. - return this->GlobalDUChains.ChainsByName.at(DUIndex).DUChains.at(chain).HasIndirectWrite(); + return this->GlobalDUChains.ChainsByName.at(DUIndex).HasIndirectWrite(chain); } } return false; // not found; pass-through case, global not def or use in block @@ -1067,8 +1067,8 @@ bool SMPBasicBlock::GetGlobalDUChainIndWrite(op_t DefOp, ea_t DefAddr) { // Is DU-chain at DefAddr the last one for global DefOp? bool SMPBasicBlock::IsLastGlobalChain(op_t DefOp, ea_t DefAddr) { unsigned int DUIndex = this->GetGlobalDUIndex(DefOp, DefAddr); - size_t LastIndex = this->GlobalDUChains.ChainsByName.at(DUIndex).DUChains.size() - 1; - ea_t LastDefAddr = this->GlobalDUChains.ChainsByName.at(DUIndex).DUChains.at(LastIndex).GetDef(); + size_t LastIndex = this->GlobalDUChains.ChainsByName.at(DUIndex).GetSize() - 1; + ea_t LastDefAddr = this->GlobalDUChains.ChainsByName.at(DUIndex).GetDef(LastIndex); return (DefAddr == LastDefAddr); } // end of SMPBasicBlock::IsLastGlobalChain() @@ -1310,9 +1310,9 @@ bool SMPBasicBlock::PropagateLocalDefType(op_t DefOp, SMPOperandType DefType, ea unsigned int RegIndex = this->GetLocalDUIndex(DefOp, SSANum); - ea_t StartAddr = this->LocalDUChains.ChainsByName.at(RegIndex).DUChains.at(SSANum).GetDef(); + ea_t StartAddr = this->LocalDUChains.ChainsByName.at(RegIndex).GetDef(SSANum); assert(DefAddr == StartAddr); - ea_t LastAddr = this->LocalDUChains.ChainsByName.at(RegIndex).DUChains.at(SSANum).GetLastUse(); + ea_t LastAddr = this->LocalDUChains.ChainsByName.at(RegIndex).GetLastUse(SSANum); if (BADADDR == LastAddr) return false; // DEF had no USEs, so no propagation set<DefOrUse, LessDefUse>::iterator CurrUse; @@ -1610,8 +1610,8 @@ bool SMPBasicBlock::PropagateLocalMetadata(op_t UseOp, SMPMetadataType Status, i LocIndex = ExtractGlobalIndex(*NameIter); assert(0 <= SSANum); - assert(SSANum < (int) this->LocalDUChains.ChainsByName.at(LocIndex).DUChains.size()); - ea_t StartAddr = this->LocalDUChains.ChainsByName.at(LocIndex).DUChains.at(SSANum).GetDef(); + assert(SSANum < (int) this->LocalDUChains.ChainsByName.at(LocIndex).GetSize()); + ea_t StartAddr = this->LocalDUChains.ChainsByName.at(LocIndex).GetDef(SSANum); // Find the instruction at StartAddr list<list<SMPInstr>::iterator>::iterator InstIter; @@ -1758,10 +1758,10 @@ bool SMPBasicBlock::InferLocalDefType(op_t DefOp, unsigned int LocIndex, ea_t De } int SSANum = CurrDef->GetSSANum(); assert(0 <= SSANum); - assert(SSANum < (int) this->LocalDUChains.ChainsByName.at(LocIndex).DUChains.size()); - ea_t StartAddr = this->LocalDUChains.ChainsByName.at(LocIndex).DUChains.at(SSANum).GetDef(); + assert(SSANum < (int) this->LocalDUChains.ChainsByName.at(LocIndex).GetSize()); + ea_t StartAddr = this->LocalDUChains.ChainsByName.at(LocIndex).GetDef(SSANum); assert(DefAddr == StartAddr); - ea_t LastAddr = this->LocalDUChains.ChainsByName.at(LocIndex).DUChains.at(SSANum).GetLastUse(); + ea_t LastAddr = this->LocalDUChains.ChainsByName.at(LocIndex).GetLastUse(SSANum); if (BADADDR == LastAddr) return false; // DEF had no USEs, so no inference from USEs is possible set<DefOrUse, LessDefUse>::iterator CurrUse; @@ -1944,7 +1944,7 @@ bool SMPBasicBlock::IsGlobalRegDead(ea_t InstAddr, op_t Operand, unsigned int Re bool FoundInLiveOutSet = (LiveOutSet.end() != LiveOutSet.find(Operand)); bool FoundInUpExposedSet = (UpExposedSet.end() != UpExposedSet.find(Operand)); bool FoundInKillSet = (KillSet.end() != KillSet.find(Operand)); - bool HasLocalChains = (0 < this->GlobalDUChains.ChainsByName.at(RegIndex).DUChains.size()); + bool HasLocalChains = (0 < this->GlobalDUChains.ChainsByName.at(RegIndex).GetSize()); bool DebugFlag = (0x804837b == InstAddr); if (DebugFlag) { @@ -1955,7 +1955,7 @@ bool SMPBasicBlock::IsGlobalRegDead(ea_t InstAddr, op_t Operand, unsigned int Re } size_t LocalUseIndex; - size_t LocalUseMax = this->GlobalDUChains.ChainsByName.at(RegIndex).DUChains.size() - 1; + size_t LocalUseMax = this->GlobalDUChains.ChainsByName.at(RegIndex).GetSize() - 1; if (DebugFlag) msg("A"); // If there are no local chains for this global name, then it is either the pass-through @@ -1979,7 +1979,7 @@ bool SMPBasicBlock::IsGlobalRegDead(ea_t InstAddr, op_t Operand, unsigned int Re // If it is not in the UpExposed set and is in the Kill set, it is dead // before the first def if (!FoundInUpExposedSet && FoundInKillSet) { - ea_t StartAddr = this->GlobalDUChains.ChainsByName.at(RegIndex).DUChains.at(0).GetDef(); + ea_t StartAddr = this->GlobalDUChains.ChainsByName.at(RegIndex).GetDef(0); if ((BADADDR != StartAddr) && (InstAddr <= StartAddr)) return true; } @@ -1987,7 +1987,7 @@ bool SMPBasicBlock::IsGlobalRegDead(ea_t InstAddr, op_t Operand, unsigned int Re if (DebugFlag) msg("D"); // If it is in the UpExposedSet, it is live until the last use of the first chain if (FoundInUpExposedSet) { - ea_t LastAddr = this->GlobalDUChains.ChainsByName.at(RegIndex).DUChains.at(0).GetLastUse(); + ea_t LastAddr = this->GlobalDUChains.ChainsByName.at(RegIndex).GetLastUse(0); if ((BADADDR != LastAddr) && (InstAddr <= LastAddr)) return false; } @@ -1995,7 +1995,7 @@ bool SMPBasicBlock::IsGlobalRegDead(ea_t InstAddr, op_t Operand, unsigned int Re if (DebugFlag) msg("E"); // If it is not Live-Out, then it is dead after the last use if (!FoundInLiveOutSet) { - ea_t LastAddr = this->GlobalDUChains.ChainsByName.at(RegIndex).DUChains.at(LocalUseMax).GetLastUse(); + ea_t LastAddr = this->GlobalDUChains.ChainsByName.at(RegIndex).GetLastUse(LocalUseMax); if ((BADADDR != LastAddr) && (InstAddr > LastAddr)) return true; } @@ -2003,7 +2003,7 @@ bool SMPBasicBlock::IsGlobalRegDead(ea_t InstAddr, op_t Operand, unsigned int Re if (DebugFlag) msg("F"); //If it is LiveOut and it is in the Kill Set, it will be live after the last definition if (FoundInLiveOutSet && FoundInKillSet) { - ea_t DefAddr = this->GlobalDUChains.ChainsByName.at(RegIndex).DUChains.at(LocalUseMax).GetDef(); + ea_t DefAddr = this->GlobalDUChains.ChainsByName.at(RegIndex).GetDef(LocalUseMax); if ((BADADDR != DefAddr) && (DefAddr < InstAddr)) // **!!** <= or < ? return false; } @@ -2014,11 +2014,11 @@ bool SMPBasicBlock::IsGlobalRegDead(ea_t InstAddr, op_t Operand, unsigned int Re // Need to check here to not break if this block does not have a def for this (LiveIn) // Skip this check if it is UpExposed and this is the first chain if (!FoundInUpExposedSet || LocalUseIndex > 0) { - ea_t StartAddr = this->GlobalDUChains.ChainsByName.at(RegIndex).DUChains.at(LocalUseIndex).GetDef(); + ea_t StartAddr = this->GlobalDUChains.ChainsByName.at(RegIndex).GetDef(LocalUseIndex); if (StartAddr >= InstAddr) continue; // cannot overlap USE if DEF is after InstAddr } - ea_t LastAddr = this->GlobalDUChains.ChainsByName.at(RegIndex).DUChains.at(LocalUseIndex).GetLastUse(); + ea_t LastAddr = this->GlobalDUChains.ChainsByName.at(RegIndex).GetLastUse(LocalUseIndex); if (DebugFlag) msg(" LastAddr: %x\n", LastAddr); if ((BADADDR != LastAddr) && (LastAddr >= InstAddr)) { if (DebugFlag) msg("Ga"); @@ -2038,11 +2038,11 @@ bool SMPBasicBlock::IsRegDead(ea_t InstAddr, unsigned int RegIndex) const { size_t SSAIndex; // See if any DEF-USE chains overlap InstAddr's USEs. assert(RegIndex < this->LocalDUChains.ChainsByName.size()); - for (SSAIndex = 0; SSAIndex < this->LocalDUChains.ChainsByName.at(RegIndex).DUChains.size(); ++SSAIndex) { - ea_t StartAddr = this->LocalDUChains.ChainsByName.at(RegIndex).DUChains.at(SSAIndex).GetDef(); + for (SSAIndex = 0; SSAIndex < this->LocalDUChains.ChainsByName.at(RegIndex).GetSize(); ++SSAIndex) { + ea_t StartAddr = this->LocalDUChains.ChainsByName.at(RegIndex).GetDef(SSAIndex); if (StartAddr >= InstAddr) continue; // cannot overlap USE if DEF is after InstAddr - ea_t LastAddr = this->LocalDUChains.ChainsByName.at(RegIndex).DUChains.at(SSAIndex).GetLastUse(); + ea_t LastAddr = this->LocalDUChains.ChainsByName.at(RegIndex).GetLastUse(SSAIndex); if ((BADADDR != LastAddr) && (LastAddr >= InstAddr)) return false; } @@ -2188,30 +2188,30 @@ bool SMPBasicBlock::IsDefDead(ea_t DefAddr, op_t DefOp) { DUIndex = ExtractGlobalIndex(*LocalIter); size_t SSAIndex; assert(DUIndex < this->LocalDUChains.ChainsByName.size()); - NumChains = this->LocalDUChains.ChainsByName.at(DUIndex).DUChains.size(); + NumChains = this->LocalDUChains.ChainsByName.at(DUIndex).GetSize(); for (SSAIndex = 0; SSAIndex < NumChains; ++SSAIndex) { - if (DefAddr == this->LocalDUChains.ChainsByName.at(DUIndex).DUChains.at(SSAIndex).GetDef()) { + if (DefAddr == this->LocalDUChains.ChainsByName.at(DUIndex).GetDef(SSAIndex)) { break; } } assert(SSAIndex < NumChains); // found it // If it has no uses, it is dead. Being a local name, there is no LiveOut possibility. - DefDead = (0 == this->LocalDUChains.ChainsByName.at(DUIndex).DUChains.at(SSAIndex).GetNumUses()); + DefDead = (0 == this->LocalDUChains.ChainsByName.at(DUIndex).GetNumUses(SSAIndex)); } else { // global name DUIndex = this->GetGlobalDUIndex(DefOp, DefAddr); - NumChains = this->GlobalDUChains.ChainsByName.at(DUIndex).DUChains.size(); + NumChains = this->GlobalDUChains.ChainsByName.at(DUIndex).GetSize(); assert(0 < NumChains); bool FoundIndex = false; size_t ChainIndex; for (ChainIndex = 0; ChainIndex < NumChains; ++ChainIndex) { - if (DefAddr == this->GlobalDUChains.ChainsByName.at(DUIndex).DUChains.at(ChainIndex).GetDef()) { + if (DefAddr == this->GlobalDUChains.ChainsByName.at(DUIndex).GetDef(ChainIndex)) { FoundIndex = true; break; } } assert(FoundIndex); - if (0 == this->GlobalDUChains.ChainsByName.at(DUIndex).DUChains.at(ChainIndex).GetNumUses()) { + if (0 == this->GlobalDUChains.ChainsByName.at(DUIndex).GetNumUses(ChainIndex)) { // No uses in that chain. If it is not the last chain, then DefOp is redefined and this // DEF is truly dead. If it is the last chain and DefOp is in the LiveOut set, then it // is not dead. @@ -2649,33 +2649,33 @@ void SMPBasicBlock::MarkIndWriteChains(ea_t InstAddr) { // Iterate through all local names that have DU chains. size_t NameIndex, SSAIndex; for (NameIndex = 0; NameIndex < this->LocalDUChains.ChainsByName.size(); ++NameIndex) { - for (SSAIndex = 0; SSAIndex < this->LocalDUChains.ChainsByName.at(NameIndex).DUChains.size(); ++SSAIndex) { - if ((InstAddr > this->LocalDUChains.ChainsByName.at(NameIndex).DUChains.at(SSAIndex).GetDef()) - && (InstAddr < this->LocalDUChains.ChainsByName.at(NameIndex).DUChains.at(SSAIndex).GetLastUse())) { - this->LocalDUChains.ChainsByName.at(NameIndex).DUChains.at(SSAIndex).SetIndWrite(true); + for (SSAIndex = 0; SSAIndex < this->LocalDUChains.ChainsByName.at(NameIndex).GetSize(); ++SSAIndex) { + if ((InstAddr > this->LocalDUChains.ChainsByName.at(NameIndex).GetDef(SSAIndex)) + && (InstAddr < this->LocalDUChains.ChainsByName.at(NameIndex).GetLastUse(SSAIndex))) { + this->LocalDUChains.ChainsByName.at(NameIndex).SetIndWrite(SSAIndex, true); } } } // Iterate through all global names that have DU chains. for (NameIndex = 0; NameIndex < this->GlobalDUChains.ChainsByName.size(); ++NameIndex) { - size_t SSALimit = this->GlobalDUChains.ChainsByName.at(NameIndex).DUChains.size(); + size_t SSALimit = this->GlobalDUChains.ChainsByName.at(NameIndex).GetSize(); for (SSAIndex = 0; SSAIndex < SSALimit; ++SSAIndex) { - bool AfterDef = (InstAddr > this->GlobalDUChains.ChainsByName.at(NameIndex).DUChains.at(SSAIndex).GetDef()); - bool BeforeLastUse = (InstAddr < this->GlobalDUChains.ChainsByName.at(NameIndex).DUChains.at(SSAIndex).GetLastUse()); + bool AfterDef = (InstAddr > this->GlobalDUChains.ChainsByName.at(NameIndex).GetDef(SSAIndex)); + bool BeforeLastUse = (InstAddr < this->GlobalDUChains.ChainsByName.at(NameIndex).GetLastUse(SSAIndex)); if (AfterDef) { if (BeforeLastUse) { - this->GlobalDUChains.ChainsByName.at(NameIndex).DUChains.at(SSAIndex).SetIndWrite(true); + this->GlobalDUChains.ChainsByName.at(NameIndex).SetIndWrite(SSAIndex, true); } // If the chain is the last SSA index for this global name, // and the global name is LiveOut, then the chain really // extends to the end of the block. else if (SSAIndex == (SSALimit - 1)) { // last chain for name // Check for LiveOut - op_t GlobalOp = this->GlobalDUChains.ChainsByName.at(NameIndex).DUChains.at(0).GetName(); + op_t GlobalOp = this->GlobalDUChains.ChainsByName.at(NameIndex).GetName(); if (this->IsLiveOut(GlobalOp)) { // live out; indirect write inside chain - this->GlobalDUChains.ChainsByName.at(NameIndex).DUChains.at(SSAIndex).SetIndWrite(true); + this->GlobalDUChains.ChainsByName.at(NameIndex).SetIndWrite(SSAIndex, true); } } } // end if (AfterDef) diff --git a/SMPDataFlowAnalysis.cpp b/SMPDataFlowAnalysis.cpp index 24f4b0c78817ab9813c1d65718f64ba22d70a7b7..c398f91f65ad5f691bac50aa74a3132b6fa39a58 100644 --- a/SMPDataFlowAnalysis.cpp +++ b/SMPDataFlowAnalysis.cpp @@ -1318,7 +1318,7 @@ void SMPDUChainArray::SetName(op_t Name) { // DEBUG dump. void SMPDUChainArray::Dump(void) { size_t index; - for (index = 0; index < this->DUChains.size(); ++index) { + for (index = 0; index < this->GetSize(); ++index) { this->DUChains.at(index).Dump((int) index); } return; diff --git a/SMPDataFlowAnalysis.h b/SMPDataFlowAnalysis.h index 30d8ec61f8279e219c0d91ccc29177726218a99f..c4ce7a438cdd35d82e79514238e31067f0578522 100644 --- a/SMPDataFlowAnalysis.h +++ b/SMPDataFlowAnalysis.h @@ -520,7 +520,7 @@ public: inline size_t GetNumUses(void) const { return RefInstrs.size() - 1; }; // Query methods. - inline bool HasIndirectWrite(void) { return IndWrite; }; + inline bool HasIndirectWrite(void) const { return IndWrite; }; // Set methods void SetName(op_t Name); @@ -540,13 +540,24 @@ public: // Constructor SMPDUChainArray(void); SMPDUChainArray(op_t Name); + // Get methods. + inline op_t GetName(void) const { return SSAName; }; + inline ea_t GetDef(int SSANum) const { return DUChains.at(SSANum).GetDef(); }; + inline ea_t GetLastUse(int SSANum) const { return DUChains.at(SSANum).GetLastUse(); }; + inline size_t GetNumUses(int SSANum) const { return DUChains.at(SSANum).GetNumUses(); }; + inline size_t GetSize(void) const { return DUChains.size(); }; // Set methods. void SetName(op_t Name); + inline void PushUse(int SSANum, ea_t UseAddr) { DUChains.at(SSANum).PushUse(UseAddr); }; + inline void PushChain(SMPDefUseChain NewChain) { DUChains.push_back(NewChain); }; + inline void SetIndWrite(int SSANum, bool NewFlag) { DUChains.at(SSANum).SetIndWrite(NewFlag); }; + // Query methods + inline bool HasIndirectWrite(int SSANum) const { return DUChains.at(SSANum).HasIndirectWrite(); }; // Printing methods. void Dump(void); - // Data (public for convenience) - vector<SMPDefUseChain> DUChains; // indexed by SSA number for local chains private: + // Data + vector<SMPDefUseChain> DUChains; // indexed by SSA number for local chains op_t SSAName; // What variable is used in all chains in the array? }; // end class SMPDUChainArray