[lld] r198037 - Micro-optimize Resolver::markLive().
Rui Ueyama
ruiu at google.com
Wed Dec 25 23:13:28 PST 2013
Author: ruiu
Date: Thu Dec 26 01:13:28 2013
New Revision: 198037
URL: http://llvm.org/viewvc/llvm-project?rev=198037&view=rev
Log:
Micro-optimize Resolver::markLive().
This patch eliminates one std::set lookup per a function call.
Modified:
lld/trunk/lib/Core/Resolver.cpp
Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=198037&r1=198036&r2=198037&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Thu Dec 26 01:13:28 2013
@@ -308,16 +308,14 @@ void Resolver::updateReferences() {
}
}
-// for dead code stripping, recursively mark atoms "live"
+// For dead code stripping, recursively mark atoms "live"
void Resolver::markLive(const Atom &atom) {
- // if already marked live, then done (stop recursion)
- if (_liveAtoms.count(&atom))
+ // Mark the atom is live. If it's already marked live, then stop recursion.
+ auto exists = _liveAtoms.insert(&atom);
+ if (!exists.second)
return;
- // mark this atom is live
- _liveAtoms.insert(&atom);
-
- // mark all atoms it references as live
+ // Mark all atoms it references as live
if (const DefinedAtom *defAtom = dyn_cast<DefinedAtom>(&atom))
for (const Reference *ref : *defAtom)
if (const Atom *target = ref->target())
More information about the llvm-commits
mailing list