@@ -118,29 +118,35 @@ static Instruction *splitBeforeCatchSwitch(CatchSwitchInst *CatchSwitch) {
118118
119119// We use a pointer use visitor to track how an alloca is being used.
120120// The goal is to be able to answer the following three questions:
121- // 1. Should this alloca be allocated on the frame instead.
122- // 2. Could the content of the alloca be modified prior to CoroBegn, which would
123- // require copying the data from alloca to the frame after CoroBegin.
124- // 3. Is there any alias created for this alloca prior to CoroBegin, but used
125- // after CoroBegin. In that case, we will need to recreate the alias after
126- // CoroBegin based off the frame. To answer question 1, we track two things:
127- // a. List of all BasicBlocks that use this alloca or any of the aliases of
121+ // 1. Should this alloca be allocated on the frame instead.
122+ // 2. Could the content of the alloca be modified prior to CoroBegin, which
123+ // would require copying the data from the alloca to the frame after
124+ // CoroBegin.
125+ // 3. Are there any aliases created for this alloca prior to CoroBegin, but
126+ // used after CoroBegin. In that case, we will need to recreate the alias
127+ // after CoroBegin based off the frame.
128+ //
129+ // To answer question 1, we track two things:
130+ // A. List of all BasicBlocks that use this alloca or any of the aliases of
128131// the alloca. In the end, we check if there exists any two basic blocks that
129- // cross suspension points. If so, this alloca must be put on the frame. b.
130- // Whether the alloca or any alias of the alloca is escaped at some point,
132+ // cross suspension points. If so, this alloca must be put on the frame.
133+ // B. Whether the alloca or any alias of the alloca is escaped at some point,
131134// either by storing the address somewhere, or the address is used in a
132135// function call that might capture. If it's ever escaped, this alloca must be
133136// put on the frame conservatively.
137+ //
134138// To answer quetion 2, we track through the variable MayWriteBeforeCoroBegin.
135139// Whenever a potential write happens, either through a store instruction, a
136140// function call or any of the memory intrinsics, we check whether this
137- // instruction is prior to CoroBegin. To answer question 3, we track the offsets
138- // of all aliases created for the alloca prior to CoroBegin but used after
139- // CoroBegin. std::optional is used to be able to represent the case when the
140- // offset is unknown (e.g. when you have a PHINode that takes in different
141- // offset values). We cannot handle unknown offsets and will assert. This is the
142- // potential issue left out. An ideal solution would likely require a
143- // significant redesign.
141+ // instruction is prior to CoroBegin.
142+ //
143+ // To answer question 3, we track the offsets of all aliases created for the
144+ // alloca prior to CoroBegin but used after CoroBegin. std::optional is used to
145+ // be able to represent the case when the offset is unknown (e.g. when you have
146+ // a PHINode that takes in different offset values). We cannot handle unknown
147+ // offsets and will assert. This is the potential issue left out. An ideal
148+ // solution would likely require a significant redesign.
149+
144150namespace {
145151struct AllocaUseVisitor : PtrUseVisitor<AllocaUseVisitor> {
146152 using Base = PtrUseVisitor<AllocaUseVisitor>;
0 commit comments