<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/148052>148052</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Bug in SimplifyCFG causes ICE
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
sivadeilra
</td>
</tr>
</table>
<pre>
This minimal Rust code causes a failure when the `simplifycfg` pass is enabled:
```rust
pub fn repro_func(shapes: &mut [ShapeInfo<ReproShape>]) {
repro_generic::<ReproShape>(shapes);
}
#[derive(Clone)]
pub struct ShapeInfo<S> {
pub shape: S,
}
#[derive(Default, Copy, Clone)]
pub enum ReproShape {
#[default]
A = 0,
B = 1,
}
pub(crate) fn repro_generic<S: Default + Clone>(shapes: &mut [ShapeInfo<S>]) {
shapes[0] = shapes[1].clone();
shapes[1].shape = Default::default();
}
```
When this is compiled with these Rust args:
```
rustc \
--emit=llvm-ir \
--crate-name=repro \
--edition=2021 \
repro.rs \
--crate-type=lib \
--out-dir=out \
--target=x86_64-pc-windows-msvc \
-Cno-prepopulate-passes
```
it produces `repro.ll`. Rust normally enables `simplifycfg` by default, so I've disabled all passes in this repro. You can manually reproduce the problem by running `opt --passes=simplifycfg repro.ll`.
I tried to attach `repro.ll`, but GitHub rejects `*.ll` files. I'll create a repro PR.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8VE-P-jYQ_TTDZQQyTkLgkAOQ5de9VbuVqp5-cpIJuHLsyH_Y8u0rO4Glu22lSJHGM_PevHm2cE6eNVEFxQGKeiGCvxhbOXkVHUllxaIx3a367SIdDlLLQSh8C85jazrCVgRHDgX2QqpgCT8upNFfCGHDnBxGJftb259hw3AUzqF0SFo0ijrI9sDSt2HTZ4PzwPZjaLDXaGm05mcfdAt86y5iJAfZHoFvhuARisN7jL3q3kB2fIvJKQDZCxQ18B1CeQC2n_ucSZOVbQSN35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