[clang] [CIR] Add cir.lifetime.start and cir.lifetime.end Op (PR #199599)

Jiahao Guo via cfe-commits cfe-commits at lists.llvm.org
Sat May 30 02:27:30 PDT 2026


================
@@ -4383,6 +4391,18 @@ cir::EhTypeIdOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
   return success();
 }
 
+//===----------------------------------------------------------------------===//
+// LifetimeStartOp & LifetimeEndOp
+//===----------------------------------------------------------------------===//
+
+LogicalResult cir::LifetimeStartOp::verify() {
+  return verifyProducedBy<cir::AllocaOp>(*this, getPtr(), "ptr");
+}
+
+LogicalResult cir::LifetimeEndOp::verify() {
+  return verifyProducedBy<cir::AllocaOp>(*this, getPtr(), "ptr");
----------------
E00N777 wrote:

I'm intentionally keeping these a 1:1 mirror of llvm.lifetime.start/end,
which aren't SSA-linked, following andy's suggestion to start simple. I did prototype
the token form (end taking start's result), but the token has no LLVM type and would
need a 1:N lowering pattern or a pre-lowering erase pass like the EH tokens — too heavy
for this PR. For now the late pass that emits these markers (only on allocas) owns the
start/end pairing; enforcing it in the verifier would need dominance analysis. Happy to
revisit a stronger guarantee in a follow-up if you think it's worthwhile.

https://github.com/llvm/llvm-project/pull/199599


More information about the cfe-commits mailing list