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-opt] conflicting debug info for argument #67586

Closed
bjorn3 opened this issue Dec 24, 2019 · 3 comments · Fixed by #68802
Closed

[MIR-opt] conflicting debug info for argument #67586

bjorn3 opened this issue Dec 24, 2019 · 3 comments · Fixed by #68802
Assignees
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bjorn3
Copy link
Member

bjorn3 commented Dec 24, 2019

$ git clone https://github.com/ebobby/simple-raytracer.git
$ cd simple-raytracer
$ RUSTFLAGS="-Zmir-opt-level=2" cargo build
[...]
conflicting debug info for argument
  call void @llvm.dbg.declare(metadata { [0 x i8]*, i64 }* %22, metadata !534, metadata !DIExpression()), !dbg !541
!532 = !DILocalVariable(name: "code", arg: 1, scope: !528, file: !5, line: 14, type: !327)
!534 = !DILocalVariable(name: "self", arg: 1, scope: !535, file: !536, line: 2244, type: !327)
conflicting debug info for argument
  call void @llvm.dbg.declare(metadata { [0 x i8]*, i64 }* %22, metadata !534, metadata !DIExpression()), !dbg !541
!532 = !DILocalVariable(name: "code", arg: 1, scope: !528, file: !5, line: 14, type: !327)
!534 = !DILocalVariable(name: "self", arg: 1, scope: !535, file: !536, line: 2244, type: !327)
LLVM ERROR: Broken module found, compilation aborted!
error: could not compile `num-traits`.
warning: build failed, waiting for other jobs to finish...
conflicting debug info for argument
  call void @llvm.dbg.declare(metadata { [0 x i8]*, i64 }* %22, metadata !779, metadata !DIExpression()), !dbg !785
!777 = !DILocalVariable(name: "code", arg: 1, scope: !774, file: !5, line: 58, type: !480)
!779 = !DILocalVariable(name: "self", arg: 1, scope: !780, file: !706, line: 2244, type: !480)
conflicting debug info for argument
  call void @llvm.dbg.declare(metadata { [0 x i8]*, i64 }* %22, metadata !779, metadata !DIExpression()), !dbg !785
!777 = !DILocalVariable(name: "code", arg: 1, scope: !774, file: !5, line: 58, type: !480)
!779 = !DILocalVariable(name: "self", arg: 1, scope: !780, file: !706, line: 2244, type: !480)
LLVM ERROR: Broken module found, compilation aborted!
error: could not compile `arrayvec`.
warning: build failed, waiting for other jobs to finish...
conflicting debug info for argument
  call void @llvm.dbg.declare(metadata { [0 x i8]*, i64 }* %5, metadata !291, metadata !DIExpression()), !dbg !294
!289 = !DILocalVariable(name: "target", arg: 1, scope: !286, file: !5, line: 82, type: !38)
!291 = !DILocalVariable(name: "self", arg: 1, scope: !292, file: !221, line: 2934, type: !38)
conflicting debug info for argument
  call void @llvm.dbg.declare(metadata { [0 x i8]*, i64 }* %5, metadata !291, metadata !DIExpression()), !dbg !294
!289 = !DILocalVariable(name: "target", arg: 1, scope: !286, file: !5, line: 82, type: !38)
!291 = !DILocalVariable(name: "self", arg: 1, scope: !292, file: !221, line: 2934, type: !38)
LLVM ERROR: Broken module found, compilation aborted!
error: could not compile `proc-macro2`.
warning: build failed, waiting for other jobs to finish...
error: build failed

@rustbot modify labels: +A-mir +C-bug +requires-nightly

@rustbot rustbot added A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. labels Dec 24, 2019
@jonas-schievink jonas-schievink added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 24, 2019
@Centril
Copy link
Contributor

Centril commented Dec 24, 2019

cc @eddyb @michaelwoerister

@eddyb
Copy link
Member

eddyb commented Dec 24, 2019

I wonder if this is caused by MIR inlining or by other passes like copy propagation.
The conflict with "self" would seem to suggest inlining (of a method call).

Anyway, we can improve this for now by treating anything not in the outermost SourceScope as not an argument user variable (even when backed by an argument MIR local).

@eddyb eddyb self-assigned this Jan 29, 2020
@eddyb
Copy link
Member

eddyb commented Feb 3, 2020

Minimal repro, with -Zmir-opt-level=2 -Cdebuginfo=2 (https://godbolt.org/z/UdZsnS):

pub fn foo(bar: usize) -> usize {
    std::convert::identity(bar)
}

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Feb 8, 2020
…ne-arg, r=nagisa

rustc_codegen_ssa: don't treat inlined variables as debuginfo arguments.

Fixes rust-lang#67586 by limiting `ArgumentVariable` special-casing to `VarDebugInfo` entries that are in `OUTERMOST_SOURCE_SCOPE`, i.e. the function's own argument scope.
That excludes `VarDebugInfo` from inlined callees, which can also point to the caller's argument locals.

This is a snippet from the optimized MIR (including inlining) of the testcase:
```rust
fn  foo(_1: usize) -> usize {
    debug bar => _1;                     // in scope 0 at ./example.rs:2:12: 2:15
    let mut _0: usize;                   // return place in scope 0 at ./example.rs:2:27: 2:32
    scope 1 {
        debug x => _1;                   // in scope 1 at /rustc/9ed29b6ff6aa2e048b09c27af8f62ee3040bdb37/src/libcore/convert/mod.rs:106:26: 106:27
    }
```
`scope 1` is from inlining the `identity` call, and `debug x => _1;` comes from the body of `core::convert::identity`, so they are now ignored for the purposes of determining the `ArgumentVariable` debuginfo associated to `_1`.
bors added a commit that referenced this issue Feb 8, 2020
…agisa

rustc_codegen_ssa: don't treat inlined variables as debuginfo arguments.

Fixes #67586 by limiting `ArgumentVariable` special-casing to `VarDebugInfo` entries that are in `OUTERMOST_SOURCE_SCOPE`, i.e. the function's own argument scope.
That excludes `VarDebugInfo` from inlined callees, which can also point to the caller's argument locals.

This is a snippet from the optimized MIR (including inlining) of the testcase:
```rust
fn  foo(_1: usize) -> usize {
    debug bar => _1;                     // in scope 0 at ./example.rs:2:12: 2:15
    let mut _0: usize;                   // return place in scope 0 at ./example.rs:2:27: 2:32
    scope 1 {
        debug x => _1;                   // in scope 1 at /rustc/9ed29b6ff6aa2e048b09c27af8f62ee3040bdb37/src/libcore/convert/mod.rs:106:26: 106:27
    }
```
`scope 1` is from inlining the `identity` call, and `debug x => _1;` comes from the body of `core::convert::identity`, so they are now ignored for the purposes of determining the `ArgumentVariable` debuginfo associated to `_1`.
@bors bors closed this as completed in a19edd6 Feb 9, 2020
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.) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants