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

MIR-inlined functions called with constants should put the constant in debug info #110675

Closed
scottmcm opened this issue Apr 22, 2023 · 1 comment · Fixed by #107404
Closed

MIR-inlined functions called with constants should put the constant in debug info #110675

scottmcm opened this issue Apr 22, 2023 · 1 comment · Fixed by #107404
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug.

Comments

@scottmcm
Copy link
Member

The following code calls is_digit with a constant radix:

pub fn num_to_digit(num: char) -> u32 {
// CHECK-NOT: panic
if num.is_digit(8) { num.to_digit(8).unwrap() } else { 0 }
}

The MIR inliner preserves a local variable that's "holding" the value

let mut _3: u32; // in scope 0 at $DIR/issue_59352.rs:+2:12: +2:23
scope 1 (inlined char::methods::<impl char>::is_digit) { // at $DIR/issue_59352.rs:15:12: 15:23
debug self => _1; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
debug radix => _3; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL

But it's actually dead -- nothing sets _3 to anything, so that debug info node is useless.

(I'm working on a PR that will remove always-uninitialized debug info like that _3, which is how I noticed this. So I opened this in case the debuginfo folks want this to work instead of just being dropped.)

@scottmcm scottmcm added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. labels Apr 22, 2023
@cjgillot
Copy link
Contributor

ConstDebugInfo does the general work of uplifting to debuginfo. I have #107404 trying to turn it by default.

@scottmcm scottmcm linked a pull request Apr 22, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants