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

Collect panic/panic_bounds_check during monomorphization #90406

Merged
merged 2 commits into from
Nov 1, 2021

Conversation

nbdd0121
Copy link
Contributor

This would prevent link time errors if these functions are #[inline] (e.g. when panic_immediate_abort is used).

Fix #90405
Fix rust-lang/cargo#10019

@rustbot label: T-compiler A-codegen

@rustbot rustbot added A-codegen Area: Code generation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 29, 2021
@rust-highfive
Copy link
Collaborator

r? @cjgillot

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 29, 2021
@rust-log-analyzer

This comment has been minimized.

@@ -0,0 +1,58 @@
// compile-flags:-Zprint-mono-items=eager
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't the eager mode consider panic function to be one of roots and hide the bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Good catch!

@cjgillot
Copy link
Contributor

Thanks @nbdd0121! LGTM.

Instance::mono will panic if the function has generics.
What happens if the input program (erroneously) declares the panic lang item function to have generic parameters?

#[lang = "panic"]
fn panic<T>(_: T) -> ! { loop {} }

Is this error correctly caught by lang item check or does Instance::mono ICE.

@nbdd0121
Copy link
Contributor Author

Is this error correctly caught by lang item check or does Instance::mono ICE.

It'll ICE. But it will ICE regardless this change since rustc_codegen_ssa uses Instance::mono to create an instance of panic as well.

@nbdd0121
Copy link
Contributor Author

(with that said this is a very simple check so added it anyway)

@cjgillot
Copy link
Contributor

cjgillot commented Nov 1, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Nov 1, 2021

📌 Commit 4d619d9 has been approved by cjgillot

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 1, 2021
@bors
Copy link
Contributor

bors commented Nov 1, 2021

⌛ Testing commit 4d619d9 with merge db062de...

@bors
Copy link
Contributor

bors commented Nov 1, 2021

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing db062de to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 1, 2021
@bors bors merged commit db062de into rust-lang:master Nov 1, 2021
@rustbot rustbot added this to the 1.58.0 milestone Nov 1, 2021
@nbdd0121 nbdd0121 deleted the panic branch November 1, 2021 21:51
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (db062de): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
8 participants