[all-commits] [llvm/llvm-project] a168dd: [MLIR][LLVM] Block address support (#134335)

Bruno Cardoso Lopes via All-commits all-commits at lists.llvm.org
Mon Apr 7 17:53:41 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a168ddc470825091ad52da12042fb38491ed81d6
      https://github.com/llvm/llvm-project/commit/a168ddc470825091ad52da12042fb38491ed81d6
  Author: Bruno Cardoso Lopes <bruno.cardoso at gmail.com>
  Date:   2025-04-07 (Mon, 07 Apr 2025)

  Changed paths:
    M mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
    M mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
    M mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
    M mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
    M mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp
    M mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
    M mlir/lib/Target/LLVMIR/ModuleImport.cpp
    M mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
    A mlir/test/Dialect/LLVMIR/blockaddress-canonicalize.mlir
    M mlir/test/Dialect/LLVMIR/constant-folding.mlir
    M mlir/test/Dialect/LLVMIR/inlining.mlir
    M mlir/test/Dialect/LLVMIR/invalid.mlir
    M mlir/test/Dialect/LLVMIR/roundtrip.mlir
    A mlir/test/Target/LLVMIR/Import/blockaddress.ll
    M mlir/test/Target/LLVMIR/Import/import-failure.ll
    A mlir/test/Target/LLVMIR/blockaddress.mlir

  Log Message:
  -----------
  [MLIR][LLVM] Block address support (#134335)

Add support for import and translate.

MLIR does not support using basic block references outside a function
(like LLVM does), This PR does not consider changes to MLIR to that
respect. It instead introduces two new ops: `llvm.blockaddress` and
`llvm.blocktag`. Here's an example:

```
llvm.func @ba() -> !llvm.ptr {
  %0 = llvm.blockaddress <function = @ba, tag = <id = 1>> : !llvm.ptr
  llvm.br ^bb1
^bb1:  // pred: ^bb0
  llvm.blocktag <id = 1>
  llvm.return %0 : !llvm.ptr
}
```

Value `%0` hold the address of block tagged as `id = 1` in function
`@ba`. Block tags need to be unique within a function and use of
`llvm.blockaddress` requires a matching tag in a `llvm.blocktag`.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list