================
@@ -679,6 +679,52 @@ cir::LocalInitOp::verifySymbolUses(SymbolTableCollection
&symbolTable) {
return success();
}
+//===----------------------------------------------------------------------===//
+// RegisterExitDtorOp
+//===----------------------------------------------------------------------===//
+
+/// Returns true if \p op is nested in the ctor region of a cir.global or
+/// cir.local_init without crossing a cir.func or a cir.register_exit_dtor.
+static bool isInVarCtorRegion(mlir::Operation *op) {
+ for (mlir::Operation *parent = op->getParentOp(); parent;
+ parent = parent->getParentOp()) {
+ mlir::Region *ctorRegion = nullptr;
+ if (auto global = mlir::dyn_cast<cir::GlobalOp>(parent))
+ ctorRegion = &global.getCtorRegion();
+ else if (auto localInit = mlir::dyn_cast<cir::LocalInitOp>(parent))
+ ctorRegion = &localInit.getCtorRegion();
+ else if (mlir::isa<cir::FuncOp, cir::RegisterExitDtorOp>(parent))
+ return false;
+ if (ctorRegion)
+ return ctorRegion->isAncestor(op->getParentRegion());
+ }
+ return false;
+}
+
+LogicalResult cir::RegisterExitDtorOp::verify() {
+ mlir::Block &body = getBody().front();
+ if (body.without_terminator().empty())
+ return emitOpError("body must destroy the object");
+ if (body.getTerminator()->getNumOperands())
+ return emitOpError("body must not yield a value");
+ if (!isInVarCtorRegion(*this))
----------------
adams381 wrote:
It doesn't actually have to go first. LoweringPrepare lowers both, and when it
lowers the global or local_init it splices the ctor body into the init
function, so this op just moves along with it and lowers the same way
afterward. I tried forcing these ops to be lowered last and the tests still
pass.
https://github.com/llvm/llvm-project/pull/229896
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits