Repository: rust
Issue: llvm error: cfi: `Assertion `cast<DISubprogram>(Scope)->describes(&MF->getFunction())`
Labels: I-crash,I-ICE,T-compiler,A-sanitizers,C-bug,requires-debug-assertions,PG-exploit-mitigations

<!--
[31mICE[0m: Rustc ./weak.rs '-Zmir-opt-level=3 -Cdebuginfo=2 -Copt-level=3 -Zsanitizer=cfi -Ccodegen-units=1 -Clto -ocodegen -Zsanitizer-cfi-normalize-integers --edition=2015' 'LLVM ERROR: Broken module found, compilation aborted!', 'LLVM ERROR: Broken module found, compilation aborted!'
File: /tmp/im/2/weak.rs
-->

snippet:
````rust
use std::sync::atomic::Ordering::*;
use std::sync::atomic::{fence, AtomicUsize};
use std::thread::spawn;

fn static_atomic(val: usize) -> &'static AtomicUsize {
    let ret = Box::leak(Box::new(AtomicUsize::new(val)));
    ret
}

fn relaxed() -> bool {
    let x = static_atomic(0);

    let j2 = spawn(move || x.load(Relaxed));

    let r2 = j2.join().unwrap();

    r2 == 1
}

fn seq_cst() -> bool {
    let x = static_atomic(0);

    let j3 = spawn(move || x.load(SeqCst));

    let r3 = j3.join().unwrap();

    r3 == 1
}

fn initialization_write(add_fence: bool) -> bool {
    let x = static_atomic(11);

    let j2 = spawn(move || x.load(Relaxed));

    let r2 = j2.join().unwrap();

    r2 == 11
}

fn assert_once(f: fn() -> bool) {
    assert!(std::iter::repeat_with(|| f()).take(100).any(|x| x));
}

pub fn main() {
    assert_once(relaxed);
    assert_once(seq_cst);
    assert_once(|| initialization_write(false));
}


````

Version information
````
rustc 1.77.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.77.0-dev
LLVM version: 17.0.6

````

Command:
`/home/matthias/.rustup/toolchains/local-debug-assertions/bin/rustc -Zmir-opt-level=3 -Cdebuginfo=2 -Copt-level=3 -Zsanitizer=cfi -Ccodegen-units=1 -Clto -ocodegen -Zsanitizer-cfi-normalize-integers --edition=2015`

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Program output</strong></summary>
<p>

```
warning: unused import: `fence`
 --> /tmp/icemaker_global_tempdir.18GTkKSaGL4b/rustc_testrunner_tmpdir_reporting.PLKsBwe60BMh/mvce.rs:2:25
  |
2 | use std::sync::atomic::{fence, AtomicUsize};
  |                         ^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused variable: `add_fence`
  --> /tmp/icemaker_global_tempdir.18GTkKSaGL4b/rustc_testrunner_tmpdir_reporting.PLKsBwe60BMh/mvce.rs:30:25
   |
30 | fn initialization_write(add_fence: bool) -> bool {
   |                         ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_add_fence`
   |
   = note: `#[warn(unused_variables)]` on by default

inlinable function call in a function with debug info must have a !dbg location
  %34 = tail call noundef zeroext i1 @_ZN4core3ops8function6FnOnce9call_once17h0a5cef41d9043f5eE(), !noalias !6817
inlinable function call in a function with debug info must have a !dbg location
  %34 = tail call noundef zeroext i1 @_ZN4core3ops8function6FnOnce9call_once17h0a5cef41d9043f5eE(), !noalias !6816
LLVM ERROR: Broken module found, compilation aborted!

```

</p>
</details>

<!--
query stack:

-->