[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:19:26 PDT 2026
https://github.com/E00N777 commented:
@Lancern
Thanks! I tried `let llvmOp = "LifetimeStartOp"/"LifetimeEndOp"`, but it doesn't compile for these ops. cir-tblgen's `CIRLoweringEmitter.cpp` always emits `typeConverter->convertType(op.getType())`, and `op.getType()` only exists on single-result ops — `cir.lifetime.start/end` have no results:
```
error: 'class cir::LifetimeStartOp' has no member named 'getType'
```
This matches the rest of the dialect: every result-less op — `cir.stackrestore`, `cir.memcpy`, `cir.memset`, … — uses a hand-written pattern. In particular `cir.stackrestore` has the exact same signature as these ops (one !cir.ptr operand, no result) and is lowered the same way I've done here:
```
rewriter.replaceOpWithNewOp<mlir::LLVM::StackRestoreOp>(op, adaptor.getPtr());
```
So I've kept the hand-written matchAndRewrite for now. Teaching CIRLoweringEmitter.cpp to support zero-result ops feels out of scope for this PR — I'd be happy to do it in a separate PR if you think it's worthwhile. WDYT?
https://github.com/llvm/llvm-project/pull/199599
More information about the cfe-commits
mailing list