[Mlir-commits] [mlir] [MLIR][LLVM] Support for indirectbr (PR #135092)
Tobias Gysi
llvmlistbot at llvm.org
Sun Apr 13 10:16:41 PDT 2025
================
@@ -2306,19 +2306,31 @@ static LogicalResult verifyComdat(Operation *op,
static LogicalResult verifyBlockTags(LLVMFuncOp funcOp) {
llvm::DenseSet<BlockTagAttr> blockTags;
BlockTagOp badBlockTagOp;
+ enum { DupTag, UnrecheableBlock } errorMsgType;
if (funcOp
.walk([&](BlockTagOp blockTagOp) {
+ mlir::Block *block = blockTagOp->getBlock();
+ if (!block->isEntryBlock() && block->use_empty()) {
+ badBlockTagOp = blockTagOp;
+ errorMsgType = UnrecheableBlock;
+ return WalkResult::interrupt();
+ }
+
if (blockTags.contains(blockTagOp.getTag())) {
badBlockTagOp = blockTagOp;
+ errorMsgType = DupTag;
return WalkResult::interrupt();
}
blockTags.insert(blockTagOp.getTag());
return WalkResult::advance();
})
.wasInterrupted()) {
- badBlockTagOp.emitError()
- << "duplicate block tag '" << badBlockTagOp.getTag().getId()
- << "' in the same function: ";
+ if (errorMsgType == DupTag)
+ badBlockTagOp.emitError()
+ << "duplicate block tag '" << badBlockTagOp.getTag().getId()
+ << "' in the same function: ";
+ else
+ badBlockTagOp.emitError() << "not allowed in unrecheable blocks";
----------------
gysit wrote:
Let's maybe add comment here (or in the walk where the emitError supposedly can move) that this verifier is different from verifier in LLVM proper which allows such cases. We could additionally say that this is needed since MLIR does not support block labels and there is currently no way to prevent the region simplifier from deleting such blocks with block tags. I think this may be relevant for future us debugging issues around this.
Note that the LLVM dialect verifier should not be more strict than LLVM propers verifier. I would say we can make an exception here since there is no clean way of modeling block labels and we currently cannot represent the UB case in MLIR's LLVM dialect.
https://github.com/llvm/llvm-project/pull/135092
More information about the Mlir-commits
mailing list