Use `void (ptr)` on `LLVM::GlobalOp` when available in LLVM dialect to represent aliased functions
Similar issue from https://github.com/llvm/clangir/issues/1065, we cannot use globals at all (even if we ignore the absence of alias) to start representing aliases. llvm.mlir.globals don't seem to accept anything besides !llvm.ptr as it's types and there are no existing casts to use in its initializers that can allows us to map from llvm.mlir.addressof.
To be more concrete, I want to generate this following 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 {
...
This also needs to be filed against upstream MLIR.
Filed upstream: https://github.com/llvm/llvm-project/issues/115392
It looks like you implemented the necessary support in the LLVM dialect, but we still aren't lowering to aliases in CIR. I'm working on a patch that implements this for function aliases. I'll put up a PR as soon as I get it cleaned up. I haven't looked at non-function aliases yet.
I think https://github.com/llvm/clangir/pull/1739 addresses this issue.
Great, thanks Andy!