Go to file
Sean Silva 2eed75926c Add `isRelExprOneOf` helper
In various places in LLD's hot loops, we have expressions of the form
"E == R_FOO || E == R_BAR || ..." (E is a RelExpr).

Some of these expressions are quite long, and even though they usually go just
a very small number of ways and so should be well predicted, they can still
occupy branch predictor resources harming other parts of the code, or they
won't be predicted well if they overflow branch predictor resources or if the
branches are too dense and the branch predictor can't track them all (the
compiler can in theory avoid this, at a cost in text size). And some of these
expressions are so large and executed so frequently that even when
well-predicted they probably still have a nontrivial cost.

This speedup should be pretty portable. The cost of these simple bit tests is
independent of:

- the target we are linking for
- the distribution of RelExpr's for a given link (which can depend on how the
  input files were compiled)
- what compiler was used to compile LLD (it is just a simple bit test;
  hopefully the compiler gets it right!)
- adding new target-dependent relocations (e.g. needsPlt doesn't pay any extra
  cost checking R_PPC_PLT_OPD on x86-64 builds)

I did some rough measurements on clang-fsds and this patch gives over about 4%
speedup for a regular -O1 link, about 2.5% for -O3 --gc-sections and over 5%
for -O0. Sorry, I don't have my current machine set up for doing really
accurate measurements right now.

This also is just a bit cleaner. Thanks for Joerg for suggesting for
this approach.

Differential Revision: https://reviews.llvm.org/D27156

llvm-svn: 288314
2016-12-01 05:43:48 +00:00
clang Teach ConstantBuilder how to emit a reference to the current position 2016-12-01 05:33:30 +00:00
clang-tools-extra [clang-tidy] Make format style customizable 2016-11-30 18:06:42 +00:00
compiler-rt Release memory to OS only when the requested range covers the entire page 2016-11-30 20:41:59 +00:00
debuginfo-tests New round of fixes for "Always compile debuginfo-tests for the host triple" 2014-10-18 23:47:59 +00:00
libclc Fix build since r286752. 2016-11-14 16:06:33 +00:00
libcxx Protect std::array tests under noexceptions 2016-11-29 17:10:29 +00:00
libcxxabi __cxa_demangle: use default member initialization 2016-11-18 19:01:53 +00:00
libunwind EHABI: mark some functions as exported 2016-11-17 23:53:35 +00:00
lld Add `isRelExprOneOf` helper 2016-12-01 05:43:48 +00:00
lldb Add another address to look for the kernel load addr in 2016-11-30 23:00:52 +00:00
llgo [llgo] add llgo source path to LLVM_GO_PACKAGES 2016-07-27 03:01:00 +00:00
llvm Revert previous whitespace change 2016-12-01 04:37:35 +00:00
openmp Fixed typo in kmp_process_deps trace output 2016-11-28 20:10:32 +00:00
parallel-libs [Acxxel] Remove setActiveDeviceForThread 2016-10-28 00:54:02 +00:00
polly Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes (NFC). 2016-11-29 18:14:12 +00:00