[clang] [CIR] Add cir.lifetime.start and cir.lifetime.end Op (PR #199599)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Mon May 25 23:33:12 PDT 2026
================
@@ -4670,6 +4670,62 @@ def CIR_StackRestoreOp : CIR_Op<"stackrestore"> {
let assemblyFormat = "$ptr attr-dict `:` qualified(type($ptr))";
}
+//===----------------------------------------------------------------------===//
+// LifetimeStartOp & LifetimeEndOp
+//===----------------------------------------------------------------------===//
+
+def CIR_LifetimeStartOp : CIR_Op<"lifetime.start"> {
+ let summary = "Marks the beginning of an alloca object's live range";
+ let description = [{
+ The `cir.lifetime.start` operation marks the beginning of the live range
+ of the memory region pointed to by `$ptr`. Between this operation and a
+ matching `cir.lifetime.end` on the same pointer, the underlying storage
+ is considered live; outside that range it is considered dead, and the
+ optimizer is free to reuse the storage for other purposes.
+
+ This operation exhibits undefined behavior if:
+ * `$ptr` does not point to memory allocated by `cir.alloca`; or
----------------
xlauko wrote:
this can be checked by the verifier, or maybe even create trait like,
```
Producer<"$ptr", "cir::AllocaOp">
```
that checks that producer of ptr operand is AllocaOp. The trait might be handy also in another ops.
https://github.com/llvm/llvm-project/pull/199599
More information about the cfe-commits
mailing list