[clang] 8aa76d3 - [Driver] Avoid repeated hash lookups (NFC) (#111225)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 5 09:49:51 PDT 2024
Author: Kazu Hirata
Date: 2024-10-05T09:49:49-07:00
New Revision: 8aa76d34ea95031abed32761251951c5f87492c6
URL: https://github.com/llvm/llvm-project/commit/8aa76d34ea95031abed32761251951c5f87492c6
DIFF: https://github.com/llvm/llvm-project/commit/8aa76d34ea95031abed32761251951c5f87492c6.diff
LOG: [Driver] Avoid repeated hash lookups (NFC) (#111225)
Added:
Modified:
clang/lib/Driver/Driver.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e9bf60d5e2ee46..2aaa52072b03d2 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -984,8 +984,9 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
} else
TC = &getToolChain(C.getInputArgs(), TT);
C.addOffloadDeviceToolChain(TC, Action::OFK_OpenMP);
- if (DerivedArchs.contains(TT.getTriple()))
- KnownArchs[TC] = DerivedArchs[TT.getTriple()];
+ auto It = DerivedArchs.find(TT.getTriple());
+ if (It != DerivedArchs.end())
+ KnownArchs[TC] = It->second;
}
}
} else if (C.getInputArgs().hasArg(options::OPT_fopenmp_targets_EQ)) {
@@ -3749,11 +3750,10 @@ class OffloadingActionBuilder final {
void recordHostAction(Action *HostAction, const Arg *InputArg) {
assert(HostAction && "Invalid host action");
assert(InputArg && "Invalid input argument");
- auto Loc = HostActionToInputArgMap.find(HostAction);
- if (Loc == HostActionToInputArgMap.end())
- HostActionToInputArgMap[HostAction] = InputArg;
- assert(HostActionToInputArgMap[HostAction] == InputArg &&
+ auto Loc = HostActionToInputArgMap.try_emplace(HostAction, InputArg).first;
+ assert(Loc->second == InputArg &&
"host action mapped to multiple input arguments");
+ (void)Loc;
}
/// Generate an action that adds device dependences (if any) to a host action.
@@ -5581,8 +5581,9 @@ InputInfoList Driver::BuildJobsForActionNoCache(
std::pair<const Action *, std::string> ActionTC = {
OA->getHostDependence(),
GetTriplePlusArchString(TC, BoundArch, TargetDeviceOffloadKind)};
- if (CachedResults.find(ActionTC) != CachedResults.end()) {
- InputInfoList Inputs = CachedResults[ActionTC];
+ auto It = CachedResults.find(ActionTC);
+ if (It != CachedResults.end()) {
+ InputInfoList Inputs = It->second;
Inputs.append(OffloadDependencesInputInfo);
return Inputs;
}
More information about the cfe-commits
mailing list