Skip to content

Commit 9e9d15a

Browse files
committed
update tests and comments
Signed-off-by: Peter Rong <[email protected]>
1 parent 67e7f61 commit 9e9d15a

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

lld/MachO/BPSectionOrderer.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ getRelocHash(const Reloc &reloc,
6161
return getRelocHash(kind, sectionIdx.value_or(0), 0, reloc.addend);
6262
}
6363

64+
// Get a hash of the unwind info (after relocation).
65+
// This hash is not 100% accurate, but it's good enough for compression.
66+
//
67+
// Unwind info will be eliminated if it is the same with its neighboors.
68+
// We want to order functions such that the ones with similar unwind info
69+
// can stay together.
70+
// See more here:
71+
// https://faultlore.com/blah/compact-unwinding/#page-tables
6472
static uint64_t getUnwindInfoEncodingHash(const InputSection *isec) {
6573
for (Symbol *sym : isec->symbols) {
6674
if (auto *d = dyn_cast_or_null<Defined>(sym)) {

lld/MachO/UnwindInfoSection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct CompactUnwindEntry {
4242
Symbol *personality;
4343
InputSection *lsda;
4444

45+
// Relocate the entry to the given Symbol.
4546
void relocateOneCompactUnwindEntry(const Defined *d);
4647
};
4748

lld/test/MachO/bp-section-orderer-stress.s

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ profiled_functions = function_names[: int(num_functions / 2)]
2929
function_contents = [
3030
f"""
3131
{name}:
32+
.cfi_startproc
33+
.cfi_personality 155, _personality_{i % 5}
34+
.cfi_lsda 16, _exception{i % 3}
3235
add w0, w0, #{i % 4096}
3336
add w1, w1, #{i % 10}
3437
add w2, w0, #{i % 20}
3538
adrp x3, {name}@PAGE
3639
ret
40+
.cfi_endproc
3741
"""
3842
for i, name in enumerate(function_names)
3943
]
@@ -78,6 +82,26 @@ with open(assembly_filepath, "w") as f:
7882
_main:
7983
ret
8084

85+
_personality_0:
86+
ret
87+
_personality_1:
88+
ret
89+
_personality_2:
90+
ret
91+
_personality_3:
92+
ret
93+
_personality_4:
94+
ret
95+
96+
_exception0:
97+
.quad 0x4200
98+
99+
_exception1:
100+
.quad 0x4210
101+
102+
_exception2:
103+
.quad 0x4220
104+
81105
{"".join(function_contents)}
82106

83107
.data

0 commit comments

Comments
 (0)