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

Cannot build with -g: dbg attachment points at wrong subprogram for function #33076

Closed
jonhoo opened this issue Apr 18, 2016 · 4 comments
Closed
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.)

Comments

@jonhoo
Copy link
Contributor

jonhoo commented Apr 18, 2016

Trying to compile the following code with -g fails on stable, beta, and nightly:

use std::collections::HashMap;

enum T {
    Some(i64),
    None,
}

impl T {
    fn x(&self, a: i64, b: &HashMap<i64, T>, c: Option<&HashMap<i64, i64>>) -> Vec<i64> {
        match *self {
            T::None => vec![a],
            _ if c.and_then(|c| c.get(&a)).is_some() => vec![a],
            T::Some(i) => b[&i].x(i, b, c),
        }
    }
}

fn main() {}

with the error

!dbg attachment points at wrong subprogram for function
!685 = distinct !DISubprogram(name: "fnfn", linkageName: "fnfn", scope: !328, file: !328, line: 12, type: !347, isLocal: true, isDefinition: true, scopeLine: 12, flags: DIFlagPrototyped, isOptimized: false, templateParams: !50, variables: !50)
i8* (i64, %"1.std::collections::hash::map::HashMap<i64, i64, std::collections::hash::map::RandomState>"*)* @"_ZN1T1x28_$u7b$$u7b$closure$u7d$$u7d$12closure.3923E"
  call void @llvm.dbg.declare(metadata %"1.std::collections::hash::map::HashMap<i64, i64, std::collections::hash::map::RandomState>"** %c, metadata !953, metadata !917), !dbg !954
!954 = !DILocation(line: 12, scope: !346)
!346 = distinct !DISubprogram(name: "fnfn", linkageName: "fnfn", scope: !328, file: !328, line: 12, type: !347, isLocal: true, isDefinition: true, scopeLine: 12, flags: DIFlagPrototyped, isOptimized: false, templateParams: !50, variables: !50)
!346 = distinct !DISubprogram(name: "fnfn", linkageName: "fnfn", scope: !328, file: !328, line: 12, type: !347, isLocal: true, isDefinition: true, scopeLine: 12, flags: DIFlagPrototyped, isOptimized: false, templateParams: !50, variables: !50)
LLVM ERROR: Broken function found, compilation aborted!
@jonhoo
Copy link
Contributor Author

jonhoo commented Apr 18, 2016

Don't know if this is related to #28947 or #29923.

@alexcrichton alexcrichton added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Apr 18, 2016
@alexcrichton
Copy link
Member

cc @michaelwoerister

@michaelwoerister
Copy link
Member

Thanks for the bug report, @jonhoo!
At first glance this looks like an incarnation of #17201, which supposedly has been fixed. We'll need to take a look at the unoptimized LLVM IR to see if all calls are assigned a valid debug location.

@Mark-Simulacrum
Copy link
Member

This no longer breaks. Closing.

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.)
Projects
None yet
Development

No branches or pull requests

4 participants