https://github.com/E00N777 commented:
@erichkeane Firstly, thanks for all your suggestions! They are very helpful! In this version,I added some description to clarify how lifetime maps to scope.like andy said: ``` The cir.alloca operation seems to be doing two things that are closely related but conceptually very different. (1) It allocates stack memory for a variable. (2) It declares a local variable. These are semantically very different. The actual alloca portion of this can and should be hoisted to the function entry in most cases. Because it is semantically moveable, it cannot be relied on to determine the lifetime of the variable. If we're going to try to deduce the lifetime of a variable from its position in CIR scopes, we really need a separate operation to declare the variable. Note that the HoistAllocas pass is currently being run before the FlattenCFG pass, and even if it weren't there is no reason that someone couldn't create a custom pipeline and run it as early as they like. ``` >From my understanding, we need this marker when the scope can no longer >provide lifetime information for local variables, like unstructured control >flow. Currently our consensus is that these ops will be emitted very late, and the markers will only ever appear on `allocas`, so rejecting a global is expected safe. I've also added a test case. Since I'm still at a fairly early stage in compiler development, please correct me if I've made any mistakes. I'd really appreciate any further suggestions you could give me. https://github.com/llvm/llvm-project/pull/199599 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
