Skip to content

Conversation

folkertdev
Copy link
Contributor

@folkertdev folkertdev commented Mar 9, 2025

fixes #138260

since #137180, global_asm! gets a fake body, that the pretty printing logic did not know what to do with.

based on #t-compiler/help > tests for MIR pretty printing I created tests/ui/unpretty/mir which seemed as good a place as any for a test. If there is a better place, let me know.

try-job: test-various
try-job: x86_64-apple-2

@rustbot
Copy link
Collaborator

rustbot commented Mar 9, 2025

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 9, 2025
@compiler-errors
Copy link
Member

r? compiler-errors

@compiler-errors
Copy link
Member

compiler-errors commented Mar 9, 2025

This has nothing to do with const operands, so the reasoning is a bit off. This also ICEs on master:

(edit: fixed typo below)

//@compile-flags: -Zdump-mir=all
use std::arch::{asm, global_asm};

global_asm!("/* hi */");

Please adjust the title and description not to mention const operands. The reason this ICEs is because since #137180 we synthesize a fake MIR body for checking the types of operands in global_asm!, but this was never adjusted to handle dumping MIR for these bodies. I think this fix is right, but I'll leave an inline suggestion for a better comment.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 9, 2025
@folkertdev folkertdev changed the title fix ICE in pretty-printing global_asm! const operands fix ICE in pretty-printing global_asm! Mar 9, 2025
@folkertdev folkertdev force-pushed the mir-dump-asm-const branch from 65d9a66 to 4613650 Compare March 9, 2025 19:11
@@ -0,0 +1,7 @@
//@ compile-flags: -Zdump-mir=all --crate-type=lib
Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mentioned -dump=mir in one of your comments. That doesn't exist, and --emit=mir seemed to work. So I don't know what you meant exactly, but is this the right dump command? will it not create a bunch of useless files when someone runs the tests suite?

Copy link
Member

Choose a reason for hiding this comment

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

-Zdump-mir=all. And yes, I think unfortunately your test will end up dumping a bunch of files when the test suite is executed I think 🤔 .

You should probably move this to a tests/mir-opt test, and add an annotation for // EMIT_MIR ... for just the global asm block, or however you spell that.

@compiler-errors
Copy link
Member

It was a typo lol

@folkertdev
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 9, 2025
@folkertdev folkertdev force-pushed the mir-dump-asm-const branch from 4613650 to b394c8e Compare March 9, 2025 19:40
@folkertdev
Copy link
Contributor Author

allright, I moved the test file. The testing machinery there is much nicer.

@compiler-errors
Copy link
Member

LGTM.

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Mar 9, 2025

📌 Commit b394c8e has been approved by compiler-errors

It is now in the queue for this repository.

@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 Mar 9, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 9, 2025
…ompiler-errors

fix ICE in pretty-printing `global_asm!`

fixes rust-lang#138260

since rust-lang#137180, `global_asm!` gets a fake body, that the pretty printing logic did not know what to do with.

