[Mlir-commits] [mlir] [MLIR][LLVM] Block address support (PR #134335)

Tobias Gysi llvmlistbot at llvm.org
Fri Apr 4 01:10:39 PDT 2025


================
@@ -1362,9 +1362,19 @@ FailureOr<Value> ModuleImport::convertConstant(llvm::Constant *constant) {
     return builder.create<LLVM::ZeroOp>(loc, targetExtType).getRes();
   }
 
+  if (auto *blockAddr = dyn_cast<llvm::BlockAddress>(constant))
+    return builder
+        .create<BlockAddressOp>(
+            loc, convertType(blockAddr->getType()),
+            BlockAddressAttr::get(
+                context,
+                FlatSymbolRefAttr::get(context,
+                                       blockAddr->getFunction()->getName()),
+                BlockTagAttr::get(context,
+                                  blockAddr->getBasicBlock()->getNumber())))
+        .getRes();
----------------
gysit wrote:

nit: given the complexity I would use braces here and maybe define variables for the symbol and the tag.

https://github.com/llvm/llvm-project/pull/134335


More information about the Mlir-commits mailing list