[Mlir-commits] [mlir] [MLIR][LLVM] Block address support (PR #134335)
Tobias Gysi
llvmlistbot at llvm.org
Sat Apr 5 05:33:33 PDT 2025
================
@@ -0,0 +1,39 @@
+// RUN: mlir-opt %s -pass-pipeline='builtin.module(llvm.func(canonicalize{region-simplify=aggressive}))' -split-input-file | FileCheck %s
+
+// CHECK-LABEL: llvm.func @ba()
+llvm.func @ba() -> !llvm.ptr {
+ %0 = llvm.blockaddress <function = @ba, tag = <id = 1>> : !llvm.ptr
+ llvm.br ^bb1
+^bb1:
+ // CHECK: llvm.blocktag <id = 1>
+ llvm.blocktag <id = 1>
+ llvm.return %0 : !llvm.ptr
+}
+
+// -----
+
+
+llvm.mlir.global private @g() {addr_space = 0 : i32, dso_local} : !llvm.ptr {
+ %0 = llvm.blockaddress <function = @fn, tag = <id = 0>> : !llvm.ptr
+ llvm.return %0 : !llvm.ptr
+}
+
+llvm.mlir.global private @h() {addr_space = 0 : i32, dso_local} : !llvm.ptr {
+ %0 = llvm.blockaddress <function = @fn, tag = <id = 1>> : !llvm.ptr
+ llvm.return %0 : !llvm.ptr
+}
+
+// CHECK-LABEL: llvm.func @fn
+llvm.func @fn(%cond : i1, %arg0 : i32, %arg1 : i32) -> i32 {
+ llvm.cond_br %cond, ^bb1, ^bb2
+^bb1:
+ // CHECK: llvm.blocktag <id = 0>
+ // CHECK: llvm.return
+ llvm.blocktag <id = 0>
+ llvm.return %arg0 : i32
----------------
gysit wrote:
I actually think it would be better to but a branch to bb2 here like in the example discussed on the revision? That way we can catch the case when someone adds a canonicalization to merge consecutive blocks?
https://github.com/llvm/llvm-project/pull/134335
More information about the Mlir-commits
mailing list