[llvm] r284249 - Move alignTo computation inside the if.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 14 10:01:40 PDT 2016
Author: rafael
Date: Fri Oct 14 12:01:39 2016
New Revision: 284249
URL: http://llvm.org/viewvc/llvm-project?rev=284249&view=rev
Log:
Move alignTo computation inside the if.
This is an improvement when compiling with llvm. llvm doesn't inline
the call to insert, so the align is always executed and shows up in
the profile.
With gcc the call to insert is inlined and the align computation moved
and done only if needed.
With this patch we explicitly only compute it if it is needed.
In the two tests with debug info, the speedup was
scylla
master 3.008959365
patch 2.932080942 1.02621974786x faster
firefox
master 6.709823604
patch 6.592387227 1.01781393795x faster
In all others the difference was in the noise.
Modified:
llvm/trunk/lib/MC/StringTableBuilder.cpp
Modified: llvm/trunk/lib/MC/StringTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/StringTableBuilder.cpp?rev=284249&r1=284248&r2=284249&view=diff
==============================================================================
--- llvm/trunk/lib/MC/StringTableBuilder.cpp (original)
+++ llvm/trunk/lib/MC/StringTableBuilder.cpp Fri Oct 14 12:01:39 2016
@@ -195,9 +195,11 @@ size_t StringTableBuilder::add(CachedHas
assert(S.size() > COFF::NameSize && "Short string in COFF string table!");
assert(!isFinalized());
- size_t Start = alignTo(Size, Alignment);
- auto P = StringIndexMap.insert(std::make_pair(S, Start));
- if (P.second)
+ auto P = StringIndexMap.insert(std::make_pair(S, 0));
+ if (P.second) {
+ size_t Start = alignTo(Size, Alignment);
+ P.first->second = Start;
Size = Start + S.size() + (K != RAW);
+ }
return P.first->second;
}
More information about the llvm-commits
mailing list