mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Reduce duplicated hash map lookups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162362 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fdeb9fe5e0
commit
05d96f98cb
@ -470,8 +470,10 @@ bool LazyValueInfoCache::hasBlockValue(Value *Val, BasicBlock *BB) {
|
||||
return true;
|
||||
|
||||
LVIValueHandle ValHandle(Val, this);
|
||||
if (!ValueCache.count(ValHandle)) return false;
|
||||
return ValueCache[ValHandle].count(BB);
|
||||
std::map<LVIValueHandle, ValueCacheEntryTy>::iterator I =
|
||||
ValueCache.find(ValHandle);
|
||||
if (I == ValueCache.end()) return false;
|
||||
return I->second.count(BB);
|
||||
}
|
||||
|
||||
LVILatticeVal LazyValueInfoCache::getBlockValue(Value *Val, BasicBlock *BB) {
|
||||
|
@ -429,8 +429,8 @@ void UnloopUpdater::updateSubloopParents() {
|
||||
Unloop->removeChildLoop(llvm::prior(Unloop->end()));
|
||||
|
||||
assert(SubloopParents.count(Subloop) && "DFS failed to visit subloop");
|
||||
if (SubloopParents[Subloop])
|
||||
SubloopParents[Subloop]->addChildLoop(Subloop);
|
||||
if (Loop *Parent = SubloopParents[Subloop])
|
||||
Parent->addChildLoop(Subloop);
|
||||
else
|
||||
LI->addTopLevelLoop(Subloop);
|
||||
}
|
||||
@ -456,9 +456,8 @@ Loop *UnloopUpdater::getNearestLoop(BasicBlock *BB, Loop *BBLoop) {
|
||||
assert(Subloop && "subloop is not an ancestor of the original loop");
|
||||
}
|
||||
// Get the current nearest parent of the Subloop exits, initially Unloop.
|
||||
if (!SubloopParents.count(Subloop))
|
||||
SubloopParents[Subloop] = Unloop;
|
||||
NearLoop = SubloopParents[Subloop];
|
||||
NearLoop =
|
||||
SubloopParents.insert(std::make_pair(Subloop, Unloop)).first->second;
|
||||
}
|
||||
|
||||
succ_iterator I = succ_begin(BB), E = succ_end(BB);
|
||||
|
@ -1554,8 +1554,7 @@ MachineBasicBlock::iterator findHoistingInsertPosAndDeps(MachineBasicBlock *MBB,
|
||||
for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI)
|
||||
Uses.insert(*AI);
|
||||
} else {
|
||||
if (Uses.count(Reg)) {
|
||||
Uses.erase(Reg);
|
||||
if (Uses.erase(Reg)) {
|
||||
for (MCSubRegIterator SubRegs(Reg, TRI); SubRegs.isValid(); ++SubRegs)
|
||||
Uses.erase(*SubRegs); // Use sub-registers to be conservative
|
||||
}
|
||||
|
@ -996,14 +996,13 @@ static void UpdatePredRedefs(MachineInstr *MI, SmallSet<unsigned,4> &Redefs,
|
||||
}
|
||||
for (unsigned i = 0, e = Defs.size(); i != e; ++i) {
|
||||
unsigned Reg = Defs[i];
|
||||
if (Redefs.count(Reg)) {
|
||||
if (!Redefs.insert(Reg)) {
|
||||
if (AddImpUse)
|
||||
// Treat predicated update as read + write.
|
||||
MI->addOperand(MachineOperand::CreateReg(Reg, false/*IsDef*/,
|
||||
true/*IsImp*/,false/*IsKill*/,
|
||||
false/*IsDead*/,true/*IsUndef*/));
|
||||
} else {
|
||||
Redefs.insert(Reg);
|
||||
for (MCSubRegIterator SubRegs(Reg, TRI); SubRegs.isValid(); ++SubRegs)
|
||||
Redefs.insert(*SubRegs);
|
||||
}
|
||||
|
@ -404,9 +404,9 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &MF) {
|
||||
}
|
||||
|
||||
void StrongPHIElimination::addReg(unsigned Reg) {
|
||||
if (RegNodeMap.count(Reg))
|
||||
return;
|
||||
RegNodeMap[Reg] = new (Allocator) Node(Reg);
|
||||
Node *&N = RegNodeMap[Reg];
|
||||
if (!N)
|
||||
N = new (Allocator) Node(Reg);
|
||||
}
|
||||
|
||||
StrongPHIElimination::Node*
|
||||
@ -714,8 +714,9 @@ void StrongPHIElimination::InsertCopiesForPHI(MachineInstr *PHI,
|
||||
assert(getRegColor(CopyReg) == CopyReg);
|
||||
}
|
||||
|
||||
if (!InsertedSrcCopyMap.count(std::make_pair(PredBB, PHIColor)))
|
||||
InsertedSrcCopyMap[std::make_pair(PredBB, PHIColor)] = CopyInstr;
|
||||
// Insert into map if not already there.
|
||||
InsertedSrcCopyMap.insert(std::make_pair(std::make_pair(PredBB, PHIColor),
|
||||
CopyInstr));
|
||||
}
|
||||
|
||||
SrcMO.setReg(CopyReg);
|
||||
|
@ -396,8 +396,7 @@ void MachObjectWriter::BindIndirectSymbols(MCAssembler &Asm) {
|
||||
continue;
|
||||
|
||||
// Initialize the section indirect symbol base, if necessary.
|
||||
if (!IndirectSymBase.count(it->SectionData))
|
||||
IndirectSymBase[it->SectionData] = IndirectIndex;
|
||||
IndirectSymBase.insert(std::make_pair(it->SectionData, IndirectIndex));
|
||||
|
||||
Asm.getOrCreateSymbolData(*it->Symbol);
|
||||
}
|
||||
@ -414,8 +413,7 @@ void MachObjectWriter::BindIndirectSymbols(MCAssembler &Asm) {
|
||||
continue;
|
||||
|
||||
// Initialize the section indirect symbol base, if necessary.
|
||||
if (!IndirectSymBase.count(it->SectionData))
|
||||
IndirectSymBase[it->SectionData] = IndirectIndex;
|
||||
IndirectSymBase.insert(std::make_pair(it->SectionData, IndirectIndex));
|
||||
|
||||
// Set the symbol type to undefined lazy, but only on construction.
|
||||
//
|
||||
|
@ -1388,10 +1388,9 @@ bool ARMConstantIslands::handleConstantPoolUser(unsigned CPUserIndex) {
|
||||
// If the original WaterList entry was "new water" on this iteration,
|
||||
// propagate that to the new island. This is just keeping NewWaterList
|
||||
// updated to match the WaterList, which will be updated below.
|
||||
if (NewWaterList.count(WaterBB)) {
|
||||
NewWaterList.erase(WaterBB);
|
||||
if (NewWaterList.erase(WaterBB))
|
||||
NewWaterList.insert(NewIsland);
|
||||
}
|
||||
|
||||
// The new CPE goes before the following block (NewMBB).
|
||||
NewMBB = llvm::next(MachineFunction::iterator(WaterBB));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user