<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62876>62876</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [IROutliner] Crash due to missing GVN
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          lanza
      </td>
    </tr>
</table>

<pre>
    When building the following source:

```
# 2 "" 3
typedef a;
typedef struct {
  int b;
  a c;
  a d
} e;
typedef struct {
  int f;
  e g
} h;
typedef struct {
  h ac;
  void *i
} j;
typedef (*k)();
typedef (*l)();
typedef (*m)();
n;
typedef (*ad)();
typedef (*o)();
p(j);
j q();
r() {
  j s = q();
 if (p(s)) {
    a t = s.ac.f ? s.ac.g.d : s.ac.g.c;
    if (t) {
 k a = s.i;
      a();
    }
  }
}
u() {
  j s = q();
 if (p(s)) {
    a t = s.ac.f ? s.ac.g.d : s.ac.g.c;
    if (t) {
 l b = s.i;
      b(u);
    }
  }
}
v() {
  j s = q();
 if (p(s)) {
    a t = s.ac.f ? s.ac.g.d : s.ac.g.c;
    if (t) {
 m c = s.i;
      c(n);
    }
  }
}
w() {
  j s = q();
  if (p(s)) {
    a t = s.ac.f ? s.ac.g.d : s.ac.g.c;
    if (t) {
      ad d = s.i;
      return d(t);
    }
  }
  return 0;
}
x() {
  j s = q();
  if (p(s)) {
    a t = s.ac.f ? s.ac.g.d : s.ac.g.c;
    if (t) {
      o e = s.i;
      return e(t, 0);
    }
  }
  return 0;
}
```

with the following flags:

```
-mthumb
-target
armv7-none-linux-androideabi19
-g3
-mllvm
-ir-outliner
-Oz
-ftrivial-auto-var-init=zero
-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
-c
here2.c
```


We reach a crash here: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/IPO/IROutliner.cpp#L190.

Here is a link to a godbolt repro: https://godbolt.org/z/7Kzf37P4b
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVt1u4zYTfRrqZkBBJiVLvtBFdg1_X9GiWRRF95oSRxITinRJytn10xf6iWMn62SDAkUAgZoZnjmcMyRACu9VaxBLkn0i2TYSQ-isK7UwRxFVVn4vv3ZooBqUlsq0EDqExmptH0bP28HVSPgNSbYkeRzXyfLNLuPAgDBGGAM-x8L3PUpsQBD-6TLigxvqACRf4gDKBKhOOAAB9YUnl2XyLeBP0jVnBAjtE0H3EwQdiPMCDlZJIOxGPbHcvWAhrCDs5p6wzWRtrgD0W4D-JcBcgQr5Fpl9CdgTVtydB-7g72cQN_vnHbkDD4RvX0BBTUuNpH5a6yJr3Lsw5flY1HEDhO9ms40lEH7z6Jx3GxbOcEl2D2JhUhdgAPG8JgAg-fbROZknY_iI-jRUV_RVhBXDuwQePqLAHuorAmvCCvMugQ_vEPjfKZxPowR5RafDMDgDcsl8U-4pIzlBT3PfPm4HLODrDcA58TMk_7YLz--h-XCo0D27xBotWv_6HUb70A19tThBuBbD7AjXH3JqrEGqlRm-UWGks0qiqNRqsyS0_JFG60O_2MpROwStDLolcntcjCY4dVBCUzEESw_CUWVUIHx7RGcXDBpRaaQ_RNIRR-_NpI-qQB-U1rRC6rC3B5S0cbantRZmuftoPf87dMji-pX-zeNXBIei7sbL2AnfwZg4noYuhP3US7YjbNeq0A1VXNuesN0kff7RvbN3WAfCdpW2FWG7XihzhlFj7E8njG-s6z1hu1--3I7jH7dLy-J6vyeM_7baJPF5Zf9Hh6A8CNDK3EOwIKC1srI6gMO9sz-ocp6OrWsJ2x0J2-W_Hhuef0mrSJZcbvhGRFiu1kVarPI0W0Vd2WQ5X4l1UxVFukmZzDaIBeYySwterFMeqZIljCcZ40maJdkqbtY5l3WTsTpP83xVkzTBXigdj5rHtSPl_YDlmhX5OtKiQu2nRxljBh9gmhwfUdk2cuXUxGpoPUkTrXzwTyxBBT295p56RbItfJ62SQ44tqRX3o8n_39__R4NTpfv3rWpmnFbpmr_CQAA___f8aya">