================
@@ -139,11 +139,21 @@ static void emitDeclDestroy(CIRGenFunction &cgf, const
VarDecl *vd,
cgf.getLoc(vd->getSourceRange()),
mlir::FlatSymbolRefAttr::get(fnOp.getSymNameAttr()),
mlir::ValueRange{cgm.getAddrOfGlobalVar(vd)});
+ assert(fnOp && "expected cir.func");
+ // TODO(cir): This doesn't do anything but check for unhandled conditions.
+ // What it is meant to do should really be happening in LoweringPrepare.
+ cgm.getCXXABI().registerGlobalDtor(vd, fnOp, nullptr);
} else {
- cgm.errorNYI(vd->getSourceRange(), "array destructor");
+ // Otherwise, a custom destroyed is needed. Classic codegen creates a
helper
+ // function here and emits the destroy into the helper function, which is
+ // called from __cxa_atexit.
+ // In CIR, we just emit the destroy into the dtor region. It will be moved
+ // into a separate function during the LoweringPrepare pass.
+ mlir::Value globalVal = cgf.getBuilder().createGetGlobal(addr);
----------------
AmrDeveloper wrote:
```suggestion
mlir::Value globalVal = builder.createGetGlobal(addr);
```
https://github.com/llvm/llvm-project/pull/169070
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits