Skip to content

Commit f4ee62c

Browse files
[IPO] Avoid repeated hash lookups (NFC) (llvm#131068)
1 parent e838ca1 commit f4ee62c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

llvm/lib/Transforms/IPO/IROutliner.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,8 +1478,9 @@ CallInst *replaceCalledFunction(Module &M, OutlinableRegion &Region) {
14781478
}
14791479

14801480
// If it is a constant, we simply add it to the argument list as a value.
1481-
if (Region.AggArgToConstant.contains(AggArgIdx)) {
1482-
Constant *CST = Region.AggArgToConstant.find(AggArgIdx)->second;
1481+
if (auto It = Region.AggArgToConstant.find(AggArgIdx);
1482+
It != Region.AggArgToConstant.end()) {
1483+
Constant *CST = It->second;
14831484
LLVM_DEBUG(dbgs() << "Setting argument " << AggArgIdx << " to value "
14841485
<< *CST << "\n");
14851486
NewCallArgs.push_back(CST);
@@ -1612,9 +1613,10 @@ getPassedArgumentAndAdjustArgumentLocation(const Argument *A,
16121613

16131614
// If it is a constant, we can look at our mapping from when we created
16141615
// the outputs to figure out what the constant value is.
1615-
if (Region.AggArgToConstant.count(ArgNum))
1616-
return Region.AggArgToConstant.find(ArgNum)->second;
1617-
1616+
if (auto It = Region.AggArgToConstant.find(ArgNum);
1617+
It != Region.AggArgToConstant.end())
1618+
return It->second;
1619+
16181620
// If it is not a constant, and we are not looking at the overall function, we
16191621
// need to adjust which argument we are looking at.
16201622
ArgNum = Region.AggArgToExtracted.find(ArgNum)->second;
@@ -2693,12 +2695,13 @@ void IROutliner::updateOutputMapping(OutlinableRegion &Region,
26932695
if (!OutputIdx)
26942696
return;
26952697

2696-
if (!OutputMappings.contains(Outputs[*OutputIdx])) {
2698+
auto It = OutputMappings.find(Outputs[*OutputIdx]);
2699+
if (It == OutputMappings.end()) {
26972700
LLVM_DEBUG(dbgs() << "Mapping extracted output " << *LI << " to "
26982701
<< *Outputs[*OutputIdx] << "\n");
26992702
OutputMappings.insert(std::make_pair(LI, Outputs[*OutputIdx]));
27002703
} else {
2701-
Value *Orig = OutputMappings.find(Outputs[*OutputIdx])->second;
2704+
Value *Orig = It->second;
27022705
LLVM_DEBUG(dbgs() << "Mapping extracted output " << *Orig << " to "
27032706
<< *Outputs[*OutputIdx] << "\n");
27042707
OutputMappings.insert(std::make_pair(LI, Orig));

0 commit comments

Comments
 (0)