[all-commits] [llvm/llvm-project] fe283a: [mlir][llvm] Fix elem type passing into `getelemen...
Rik Huijzer via All-commits
all-commits at lists.llvm.org
Thu Oct 5 09:34:28 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: fe283a1ff74fdfa46dd2bedf60e544d747d3416e
https://github.com/llvm/llvm-project/commit/fe283a1ff74fdfa46dd2bedf60e544d747d3416e
Author: Rik Huijzer <github at huijzer.xyz>
Date: 2023-10-05 (Thu, 05 Oct 2023)
Changed paths:
M mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
M mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
M mlir/test/Target/LLVMIR/opaque-ptr.mlir
Log Message:
-----------
[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.
More information about the All-commits
mailing list