based on [#t-compiler/help > tests for MIR pretty printing](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/tests.20for.20MIR.20pretty.20printing) I created `tests/ui/unpretty/mir` which seemed as good a place as any for a test. If there is a better place, let me know.
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 10, 2025
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#137279 (Make some invalid codegen attr errors structured/translatable)
 - rust-lang#137793 (Stablize anonymous pipe)
 - rust-lang#138238 (Fix dyn -> param suggestion in struct ICEs)
 - rust-lang#138270 (chore: Fix some comments)
 - rust-lang#138280 (fix ICE in pretty-printing `global_asm!`)
 - rust-lang#138286 (triagebot.toml: Don't label `test/rustdoc-json` as A-rustdoc-search (…)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 10, 2025
…ompiler-errors

fix ICE in pretty-printing `global_asm!`

fixes rust-lang#138260

since rust-lang#137180, `global_asm!` gets a fake body, that the pretty printing logic did not know what to do with.

based on [#t-compiler/help > tests for MIR pretty printing](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/tests.20for.20MIR.20pretty.20printing) I created `tests/ui/unpretty/mir` which seemed as good a place as any for a test. If there is a better place, let me know.
@folkertdev
Copy link
Contributor Author

right, of course...

It looks like minicore is not available for the mir opt tests (yet?), so I copied from it what is needed here.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 10, 2025
@@ -0,0 +1,18 @@
// skip-filecheck
#![feature(no_core, lang_items, rustc_attrs, decl_macro)]
Copy link
Member

Choose a reason for hiding this comment

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

you don't need no-core, i'm pretty sure there's a directive for limiting this test just to platforms with asm support:

//@ needs-asm-support

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I guess that's fine here, because the printing logic does not change between platforms so testing only on some is probably fine. I've made the change.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 10, 2025
@compiler-errors
Copy link
Member

I'll approve when CI turns green

@matthiaskrgr
Copy link
Member

@bors try

@bors
Copy link
Collaborator

bors commented Mar 10, 2025

⌛ Trying commit 9213cb8 with merge 9fc4032...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 10, 2025
fix ICE in pretty-printing `global_asm!`

fixes rust-lang#138260

since rust-lang#137180, `global_asm!` gets a fake body, that the pretty printing logic did not know what to do with.

based on [#t-compiler/help > tests for MIR pretty printing](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/tests.20for.20MIR.20pretty.20printing) I created `tests/ui/unpretty/mir` which seemed as good a place as any for a test. If there is a better place, let me know.

try-job: test-various
try-job: x86_64-apple-2
@bors
Copy link
Collaborator

bors commented Mar 10, 2025

☀️ Try build successful - checks-actions
Build commit: 9fc4032 (9fc4032645037b551db82b8f38855ac82a5a5fb6)

@folkertdev
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 12, 2025
@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Mar 12, 2025

📌 Commit 9213cb8 has been approved by compiler-errors

It is now in the queue for this repository.

@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 Mar 12, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 12, 2025
…earth

Rollup of 12 pull requests

Successful merges:

 - rust-lang#134076 (Stabilize `std::io::ErrorKind::InvalidFilename`)
 - rust-lang#137504 (Move methods from Map to TyCtxt, part 4.)
 - rust-lang#138175 (Support rmeta inputs for --crate-type=bin --emit=obj)
 - rust-lang#138259 (Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs)
 - rust-lang#138280 (fix ICE in pretty-printing `global_asm!`)
 - rust-lang#138318 (Rustdoc: remove a bunch of `@ts-expect-error` from main.js)
 - rust-lang#138331 (Use `RUSTC_LINT_FLAGS` more)
 - rust-lang#138357 (merge `TypeChecker` and `TypeVerifier`)
 - rust-lang#138394 (remove unnecessary variant)
 - rust-lang#138403 (Delegation: one more ICE fix for `MethodCall` generation)
 - rust-lang#138407 (Delegation: reject C-variadics)
 - rust-lang#138409 (Use sa_sigaction instead of sa_union.__su_sigaction for AIX)

r? `@ghost`
`@rustbot` modify labels: rollup
@Manishearth
Copy link
Member

Is it possible this rollup failure is caused by this PR?

#138416 (comment)

@compiler-errors
Copy link
Member

Likely not @Manishearth

@jieyouxu
Copy link
Member

(Unrelated, rollup failure is spurious MSVC filesystem problems)

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 13, 2025
…earth

Rollup of 12 pull requests

Successful merges:

 - rust-lang#134076 (Stabilize `std::io::ErrorKind::InvalidFilename`)
 - rust-lang#137504 (Move methods from Map to TyCtxt, part 4.)
 - rust-lang#138175 (Support rmeta inputs for --crate-type=bin --emit=obj)
 - rust-lang#138259 (Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs)
 - rust-lang#138280 (fix ICE in pretty-printing `global_asm!`)
 - rust-lang#138318 (Rustdoc: remove a bunch of `@ts-expect-error` from main.js)
 - rust-lang#138331 (Use `RUSTC_LINT_FLAGS` more)
 - rust-lang#138357 (merge `TypeChecker` and `TypeVerifier`)
 - rust-lang#138394 (remove unnecessary variant)
 - rust-lang#138403 (Delegation: one more ICE fix for `MethodCall` generation)
 - rust-lang#138407 (Delegation: reject C-variadics)
 - rust-lang#138409 (Use sa_sigaction instead of sa_union.__su_sigaction for AIX)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f5eb296 into rust-lang:master Mar 13, 2025
7 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 13, 2025
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Mar 14, 2025
…earth

Rollup of 12 pull requests

Successful merges:

 - rust-lang#134076 (Stabilize `std::io::ErrorKind::InvalidFilename`)
 - rust-lang#137504 (Move methods from Map to TyCtxt, part 4.)
 - rust-lang#138175 (Support rmeta inputs for --crate-type=bin --emit=obj)
 - rust-lang#138259 (Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs)
 - rust-lang#138280 (fix ICE in pretty-printing `global_asm!`)
 - rust-lang#138318 (Rustdoc: remove a bunch of `@ts-expect-error` from main.js)
 - rust-lang#138331 (Use `RUSTC_LINT_FLAGS` more)
 - rust-lang#138357 (merge `TypeChecker` and `TypeVerifier`)
 - rust-lang#138394 (remove unnecessary variant)
 - rust-lang#138403 (Delegation: one more ICE fix for `MethodCall` generation)
 - rust-lang#138407 (Delegation: reject C-variadics)
 - rust-lang#138409 (Use sa_sigaction instead of sa_union.__su_sigaction for AIX)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Development

Successfully merging this pull request may close these issues.

ICE: pretty: Unexpected def kind GlobalAsm
8 participants