-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Analysis] Avoid repeated hash lookups (NFC) #128394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Analysis] Avoid repeated hash lookups (NFC) #128394
Conversation
@llvm/pr-subscribers-llvm-analysis Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/128394.diff 1 Files Affected:
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index a1d91de3bb788..5988e40c56100 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1443,12 +1443,11 @@ void AccessAnalysis::processMemAccesses() {
UnderlyingObj->getType()->getPointerAddressSpace()))
continue;
- UnderlyingObjToAccessMap::iterator Prev =
- ObjToLastAccess.find(UnderlyingObj);
- if (Prev != ObjToLastAccess.end())
- DepCands.unionSets(Access, Prev->second);
+ auto [It, Inserted] =
+ ObjToLastAccess.try_emplace(UnderlyingObj, Access);
+ if (!Inserted)
+ DepCands.unionSets(Access, It->second);
- ObjToLastAccess[UnderlyingObj] = Access;
LLVM_DEBUG(dbgs() << " " << *UnderlyingObj << "\n");
}
}
|
@nikic Thanks for the review! I don't think my original PR was correct. Without my PR, we update the map in every iteration:
In the latest revision, I now update the map even when the lookup succeeds. If you could review this PR again, that would be greatly appreciated. Text "LGTM" would be fine. Thanks! |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/13498 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/81/builds/5045 Here is the relevant piece of the build log for the reference
|
No description provided.