[mlir][llvm] Fix elem type passing into `getelementptr` (#68136)
As was correctly pointed out by @azteca1998, the element type for a `llvm.getelementptr` was only read when using an attribute and not when using a type. As pointed out in https://github.com/llvm/llvm-project/issues/63832#issuecomment-1643751039, the translation to LLVM would work for ```mlir llvm.func @main(%0 : !llvm.ptr) -> !llvm.ptr { %1 = llvm.getelementptr %0[0] { elem_type = !llvm.ptr } : (!llvm.ptr) -> !llvm.ptr llvm.return %1 : !llvm.ptr } ``` but not for ```mlir llvm.func @main(%0 : !llvm.ptr) -> !llvm.ptr<ptr> { %1 = llvm.getelementptr %0[0] : (!llvm.ptr) -> !llvm.ptr<ptr> llvm.return %1 : !llvm.ptr<ptr> } ``` This was caused by the `LLVM_GEPOp` builder only reading the type from the attribute (`{ elem_type = !llvm.ptr }`), but not from the pointer type (`!llvm.ptr<ptr>`). Fixes #63832. EDIT: During review Markus Böck pointed out that this bugfix adds new functionality for typed pointers, but this functionality shouldn't be there in the first place. In response, Oleksandr "Alex" Zinenko pointed out that this is okay for now since the typed pointers will be removed in an upcoming release anyway, so it's best to merge this PR and spend time on the removal instead.
Loading
Please sign in to comment