mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-03 16:03:21 +00:00
Rui Ueyama
7d8263bf1d
COFF: Optimize ICF by comparing relocations before section contents.
equalsConstants() is the heaviest function in ICF, and that consumes more than half of total ICF execution time. Of which, section content comparison accounts for roughly one third. Previously, we compared section contents at the beginning of the function after comparing their checksums. The comparison is very likely to succeed because when the control reaches that comparison, their checksums are always equal. And because checksums are 64-bit CRC, they are unlikely to collide. We compared relocations and associative sections after that. If they are different, the time we spent on byte-by-byte comparison of section contents were wasted. This patch moves the comparison at the end of function. If the comparison fails, the time we spent on relocation comparison are wasted, but as I wrote it's very unlikely to happen. LLD took 1198 ms to link itself to produce a 27.11 MB executable. Of which, ICF accounted for 536 ms. This patch cuts it by 90 ms, which is 17% speedup of ICF and 7.5% speedup overall. All numbers are median of ten runs. llvm-svn: 247961
Description
llvm with tablegen backend for capstone disassembler
Languages
LLVM
34.8%
C++
32.7%
C
19.6%
Assembly
8.6%
MLIR
1.2%
Other
2.7%