[PATCH] D156603: [SymbolSize] Improve the performance of SymbolSize computation
Steven Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 30 12:15:28 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf5974e80653d: [SymbolSize] Improve the performance of SymbolSize computation (authored by steven_wu).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156603/new/
https://reviews.llvm.org/D156603
Files:
llvm/lib/Object/SymbolSize.cpp
Index: llvm/lib/Object/SymbolSize.cpp
===================================================================
--- llvm/lib/Object/SymbolSize.cpp
+++ llvm/lib/Object/SymbolSize.cpp
@@ -84,16 +84,21 @@
array_pod_sort(Addresses.begin(), Addresses.end(), compareAddress);
- // Compute the size as the gap to the next symbol
- for (unsigned I = 0, N = Addresses.size() - 1; I < N; ++I) {
+ // Compute the size as the gap to the next symbol. If multiple symbols have
+ // the same address, give both the same size. Because Addresses is sorted,
+ // using two pointers to keep track of the current symbol vs. the next symbol
+ // that doesn't have the same address for size computation.
+ for (unsigned I = 0, NextI = 0, N = Addresses.size() - 1; I < N; ++I) {
auto &P = Addresses[I];
if (P.I == O.symbol_end())
continue;
- // If multiple symbol have the same address, give both the same size.
- unsigned NextI = I + 1;
- while (NextI < N && Addresses[NextI].Address == P.Address)
- ++NextI;
+ // If the next pointer is behind, update it to the next symbol.
+ if (NextI <= I) {
+ NextI = I + 1;
+ while (NextI < N && Addresses[NextI].Address == P.Address)
+ ++NextI;
+ }
uint64_t Size = Addresses[NextI].Address - P.Address;
P.Address = Size;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156603.545462.patch
Type: text/x-patch
Size: 1317 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230730/48ac34c3/attachment.bin>
More information about the llvm-commits
mailing list