Lancern wrote:

> I find myself thinking that instead of this being a property of a load/store, 
> perhaps this should be a property of the loop or alloca. WDYT? So the 
> following:

A relevant issue we met when originally trying implement this in the incubator 
is to emit LLVM lifetime markers for local variables. The problems are actually 
very alike:

- To emit proper LLVM lifetime markers, we need some CIR operation that marks 
the lifetime span of the alloca, even if it is hoisted.
- If the local variable is `const`, we need to explicitly mark its constness in 
that same lifetime span.

So you could think of InvariantGroupOp as some sort of "lifetime markers for 
const local variables", but we don't leverage that for emitting LLVM lifetime 
markers for now. We could materialize this idea into a general "variable 
lifetime marker" operation: (the op name is randomly chosen without much 
thought)

```mlir
cir.func @foo() {
  %x.slot = cir.alloca !s32i
  cir.scope {
    cir.while {
      %x = cir.start_lifetime %x.slot [const]
      // ...
    }
  }
}
```

https://github.com/llvm/llvm-project/pull/175037
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to