Skip to content

Add -Xfrontend -mergeable-traps as a way to emit mergeable traps #76045

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 7 commits into from
Mar 25, 2025

Conversation

kubamracek
Copy link
Contributor

Only adding as a hidden frontend flag, not intending this to actually be used in normal production code. But this is potentially useful for Embedded Swift and especially codesize constrained environments: (1) A/B testing to see how much codesize are we paying for non-mergeable traps, (2) if it's appropriate in special cases to regress debuggability to save on codesize.

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

I think it also makes sense to relax the condition in

(condFailToMerge.isEmpty || cfi.message == condFailToMerge.first!.message) {
if this option is set.

@@ -503,7 +503,7 @@ llvm::CallInst *IRBuilder::CreateNonMergeableTrap(IRGenModule &IGM,
}
}

if (IGM.IRGen.Opts.shouldOptimize()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we keep IGM.IRGen.Opts.shouldOptimize(), too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, done!

@kubamracek
Copy link
Contributor Author

I think it also makes sense to relax the condition in

(condFailToMerge.isEmpty || cfi.message == condFailToMerge.first!.message) {

if this option is set.

Done!

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm!

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek kubamracek merged commit 41ae316 into swiftlang:main Mar 25, 2025
5 checks passed
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.

3 participants