This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Don't put entries with less than 2 usages into the common table.
Changes PlannedPublic

Authored by oontvoo on Oct 20 2022, 1:12 PM.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

This matches LD64's handling.

Diff Detail

Event Timeline

oontvoo created this revision.Oct 20 2022, 1:12 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 20 2022, 1:12 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
oontvoo requested review of this revision.Oct 20 2022, 1:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 20 2022, 1:12 PM
oontvoo added inline comments.Oct 20 2022, 1:14 PM
lld/test/MachO/fold-common-encoding.s
2

This is only 1 test at the moment, but I have another patch coming which needs two input files - so using split-file in this patch to make the diff easier

17

This used to include the _exception1 entry, too.

int3 added a subscriber: int3.Oct 20 2022, 1:54 PM

Does this behavior difference really matter? We're not saving any bytes with this, right

int3 added a comment.Oct 20 2022, 2:14 PM

That said, I'm not super opposed to making this change. But I'm wondering if we could at least reuse the compact-unwind.s test instead of adding a new file -- this seems like a lot of additional testing for a trivial behavior change. Or will your upcoming patch not fit into that test file?

Does this behavior difference really matter? We're not saving any bytes with this, right

This change isn't about saving the bytes - but rather, theoretically the size of the common-encoding table could change the paging logic. I'm still chasing down the missing exception-handling-code bug and noticed that this is one of a few differences.... just trying to narrow down the issue.

But I'm wondering if we could at least reuse the compact-unwind.s test instead of adding a new file -- this seems like a lot of additional testing for a trivial behavior change. Or will your upcoming patch not fit into that test file?

it could kind of fit into compact-unwind.s but will need additional sub-files (or modifying the existing one to have more symbols to demonstrate this change), which I think doesn't really help with reducing complexity.
What is the concern? IMHO, it's easier to debug failures in general when there are multiple separate test files with single-purpose testings rather than trying to pack as many related things as possible into one giant file 🤔

int3 added a comment.Oct 24 2022, 6:46 PM

What is the concern? IMHO, it's easier to debug failures in general when there are multiple separate test files with single-purpose testings rather than trying to pack as many related things as possible into one giant file 🤔

It's a tension between that vs being able to easily understand what is being tested -- one of the purposes of a test is to serve as a declarative spec of behavior, which are usually easier to understand than the imperative code -- partly because they are terser.

Other reasons include test suite running time, plus the amount of effort needed to update tests when LLD's behavior changes.

Given the tradeoffs, it's a matter of striking a balance. Adding a whole test file to cover a single if statement seems kind of heavy. If we did that for every other if... we would have a lot more tests. It's not always necessarily *wrong* -- if e.g. there's a tricky edge case that only happens for very carefully constructed inputs, then sure, having a separate test file makes sense even if the fix is a single if. But this particular test doesn't seem to fall into that category.

(Also, couldn't the current test be simplified? It seems like you could just vary the .cfi_def_cfa_offset value to get different encodings. Doesn't seem like _main and _exception1 are necessary...)

Plus I noted that the compact-unwind.s test doesn't really test for encodings at all. I'm thinking we could add CHECKs for that, plus a single _unique_encoding function that ensures its uniqueness via the CFA offset.

Feel free to push back, but these are my reasons :)

Roger added a subscriber: Roger.Nov 1 2022, 7:51 PM
Roger added inline comments.
lld/MachO/UnwindInfoSection.cpp
513

Could we include in the comment that the motivation for this if-statement is to match what ld64 is doing?

oontvoo planned changes to this revision.Nov 8 2022, 6:21 AM

addressing review comments - so pulling this off the review queue - sorry for the delay in response, was OOO for 2 weeks