[mlir] LLVM dialect: use addressof instead of constant to create function pointers
authorAlex Zinenko <zinenko@google.com>
Mon, 29 Jun 2020 10:16:23 +0000 (12:16 +0200)
committerAlex Zinenko <zinenko@google.com>
Mon, 29 Jun 2020 10:21:33 +0000 (12:21 +0200)
commitcba733edf5383344243688dfb249f0960bef33bf
treefadc5a449616c22f5e9ef682417906b8ade1db6e
parente503851d80e7a8a72e014bcb975157e828dab800
[mlir] LLVM dialect: use addressof instead of constant to create function pointers

`llvm.mlir.constant` was originally introduced as an LLVM dialect counterpart
to `std.constant`. As such, it was supporting "function pointer" constants
derived from the symbol name. This is different from `std.constant` that allows
for creation of a "function" constant since MLIR, unlike LLVM IR, supports
this. Later, `llvm.mlir.addressof` was introduced as an Op that obtains a
constant pointer to a global in the LLVM dialect. It naturally extends to
functions (in LLVM IR, functions are globals) and should be used for defining
"function pointer" values instead.

Fixes PR46344.

Differential Revision: https://reviews.llvm.org/D82667
12 files changed:
mlir/docs/Dialects/LLVM.md
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/test/Conversion/StandardToLLVM/convert-funcs.mlir
mlir/test/Dialect/LLVMIR/global.mlir
mlir/test/Dialect/LLVMIR/invalid.mlir
mlir/test/Dialect/LLVMIR/roundtrip.mlir
mlir/test/Target/import.ll
mlir/test/Target/llvmir.mlir