Skip to content
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

[EDS] LLVM support for new conditional runtime records #8588

Open
wants to merge 3 commits into
base: stable/20230725
Choose a base branch
from

Conversation

NuriAmari
Copy link

@NuriAmari NuriAmari commented Apr 17, 2024

This adds the required LLVM support for the new form of conditional runtime records proposed in apple/swift#73060.

Teach the dead stripping in LLD for MachO how to parse
conditionally live records, and consider them when dead stripping.

This is a demonstrative patch of a change that could made for LLD
for ELF/COFF or other linkers to support effective EDS without
LTO.
During thin-LTO thin-link, a global liveness analysis is performed
to guide importing and exporting decisions between modules.

EDS is far more effective when it can operate on the entire LTO unit,
otherwise dependencies defined in other modules have to be
conservatively assumed live. It is also far simpler to safely run
EDS on the entire LTO unit, since otherwise it can be difficult to
determine if the liveness of a copy of a dependency is representative
of the liveness of the entity in the program as a whole. Lastly,
just like regular DCE, EDS is more effective run multiple times.

In this patch, we serialize EDS information (stripping conditions) into
each module's summary, then collect this information during thin-link,
making liveness decisions accordingly.

We support both the old and new LTO backend.
@@ -1,17 +0,0 @@
; RUN: opt -S -passes=globaldce < %s | FileCheck %s
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test tested what happens when the metadata contains null dependencies, which is now impossible.

@NuriAmari
Copy link
Author

@NuriAmari NuriAmari marked this pull request as ready for review April 17, 2024 21:41
@NuriAmari NuriAmari force-pushed the resilient-conditional-runtime-records branch from ce4cdb3 to b28c6d8 Compare April 18, 2024 17:53
In this patch, we replace the old EDS logic in GlobalDCE,
with new logic that knows how to interpret the new conditionally
live records.

We prevent this stripping logic from running before full-LTO merge,
as it's unclear if it is safe to evaluate the liveness of a dependency
without considering the full LTO unit.

The primary concern here is when a dependency has multiple defintions,
each internalized into different modules. The liveness of one may not
reflect the liveness of another.
@NuriAmari NuriAmari force-pushed the resilient-conditional-runtime-records branch from b28c6d8 to 8f4c2fa Compare April 18, 2024 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant