Repository: rust
Issue: ice: cfi: LLVM ERROR with polymorphic paths
Labels: I-ICE,T-compiler,A-sanitizers,C-bug,requires-nightly,PG-exploit-mitigations

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.
http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
-->

### Code
from `ufcs-polymorphic-path.rs`
`rustc ufcs-polymorphic-paths.rs -Copt-level=3 -Cdebuginfo=2 -Clto -Zsanitizer=cfi`
```Rust
use std::borrow::{Cow, ToOwned};
use std::default::Default;

pub struct XorShiftRng;
impl Rng for XorShiftRng {}
pub trait Rng {}
pub trait Rand: Default + Sized {
    fn rand<R: Rng>(_rng: &mut R) -> Self { Default::default() }
}
impl Rand for i32 { }

pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
    fn into_cow(self) -> Cow<'a, B>;
}

impl<'a> IntoCow<'a, str> for String {
    fn into_cow(self) -> Cow<'a, str> {
        Cow::Owned(self)
    }
}

#[derive(PartialEq, Eq)]
struct Newt<T>(T);

fn eq<T: Eq>(a: T, b: T) -> bool { a == b }


trait Size: Sized {
    fn size() -> usize { std::mem::size_of::<Self>() }
}
impl<T> Size for T {}



#[derive(PartialEq, Eq)]
struct Foo<T>(T);


macro_rules! tests {
    ($($expr:expr, $ty:ty, ($($test:expr),*);)+) => (pub fn main() {$({
        static S: $ty = $expr;
        assert!(eq(S($($test),*), $expr($($test),*)));
    })+})
}

tests! {
    <Vec<()>>::with_capacity, fn(usize) -> Vec<()>, (5);  
}

```


### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.72.0-nightly (e6d4725c7 2023-06-05)
binary: rustc
commit-hash: e6d4725c76f3b526c74454bc51afdf6daf133506
commit-date: 2023-06-05
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.4
```

### Error output

```
-
```

<!--
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>Backtrace</strong></summary>
<p>

```
!dbg attachment points at wrong subprogram for function
!199 = distinct !DISubprogram(name: "main", linkageName: "_ZN22ufcs_polymorphic_paths4main17h5fab3a21c907a36eE", scope: !14, file: !15, line: 40, type: !195, scopeLine: 40, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized | DISPFlagMainSubprogram, unit: !8, templateParams: !46, retainedNodes: !46)
ptr @_ZN22ufcs_polymorphic_paths4main17h5fab3a21c907a36eE.cfi
  call void @llvm.dbg.declare(metadata ptr undef, metadata !232, metadata !DIExpression()), !dbg !236
!236 = !DILocation(line: 671, column: 46, scope: !233, inlinedAt: !237)
!238 = distinct !DISubprogram(name: "with_capacity<()>", linkageName: "_ZN5alloc3vec12Vec$LT$T$GT$13with_capacity17h0185b499b8c3601eE", scope: !19, file: !206, line: 478, type: !17, scopeLine: 478, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !8, templateParams: !41, declaration: !207, retainedNodes: !239)
!238 = distinct !DISubprogram(name: "with_capacity<()>", linkageName: "_ZN5alloc3vec12Vec$LT$T$GT$13with_capacity17h0185b499b8c3601eE", scope: !19, file: !206, line: 478, type: !17, scopeLine: 478, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !8, templateParams: !41, declaration: !207, retainedNodes: !239)
!dbg attachment points at wrong subprogram for function
!199 = distinct !DISubprogram(name: "main", linkageName: "_ZN22ufcs_polymorphic_paths4main17h5fab3a21c907a36eE", scope: !14, file: !15, line: 40, type: !195, scopeLine: 40, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized | DISPFlagMainSubprogram, unit: !8, templateParams: !46, retainedNodes: !46)
ptr @_ZN22ufcs_polymorphic_paths4main17h5fab3a21c907a36eE.cfi
  call void @llvm.dbg.declare(metadata ptr undef, metadata !232, metadata !DIExpression()), !dbg !236
!236 = !DILocation(line: 671, column: 46, scope: !233, inlinedAt: !237)
!238 = distinct !DISubprogram(name: "with_capacity<()>", linkageName: "_ZN5alloc3vec12Vec$LT$T$GT$13with_capacity17h0185b499b8c3601eE", scope: !19, file: !206, line: 478, type: !17, scopeLine: 478, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !8, templateParams: !41, declaration: !207, retainedNodes: !239)
!238 = distinct !DISubprogram(name: "with_capacity<()>", linkageName: "_ZN5alloc3vec12Vec$LT$T$GT$13with_capacity17h0185b499b8c3601eE", scope: !19, file: !206, line: 478, type: !17, scopeLine: 478, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !8, templateParams: !41, declaration: !207, retainedNodes: !239)
LLVM ERROR: Broken module found, compilation aborted!
```

</p>
</details>


<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"rcvalle"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->