This matches LD64's handling.
Details
- Reviewers
- None
- Group Reviewers
Restricted Project
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Does this behavior difference really matter? We're not saving any bytes with this, right
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?
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 🤔
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 :)
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? |
addressing review comments - so pulling this off the review queue - sorry for the delay in response, was OOO for 2 weeks
Could we include in the comment that the motivation for this if-statement is to match what ld64 is doing?