-
Notifications
You must be signed in to change notification settings - Fork 15.3k
release/20.x: [ORC] Force eh-frame use for older Darwins on x86-64 in MachOPlatform, LLJIT. #126361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(cherry picked from commit 7fb233f)
Rename MachOCompactUnwindInfoSectionName to MachOCompactUnwindSectionName. Background: There are two related sections used for compact-unwind info processing: __LD,__compact_unwind -- the input table stored in relocatable object formats, and __TEXT,__unwind_info -- the compressed table produced by the linker and consumed by libunwind. To keep the distinction clear we'll use *CompactUnwind* for names that refer to the __LD,__compact_unwind input tables and *UnwindInfo* for names that refer to the __TEXT,__unwind_info output tables. Dropping 'Info' from the variable above clarifies which section it refers to. (cherry picked from commit a1ff2d1)
We already had a -jit-mode=orc-lazy regression test for this, but it should work equally well in non-lazy mode. (cherry picked from commit b46211b)
…ame. a1ff2d1 should have disambiguated MachOCompactUnwindInfoSectionName to MachOUnwindInfoSectionName, given how it's used in MachOPlatform and its value. A MachOCompactUnwindSectionName variable with an appropriate value will be added in an upcoming patch to re-enable compact-unwind support in JITLink. (cherry picked from commit b84ac58)
Unwind-info records only have one keep-alive edge to their target function, but eh-frame records may have multiple edges (to the CIE, function, personality, and lsda). We need to identify the target-function edge differently for each section type. (cherry picked from commit 52b5e36)
Some eh-frame records are CIEs, which don't point to functions. We need to skip these records. This patch reuses EHFrameCFIBlockInspector to identify function targets, rather than a custom loop. Any performance impact will be minimal, and essentially irrelevant once compact-unwind support re-lands (since at that point we'll discard most eh-frame records). For unwind-info sections: don't assume one block per record: the unwind-info section packs all records into a single block. (cherry picked from commit 9de581b)
…fixes. Re-enables compact-unwind support in JITLink, which was reverted in b04847b due to buildbot failures. The underlying cause for the failures on the buildbots was the lack of compact-unwind registration support on older Darwin OSes. Since the CompactUnwindManager pass now removes eh-frames by default we were left with unwind-info that could not be registered. On x86-64, where eh-frame info is produced by default the solution is to fall back to using eh-frames. On arm64 we simply can't support exceptions on older OSes. This patch updates the EHFrameRegistrationPlugin to remove the compact-unwind section (__LD,__compact_unwind) when installed, forcing use of eh-frames when the EHFrameRegistrationPlugin is used. In LLJIT, the EHFrameRegistrationPlugin continues to be used for all non-Darwin platform, and will be added on Darwin platforms when the a CompactUnwindRegistrationPlugin instance can't be created (e.g. due to missing support for compact-unwind info registration). The lit.cfg.py script is updated to check whether the host OSes default unwind info supports JIT registration, allowing tests to be disabled for older Darwin OSes on arm64. (cherry picked from commit eae6d6d)
(cherry picked from commit aefa30e)
SecondLevelPageOffset should be incremented by SecondLevelPageSize bytes, not one byte. Failure to calculate the offset correctly leads to corrupted unwind-info (and consequently broken exceptions / unwinding) when more than one second level page is needed. Since JITLink's unwind support only produces UNWIND_SECOND_LEVEL_REGULAR-style pages this would trigger for any file containing more than 511 functions with unwind info. The included test-case contains 1022 functions (sufficient for both the current format and any future implementation that supports UNWIND_SECOND_LEVEL_COMPRESSED pages). Thanks to @edoardo on discord for spotting this bug! (cherry picked from commit 88f55d1)
`Sym.getSection()` is equivalent to `Sym.getBlock().getSection()`. (cherry picked from commit 4a2a8ed)
Compact-unwind encodings are more limited than DWARF frame descriptions. For functions whose frame layout cannot be described by a compact unwind encoding, the encoding for the function will specify "use DWARF", and the corresponding unwind-info record will use the low bits of the encoding to point to the FDE for the function. We test this with a frame-pointer=none function, since these frame layouts always triger a fall-back to DWARF on arm64. (cherry picked from commit 9d88ffe)
…tcase. Makes this test smaller and more readable. (cherry picked from commit e00f824)
(cherry picked from commit 7811c20)
…lues. The getBootstrapMap, getBootstrapMapValue, getBootstrapSymbolsMap, and getBootstrapSymbols methods forward to their respective counterparts in ExecutorProcessControl, similar to the callWrapper functions. These methods will be used to simplify an upcoming patch that accesses the bootstrap values. (cherry picked from commit 63bb4ba)
…, LLJIT. The system libunwind on older Darwins does not support JIT registration of compact-unwind. Since the CompactUnwindManager utility discards redundant eh-frame FDEs by default we need to remove the compact-unwind section first when targeting older libunwinds in order to preserve eh-frames. While LLJIT was already doing this as of eae6d6d, MachOPlatform was not. This was causing buildbot failures in the ORC runtime (e.g. in https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA/3479/). This patch updates both LLJIT and MachOPlatform to check a bootstrap value, "darwin-use-ehframes-only", to determine whether to forcibly preserve eh-frame sections. If this value is present and set to true then compact-unwind sections will be discarded, causing eh-frames to be preserved. If the value is absent or set to false then compact-unwind will be used and redundant FDEs in eh-frames discarded (FDEs that are needed by the compact-unwind section are always preserved). rdar://143895614 (cherry picked from commit e2eaf8d)
|
@lhames (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport 7fb233f a1ff2d1 b46211b c0f7ebe b84ac58 52b5e36 9de581b eae6d6d aefa30e 88f55d1 4a2a8ed 9d88ffe 7a213e7 e00f824 7811c20 63bb4ba e2eaf8d
Requested by: @lhames