rust-lang/rust

llvm error: cfi: `Assertion 'cast<DISubprogram>(Scope)->describes(&MF->getFunction())' failed.`

matthiaskrgr opened this issue · 2 comments

I tried this code:
built my rustc with llvm debug assertions and rustc treereduce.out -Clto -Zsanitizer=cfi -Copt-level=1 -Cdebuginfo=2

use std::collections::HashMap;

fn copy<T: Copy>(&x: &T) -> T {
    x
}

fn main() {
    let arr = [(1, 1), (2, 2), (3, 3)];

    let m1: HashMap<_, _> = arr.iter().map(copy).collect();
}

I expected to see this happen: explanation

Instead, this happened: explanation

Meta

rustc --version --verbose:

eac35583d2ffb5ed9e564dee0822c9a244058ee0
Backtrace

warning: unused variable: `m1`
  --> treereduce.out:10:9
   |
10 |     let m1: HashMap<_, _> = arr.iter().map(copy).collect();
   |         ^^ help: if this is intentional, prefix it with an underscore: `_m1`
   |
   = note: `#[warn(unused_variables)]` on by default

!dbg attachment points at wrong subprogram for function
!1642 = distinct !DISubprogram(name: "reserve_rehash<(i32, i32), alloc::alloc::Global, hashbrown::map::make_hasher::{closure_env#0}<i32, i32, i32, std::collections::hash::map::RandomState>>", linkageName: "_ZN9hashbrown3raw21RawTable$LT$T$C$A$GT$14reserve_rehash17h66542d3b647441f2E", scope: !1542, file: !818, line: 673, type: !1643, scopeLine: 673, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !62, templateParams: !1676, retainedNodes: !1671)
ptr @"_ZN9hashbrown3raw21RawTable$LT$T$C$A$GT$14reserve_rehash17h66542d3b647441f2E"
  invoke void @_ZN4core9panicking5panic17he5f7c6779e1d5164E(ptr noalias noundef nonnull readonly align 1 %577, i64 noundef %578, ptr noalias noundef nonnull readonly align 8 dereferenceable(24) %579) #66
          to label %580 unwind label %551, !dbg !3554
!3554 = !DILocation(line: 0, scope: !1756)
!1756 = distinct !DILexicalBlock(scope: !1754, file: !818, line: 1429, column: 36)
!1726 = distinct !DISubprogram(name: "resize_inner<alloc::alloc::Global>", linkageName: "_ZN9hashbrown3raw22RawTableInner$LT$A$GT$12resize_inner17hba10e3325cc12a41E", scope: !774, file: !818, line: 1419, type: !1727, scopeLine: 1419, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !62, templateParams: !633, retainedNodes: !1729)
conflicting debug info for argument
  call void @llvm.dbg.value(metadata ptr %0, metadata !2787, metadata !DIExpression()), !dbg !3661
!1673 = !DILocalVariable(name: "additional", arg: 2, scope: !1642, file: !818, line: 675, type: !9)
!2787 = !DILocalVariable(name: "table", arg: 2, scope: !2782, file: !818, line: 682, type: !822)
conflicting debug info for argument
  call void @llvm.dbg.value(metadata i64 %548, metadata !2788, metadata !DIExpression()), !dbg !3661
!1674 = !DILocalVariable(name: "hasher", arg: 3, scope: !1642, file: !818, line: 676, type: !179)
!2788 = !DILocalVariable(name: "index", arg: 3, scope: !2782, file: !818, line: 682, type: !9)
!dbg attachment points at wrong subprogram for function
!1642 = distinct !DISubprogram(name: "reserve_rehash<(i32, i32), alloc::alloc::Global, hashbrown::map::make_hasher::{closure_env#0}<i32, i32, i32, std::collections::hash::map::RandomState>>", linkageName: "_ZN9hashbrown3raw21RawTable$LT$T$C$A$GT$14reserve_rehash17h66542d3b647441f2E", scope: !1542, file: !818, line: 673, type: !1643, scopeLine: 673, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !62, templateParams: !1676, retainedNodes: !1671)
ptr @"_ZN9hashbrown3raw21RawTable$LT$T$C$A$GT$14reserve_rehash17h66542d3b647441f2E"
  invoke void @_ZN4core9panicking5panic17he5f7c6779e1d5164E(ptr noalias noundef nonnull readonly align 1 @anon.263e188e0c7062297bf76a7be6bcc7e2.28, i64 noundef 47, ptr noalias noundef nonnull readonly align 8 dereferenceable(24) @anon.263e188e0c7062297bf76a7be6bcc7e2.29) #66
          to label %584 unwind label %558, !dbg !3551
!3551 = !DILocation(line: 0, scope: !1757)
!1757 = distinct !DILexicalBlock(scope: !1755, file: !818, line: 1429, column: 36)
!1727 = distinct !DISubprogram(name: "resize_inner<alloc::alloc::Global>", linkageName: "_ZN9hashbrown3raw22RawTableInner$LT$A$GT$12resize_inner17hba10e3325cc12a41E", scope: !774, file: !818, line: 1419, type: !1728, scopeLine: 1419, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !62, templateParams: !633, retainedNodes: !1730)
rustc: /home/matthias/vcs/github/rust_debug_assertions/src/llvm-project/llvm/lib/CodeGen/LexicalScopes.cpp:178: llvm::LexicalScope *llvm::LexicalScopes::getOrCreateRegularScope(const llvm::DILocalScope *): Assertion `cast<DISubprogram>(Scope)->describes(&MF->getFunction())' failed.
[2]    3928429 IOT instruction  RUSTFLAGS="" ~/.rustup/toolchains/local-debug-assertions/bin/rustc  -Clto

@rustbot claim

This seems to have been fixed in #113593.