[clang] [CIR] Implement cleanups for temporaries with automatic duration (PR #189754)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 1 07:25:52 PDT 2026
================
@@ -542,3 +542,29 @@ void CIRGenFunction::popCleanupBlocks(
}
}
}
+
+/// Pops cleanup blocks until the given savepoint is reached, then add the
+/// cleanups from the given savepoint in the lifetime-extended cleanups stack.
+void CIRGenFunction::popCleanupBlocks(
+ EHScopeStack::stable_iterator oldCleanupStackDepth,
+ size_t oldLifetimeExtendedSize, ArrayRef<mlir::Value *> valuesToReload) {
+ popCleanupBlocks(oldCleanupStackDepth, valuesToReload);
+
+ // Move our deferred cleanups onto the EH stack.
+ for (size_t i = oldLifetimeExtendedSize,
+ e = lifetimeExtendedCleanupStack.size();
+ i != e;) {
+ assert((i % alignof(LifetimeExtendedCleanupHeader) == 0) &&
+ "misaligned cleanup stack entry");
+
+ LifetimeExtendedCleanupHeader &header =
+ reinterpret_cast<LifetimeExtendedCleanupHeader &>(
----------------
erichkeane wrote:
Why do we need a reinterpret_cast here? Also, the fact that `lifetimeExtendedCleanupStack` holds chars is.. weird.
Would doing that actually clear up this... oddness of what we're doing with ints here?
https://github.com/llvm/llvm-project/pull/189754
More information about the cfe-commits
mailing list