[Mlir-commits] [mlir] [MLIR][LLVM] Block address support (PR #134335)
Tobias Gysi
llvmlistbot at llvm.org
Fri Apr 4 01:10:39 PDT 2025
================
@@ -3815,6 +3840,55 @@ void InlineAsmOp::getEffects(
}
}
+//===----------------------------------------------------------------------===//
+// BlockAddressOp
+//===----------------------------------------------------------------------===//
+
+LogicalResult
+BlockAddressOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
+ Operation *symbol = symbolTable.lookupSymbolIn(parentLLVMModule(*this),
+ getBlockAddr().getFunction());
+ auto function = dyn_cast_or_null<LLVMFuncOp>(symbol);
+
+ if (!function)
+ return emitOpError("must reference a function defined by 'llvm.func'");
+
+ return success();
+}
+
+LLVMFuncOp BlockAddressOp::getFunction(SymbolTableCollection &symbolTable) {
+ return dyn_cast_or_null<LLVMFuncOp>(symbolTable.lookupSymbolIn(
+ parentLLVMModule(*this), getBlockAddr().getFunction()));
+}
+
+BlockTagOp BlockAddressOp::getBlockTagOp() {
+ auto m = (*this)->getParentOfType<ModuleOp>();
+ auto funcOp = cast<LLVMFuncOp>(mlir::SymbolTable::lookupNearestSymbolFrom(
+ m, getBlockAddr().getFunction()));
+
+ BlockTagOp blockTagOp = nullptr;
+ funcOp.walk([&](LLVM::BlockTagOp labelOp) {
+ if (labelOp.getTag() == getBlockAddr().getTag()) {
+ blockTagOp = labelOp;
+ return WalkResult::interrupt();
+ }
+ return WalkResult::advance();
+ });
+ return blockTagOp;
+}
+
+LogicalResult BlockAddressOp::verify() {
+ if (!getBlockTagOp())
----------------
gysit wrote:
That sounds definitely like we need to prevent inlining for any functions that contain a blockTagOp!
You should be able to add the op here:
https://github.com/llvm/llvm-project/blob/92923e517c2926eb94b7b6e403433ecf62953186/mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp#L730
The verifier seems pretty expensive but since I do not expect the op to show up too often I expect this to be fine.
https://github.com/llvm/llvm-project/pull/134335
More information about the Mlir-commits
mailing list