Skip to content

[GlobalDCE] Add !llvm.used.conditional support for conditionally used global variables #3396

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
merged 1 commit into from
Oct 24, 2021

Conversation

kubamracek
Copy link

@kubamracek kubamracek commented Oct 12, 2021

This PR lands a preview version of !llvm.used.conditional that is not yet merged in upstream LLVM and is being reviewed at https://reviews.llvm.org/D104496, but it's important to unblock progress in adopting these changes in Swift. Once upstream LLVM gets !llvm.used.metadata (or a differently-named or differently-implemented) support, which downstream change will be reverted.

Commit message:

[GlobalDCE] Add !llvm.used.conditional support for conditionally used global variables

As part of the optimization work to emit dead-strippable symbols for Swift and
enable GlobalDCE to remove those symbols when possible, we need to mark some
Swift symbols as conditionally used based on a set of other symbols. Background
info can be found here: https://bugs.swift.org/browse/SR-14509.

This diff adds a module-level name metadata !llvm.used.conditional, which
contains a list of metadata triplets, that describes the conditions under which
we allow removal of globals even if they are mentioned in @llvm.used. See the
included LangRef changes to details. The implementation is a strict addition,
it does not change any semantics and does not affect IR or passes in any way,
unless !llvm.used.conditional is present in the input IR.

@kubamracek kubamracek requested a review from fhahn October 12, 2021 19:32
@kubamracek
Copy link
Author

@swift-ci please test

@kubamracek
Copy link
Author

@swift-ci please test macOS platform

1 similar comment
@kubamracek
Copy link
Author

@swift-ci please test macOS platform

@fhahn
Copy link

fhahn commented Oct 13, 2021

Looks like there's a failure on macOS which may be relevant:

01:04:56 Swift(macosx-x86_64) :: IRGen/conditional-dead-strip-ir.swift

@kubamracek kubamracek force-pushed the mracek/llvm-used-conditional branch from ac9ede0 to 6cdc7b4 Compare October 13, 2021 14:25
@kubamracek
Copy link
Author

Looks like there's a failure on macOS which may be relevant:

01:04:56 Swift(macosx-x86_64) :: IRGen/conditional-dead-strip-ir.swift

Addressed (on the Swift side), it was the IR Verifier not liking the slightly-different version of llvm.used.conditional that is used in this test :) The next run should be clean.

@kubamracek
Copy link
Author

@swift-ci please test

@kubamracek kubamracek force-pushed the mracek/llvm-used-conditional branch from 6cdc7b4 to e30d26c Compare October 23, 2021 02:46
@kubamracek kubamracek changed the title [GlobalDCE] Add !llvm.used.metadata support for conditionally used global variables [GlobalDCE] Add !llvm.used.conditional support for conditionally used global variables Oct 23, 2021
@kubamracek
Copy link
Author

@swift-ci please test

@kubamracek kubamracek force-pushed the mracek/llvm-used-conditional branch from e30d26c to 97c2cc4 Compare October 23, 2021 02:50
@kubamracek
Copy link
Author

@swift-ci please test

@kubamracek
Copy link
Author

@swift-ci please test macOS platform

2 similar comments
@kubamracek
Copy link
Author

@swift-ci please test macOS platform

@kubamracek
Copy link
Author

@swift-ci please test macOS platform

… global variables

As part of the optimization work to emit dead-strippable symbols for Swift and
enable GlobalDCE to remove those symbols when possible, we need to mark some
Swift symbols as conditionally used based on a set of other symbols. Background
info can be found here: https://bugs.swift.org/browse/SR-14509.

This diff adds a module-level name metadata !llvm.used.conditional, which
contains a list of metadata triplets, that describes the conditions under which
we allow removal of globals even if they are mentioned in @llvm.used. See the
included LangRef changes to details. The implementation is a strict addition,
it does not change any semantics and does not affect IR or passes in any way,
unless !llvm.used.conditional is present in the input IR.
@kubamracek kubamracek force-pushed the mracek/llvm-used-conditional branch from 97c2cc4 to 887b8da Compare October 24, 2021 14:25
@kubamracek
Copy link
Author

@swift-ci please test

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.

2 participants