[lld/mac] Make X86_64::getImplicitAddend not do heap allocations
authorNico Weber <thakis@chromium.org>
Mon, 7 Dec 2020 14:05:46 +0000 (09:05 -0500)
committerNico Weber <thakis@chromium.org>
Mon, 7 Dec 2020 14:23:51 +0000 (09:23 -0500)
Speeds up linking Chromium's base_unittests almost 10%. According to ministat:

    N           Min           Max        Median           Avg        Stddev
x   5    0.72193289    0.73073196    0.72560811    0.72565799  0.0032265649
+   5    0.64069581    0.67173195    0.65876389    0.65796089   0.011349451
Difference at 95.0% confidence
-0.0676971 +/- 0.0121682
-9.32906% +/- 1.67685%
(Student's t, pooled s = 0.00834328)

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

lld/MachO/Arch/X86_64.cpp

index 19e62a9..7f4024c 100644 (file)
@@ -52,9 +52,8 @@ static std::string getErrorLocation(MemoryBufferRef mb, const section_64 &sec,
 
 static void validateLength(MemoryBufferRef mb, const section_64 &sec,
                            const relocation_info &rel,
-                           const std::vector<uint8_t> &validLengths) {
-  if (std::find(validLengths.begin(), validLengths.end(), rel.r_length) !=
-      validLengths.end())
+                           ArrayRef<uint8_t> validLengths) {
+  if (find(validLengths, rel.r_length) != validLengths.end())
     return;
 
   std::string msg = getErrorLocation(mb, sec, rel) + ": relocations of type " +