Skip to content

Weird output about spills and variables #110743

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

Closed
matthiaskrgr opened this issue Apr 23, 2023 · 5 comments
Closed

Weird output about spills and variables #110743

matthiaskrgr opened this issue Apr 23, 2023 · 5 comments
Assignees
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Apr 23, 2023

I tried this code:

const SZ: usize = 64_000_000;
type BigDrop = [String; SZ];

fn f(from_fn: BigDrop) {}

fn f2(_moveme: BigDrop) -> String {
    let [a, ..] = _moveme;
    a
}

fn main() {
    f(std::array::from_fn(|_| String::new()));
    f2(std::array::from_fn(|_| String::new()));
}

I expected to see this happen: explanation

Instead, this happened: explanation

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (b628260df 2023-04-22)
binary: rustc
commit-hash: b628260df0587ae559253d8640ecb8738d3de613
commit-date: 2023-04-22
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

If you compile this you will get very interesting output

warning: unused variable: `from_fn`
 --> B3A5F4060827522A3328FC59CAE6348272F5F8B0627152DED589D0B44CBBDBB5.rs:6:6
  |
6 | fn f(from_fn: BigDrop) {}
  |      ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_from_fn`
  |
  = note: `#[warn(unused_variables)]` on by default

80/9216000120 (0.00%) spills, 9216000040/9216000120 (100.00%) variables
80/9216000120 (0.00%) spills, 9216000040/9216000120 (100.00%) variables
warning: 1 warning emitted

I could not find any traces of this inside the rust source code, it seems to be coming from llvm directly?! Some leftover debug print maybe?

(llvm git: llvm/lib/CodeGen/PrologEpilogInserter.cpp:316: dbgs() << formatv("{0}/{1} ({3:P}) spills, {2}/{1} ({4:P}) variables",)

@matthiaskrgr matthiaskrgr added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. labels Apr 23, 2023
@Ezrashaw
Copy link
Contributor

Ezrashaw commented Apr 25, 2023

Shall I add a UI test for this so we can track it?

How on earth did this get through LLVM's review process? LLVM isn't meant to print output at all when invoked by rustc. 🤣

@rustbot claim
(I'll see if I can get a fix upstream)

@rustbot
Copy link
Collaborator

rustbot commented Apr 25, 2023

Error: Parsing assign command in comment failed: ...' claim' | error: expected end of command at >| ' (I'll see'...

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

@matthiaskrgr
Copy link
Member Author

another one:

#![allow(invalid_value)]

fn main() {
    // The array avoids a `Scalar` layout which detects uninit without even doing validation.
    let _val = unsafe { std::mem::MaybeUninit::<[*const u8; 0xABCDABCD]>::uninit().assume_init() };
    //~^ ERROR: uninitialized
}

@Ezrashaw
Copy link
Contributor

This is fixed upstream in LLVM now, so at some point this bug will just disappear.

@Ezrashaw
Copy link
Contributor

@matthiaskrgr This is now fixed in nightly and stable. This issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants