forked from OSchip/llvm-project
Fix a bunch of other places that used operator[] to test whether
a key is present in a std::map or DenseMap to use find instead. llvm-svn: 74676
This commit is contained in:
parent
f7691d398d
commit
43f33dd550
|
@ -618,8 +618,9 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
DomTreeNodeBase<NodeT> *getNodeForBlock(NodeT *BB) {
|
DomTreeNodeBase<NodeT> *getNodeForBlock(NodeT *BB) {
|
||||||
if (DomTreeNodeBase<NodeT> *BBNode = this->DomTreeNodes[BB])
|
typename DomTreeNodeMapType::iterator I = this->DomTreeNodes.find(BB);
|
||||||
return BBNode;
|
if (I != this->DomTreeNodes.end() && I->second)
|
||||||
|
return I->second;
|
||||||
|
|
||||||
// Haven't calculated this node yet? Get or calculate the node for the
|
// Haven't calculated this node yet? Get or calculate the node for the
|
||||||
// immediate dominator.
|
// immediate dominator.
|
||||||
|
|
|
@ -452,8 +452,9 @@ bool X86FastISel::X86SelectAddress(Value *V, X86AddressMode &AM, bool isCall) {
|
||||||
if (Subtarget->GVRequiresExtraLoad(GV, TM, isCall)) {
|
if (Subtarget->GVRequiresExtraLoad(GV, TM, isCall)) {
|
||||||
// Check to see if we've already materialized this
|
// Check to see if we've already materialized this
|
||||||
// value in a register in this block.
|
// value in a register in this block.
|
||||||
if (unsigned Reg = LocalValueMap[V]) {
|
DenseMap<const Value *, unsigned>::iterator I = LocalValueMap.find(V);
|
||||||
AM.Base.Reg = Reg;
|
if (I != LocalValueMap.end() && I->second != 0) {
|
||||||
|
AM.Base.Reg = I->second;
|
||||||
AM.GV = 0;
|
AM.GV = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -935,9 +935,11 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB, BasicBlock *PredBB,
|
||||||
|
|
||||||
// Remap operands to patch up intra-block references.
|
// Remap operands to patch up intra-block references.
|
||||||
for (unsigned i = 0, e = New->getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = New->getNumOperands(); i != e; ++i)
|
||||||
if (Instruction *Inst = dyn_cast<Instruction>(New->getOperand(i)))
|
if (Instruction *Inst = dyn_cast<Instruction>(New->getOperand(i))) {
|
||||||
if (Value *Remapped = ValueMapping[Inst])
|
DenseMap<Instruction*, Value*>::iterator I = ValueMapping.find(Inst);
|
||||||
New->setOperand(i, Remapped);
|
if (I != ValueMapping.end())
|
||||||
|
New->setOperand(i, I->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We didn't copy the terminator from BB over to NewBB, because there is now
|
// We didn't copy the terminator from BB over to NewBB, because there is now
|
||||||
|
@ -953,9 +955,11 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB, BasicBlock *PredBB,
|
||||||
Value *IV = PN->getIncomingValueForBlock(BB);
|
Value *IV = PN->getIncomingValueForBlock(BB);
|
||||||
|
|
||||||
// Remap the value if necessary.
|
// Remap the value if necessary.
|
||||||
if (Instruction *Inst = dyn_cast<Instruction>(IV))
|
if (Instruction *Inst = dyn_cast<Instruction>(IV)) {
|
||||||
if (Value *MappedIV = ValueMapping[Inst])
|
DenseMap<Instruction*, Value*>::iterator I = ValueMapping.find(Inst);
|
||||||
IV = MappedIV;
|
if (I != ValueMapping.end())
|
||||||
|
IV = I->second;
|
||||||
|
}
|
||||||
PN->addIncoming(IV, NewBB);
|
PN->addIncoming(IV, NewBB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -317,9 +317,12 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
|
||||||
//
|
//
|
||||||
BI = Branch; ++BI; // Get an iterator to the first new instruction
|
BI = Branch; ++BI; // Get an iterator to the first new instruction
|
||||||
for (; BI != SourceBlock->end(); ++BI)
|
for (; BI != SourceBlock->end(); ++BI)
|
||||||
for (unsigned i = 0, e = BI->getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = BI->getNumOperands(); i != e; ++i) {
|
||||||
if (Value *Remapped = ValueMapping[BI->getOperand(i)])
|
std::map<Value*, Value*>::const_iterator I =
|
||||||
BI->setOperand(i, Remapped);
|
ValueMapping.find(BI->getOperand(i));
|
||||||
|
if (I != ValueMapping.end())
|
||||||
|
BI->setOperand(i, I->second);
|
||||||
|
}
|
||||||
|
|
||||||
// Next we check to see if any of the successors of DestBlock had PHI nodes.
|
// Next we check to see if any of the successors of DestBlock had PHI nodes.
|
||||||
// If so, we need to add entries to the PHI nodes for SourceBlock now.
|
// If so, we need to add entries to the PHI nodes for SourceBlock now.
|
||||||
|
@ -333,8 +336,9 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
|
||||||
Value *IV = PN->getIncomingValueForBlock(DestBlock);
|
Value *IV = PN->getIncomingValueForBlock(DestBlock);
|
||||||
|
|
||||||
// Remap the value if necessary...
|
// Remap the value if necessary...
|
||||||
if (Value *MappedIV = ValueMapping[IV])
|
std::map<Value*, Value*>::const_iterator I = ValueMapping.find(IV);
|
||||||
IV = MappedIV;
|
if (I != ValueMapping.end())
|
||||||
|
IV = I->second;
|
||||||
PN->addIncoming(IV, SourceBlock);
|
PN->addIncoming(IV, SourceBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,10 @@ namespace {
|
||||||
virtual void emitBasicBlockStartAnnot(const BasicBlock *BB,
|
virtual void emitBasicBlockStartAnnot(const BasicBlock *BB,
|
||||||
raw_ostream &OS) {
|
raw_ostream &OS) {
|
||||||
if (BlockFreqs.empty()) return;
|
if (BlockFreqs.empty()) return;
|
||||||
if (unsigned Count = BlockFreqs[BB])
|
std::map<const BasicBlock *, unsigned>::const_iterator I =
|
||||||
OS << "\t;;; Basic block executed " << Count << " times.\n";
|
BlockFreqs.find(BB);
|
||||||
|
if (I != BlockFreqs.end())
|
||||||
|
OS << "\t;;; Basic block executed " << I->second << " times.\n";
|
||||||
else
|
else
|
||||||
OS << "\t;;; Never executed!\n";
|
OS << "\t;;; Never executed!\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue