<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115392>115392</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missing function pointer (e.g. `void (ptr)`) support in `mlir::LLVM::GlobalOp`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir:llvm
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bcardosolopes
</td>
</tr>
</table>
<pre>
While working on ClangIR to LLVM lowering, we want to generate this kind of LLVM IR code:
```
@_ZN1BD1Ev = dso_local unnamed_addr alias void (ptr), ptr @_ZN1BD2Ev
@_ZN1CD2Ev = dso_local unnamed_addr alias void (ptr), ptr @_ZN1BD2Ev
@_ZN1CD1Ev = dso_local unnamed_addr alias void (ptr), ptr @_ZN1BD2Ev
define dso_local void @_ZN1BD2Ev(ptr noundef nonnull align 8 dereferenceable(9) %this) unnamed_addr #0 {
```
However, one of the issues is that `llvm.mlir.global`s don't seem to accept anything besides `!llvm.ptr` as their types and there are no existing casts to use in its initializers that can allows us to load `llvm.mlir.addressof` as `void (ptr)`. I tried several combinations but didn't get successful, let me know if I'm missing anything. The other reason we can't generate this is the missing `alias`, tracked in https://github.com/llvm/llvm-project/issues/115390
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VE2PpDYQ_TXmUgoyphu6DxzmYzsZaTeRVlEi5TIydgHOGBdyme5Mfn1kunczE-0tiYSwDfbzq_eqSjO7MSB2Yn8v9o-FXtNEseuNjpaYPC3IRU_2tft1ch7hQvHFhREowIPXYXz6DIng48dfPoGnC0YXRqEe4IJw0SHlfyMGjDohpMkxvLhggYbriafPYMiiqO-EfBTyTjTy9lyXO_n824_V_WP14QyifgTL9OzJaA9rCHpG-6ytjaC90wxnchaEOiwpCnXMJJYU4SuG-nB-h_qQv_wPqP8pV7gOFgcX8A3k9fzb7RsWBFqDxQEChbB6n28bAxzAYsQBIwaDuvco1OEo1BGE2mdT8vQdSaFqCaK9_7Yr2_sHuuAZY6YOFDBbmiYEx7wig2NIk04gGun9eS5n72I5euq1F41ksBSEahMw4pxzRBuDSwIdXtOUs6tHdhY5nxeq2iCyVI0EnZHRRUivCzLoYPM6IuiIEAjwD8cpQxjNiTP2yggugEsMLrjktHd_YrwRNDqA9p4uDOu225O272lnRZCZhtv1opH_sK-RJTxBig4tcFZFezA09y7o5Cgw9GsC6-w15hET8GoMMg-rzwJ6TDAjvAS6gBvgSah2htkx5zi-aFLCzxMC5WAhomYKuciM_gL6tsg2-fErhGjklnabmg-QojYvaLMoU0oL5_JTJ6FOo0vT2peGZqFOWYDb8N0S6Xc0SajT1V-hTlW1r4_vMqKwXW2P9VEX2FVtXUlVqfZYTF1fHc1B9fudbdt2v7OHGlUlh6Fvm7ZuJRauU1Ltqkq2qq529aGssW2r-qCxHbBueit2EmftfLm5QnEsNh7dRkIVXvfoeetgSmXPRH13pa9yS4vdFkS_jix20jtO_DdQcslj9-mm1LAGky2DhVxImCvhgOVYftP0XDa8LgvFlLUUjbzdLeq73N6us--3rP9pEY0s1ui7fym5Ks6d-isAAP__4SPTNQ">