-
Notifications
You must be signed in to change notification settings - Fork 13k
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
sync adding nounwind attribute with generating abort-on-panic shim #63884
Conversation
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
// Foreign items like `extern "C" { fn foo(); }` are assumed not to | ||
// unwind | ||
// Foreign items like `extern "C" { fn foo(); }` and `extern "Rust" { fn bar(); }` | ||
// are assumed not to unwind. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to assume that an imported extern "Rust" { fn bar(); }
does not unwind? I just expanded the comment here to describe already existing behavior.
Cc @gnzlbg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to assume that an imported extern "Rust" { fn bar(); } does not unwind?
IIRC, "Rust"
, "platform-intrinsic"
, "rust-intrinsic"
, and "rustcall"
are actually the same ABI, and it is ok for extern declarations of those to actually unwind. One such a declaration would be the integer add
intrinsic that panics on integer overflow. We also sometimes import llvm
intrinsics (via #[feature(link_llvm_intrinsics(]
) using the "unadjusted"
ABI. I'm not sure if that one should be able to unwind as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My personal inclination is to just remove the foreign_item
case here. But that decision should probably be made by someone who actually knows the surrounding code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact I had to remove that branch to make the codegen tests work as expected. Whatever that means.
src/librustc/ty/context.rs
Outdated
@@ -1581,6 +1581,32 @@ impl<'tcx> TyCtxt<'tcx> { | |||
pub fn has_strict_asm_symbol_naming(&self) -> bool { | |||
self.gcx.sess.target.target.arch.contains("nvptx") | |||
} | |||
|
|||
/// Determine if this function gets a shim to catch panics and abort. | |||
pub fn abort_on_panic_shim(&self, fn_def_id: DefId, abi: abi::Abi) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had no idea what the right place would be for this method. Suggestions?
0cf0812
to
0f6bbcb
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Adjusted and expanded the failing test. I tried for a long time to also adjust and expand |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Hm, incremental thinlto tests are failing and I have no idea why,
|
This comment has been minimized.
This comment has been minimized.
@Centril I am not entirely sure why you nominated this for T-lang? This is a bugfix, solving the problem that the comments in LLVM codegen are wrong (they say we add abort-on-panic shims but we don't). #62603 seems like the more interesting one from a T-lang perspective, that one actually changed program behavior. |
ea60cf7
to
cef82c3
Compare
cef82c3
to
2214932
Compare
I felt like this PR did a bit too much for backporting, so I moved the soundness-fix part into a separate PR: #63909. This PR here is now based on that. Here's the relative diff. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Why is this nominated for beta ? AFAICT this only fixes a bug in a unstable Rust feature right ? |
Does it remove the |
No, it (or rather, #63909) removes the This PR here is not nominated for backport any more.
#63909 does. This PR includes that one. That is already reflected in the PR message. |
Marking as blocked and removing nomination; that has been moved to #63909. |
☔ The latest upstream changes (presumably #64264) made this pull request unmergeable. Please resolve the merge conflicts. |
Currently, the code paths for deciding whether to add an abort-on-panic shim, and whether to add the
nounwind
attribute, are separate. This unifies them. As a consequence, we now add anounwind
attribute to#[unwind(aborts)]
functions.The logic is also changed slightly to not take the call ABI into account any more. Fixes #63883.
Based on #63909, relative diff.