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

    <tr>
        <th>Summary</th>
        <td>
            Flaky  "invalid forward reference to function"
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            opaque-pointers,
            llvm
      </td>
    </tr>

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

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

<pre>
    ```
@glob = constant i64 ptrtoint (i64* @glob to i64)

define void @call_func() {
  call void @func()
  ret void
}

define i32 @func() {
   ret i32 1
}
```

This IR will fail with:

```
./bin/llc: error: ./bin/llc: /tmp/test4.ll:4:13: error: invalid forward reference to function 'func' with wrong type: expected 'i32 ()*' but was 'void ()*'
  call void @func()
            ^
```

but if I comment out `@glob`, there is no error. Adding some printfs, it looks like the types when `@glob` is not commented out are:

```
void ()*
i32 ()*
```

but when it is commented out, the types are both `ptr`. I imagine the failure should persist independently of `@glob`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVE2P2jAQ_TXJxdoocYghhxzYUqTtqap6r5x4krhr7NR2oPz7jh0oC61Wi8LE9rz5eM8DrRHnJmH55cl3Sb5NVvmgTEuSckc6o53n2hPJVmTy1huJm4RucJ_QLblivSHxpL6kiFZALzWQo5EiADuu1I9-1h2GI5Ik6-cFR0hw_cXdIFe3BR-9l-Tr3X-qyJLeB7_NHzMERPGY4oF6tN9H6cjLN3KS2FXPpcKVH5Ny-xb0EJkldN9KjVapDqEErDU2LP7x4MofpmDB-VWmFB6u8FuUd3FSH7lCRXpjT9wKpNCDBd1BEDvQ9NJoTLZeKK9jk-RkjR6IP08Qk_2eoPMgAiwKtMhKtwHfzp6cuAu-Rfo3zg9ezO2TVJ_fUTSUkj15wXk6HAAnyOBBwCzjE1b0E_EjEiSovTaLDBnZCiGRjzMHIJPF2etdQEpPlDGvjij5CiEuMnbkNIK-z7uk89fCKEUozS28f50PgsSzewHfJxsbwS6x-l3lC81Lu9gGaQ3eGmbAHxfaDDWSBz6EiQ64MH0zotxoZiXIBNZJh2m1gAnQaK_OxPT3nLMUmoKxKq_romSpaEpRlzVPvfQKmr3ir2e8MEo_NGGIS2ermtH7yQXR6B6fAWdtbjPkFuf6eH09Tdb8xJHDrXRuBrytfbWheZ2OTUdZ2a9XbQsbtimpWFds066KqhMbBpSJVPEWlGuS6hmLmon_muFpCn84yBpPgnb4WqrRpNqlsqE5pUWeM1qWtGBZ2dVVxWvaloz1WA01gQNKmIWgzNghtU1ss50Hh06FYrqbkzsnBw0QW8D8fPajsc1X-QXVB5dGSk3k8weI6obw">