Skip to content

Commit 1bc2108

Browse files
[Transforms] Avoid repeated hash lookups (NFC) (#131497)
1 parent 48ecec2 commit 1bc2108

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

llvm/lib/Transforms/IPO/FunctionAttrs.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ static FunctionSummary *calculatePrevailingSummary(
319319
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
320320
IsPrevailing) {
321321

322-
if (auto It = CachedPrevailingSummary.find(VI);
323-
It != CachedPrevailingSummary.end())
322+
auto [It, Inserted] = CachedPrevailingSummary.try_emplace(VI);
323+
if (!Inserted)
324324
return It->second;
325325

326326
/// At this point, prevailing symbols have been resolved. The following leads
@@ -363,7 +363,6 @@ static FunctionSummary *calculatePrevailingSummary(
363363
/// future this can be revisited.
364364
/// 5. Otherwise, go conservative.
365365

366-
CachedPrevailingSummary[VI] = nullptr;
367366
FunctionSummary *Local = nullptr;
368367
FunctionSummary *Prevailing = nullptr;
369368

@@ -764,12 +763,12 @@ ArgumentUsesSummary collectArgumentUsesPerBlock(Argument &A, Function &F) {
764763
auto UpdateUseInfo = [&Result](Instruction *I, ArgumentAccessInfo Info) {
765764
auto *BB = I->getParent();
766765
auto &BBInfo = Result.UsesPerBlock[BB];
767-
bool AlreadyVisitedInst = BBInfo.Insts.contains(I);
768-
auto &IInfo = BBInfo.Insts[I];
766+
auto [It, Inserted] = BBInfo.Insts.try_emplace(I);
767+
auto &IInfo = It->second;
769768

770769
// Instructions that have more than one use of the argument are considered
771770
// as clobbers.
772-
if (AlreadyVisitedInst) {
771+
if (!Inserted) {
773772
IInfo = {ArgumentAccessInfo::AccessType::Unknown, {}};
774773
BBInfo.HasUnknownAccess = true;
775774
return false;

0 commit comments

Comments
 (0)