@@ -118,29 +118,35 @@ static Instruction *splitBeforeCatchSwitch(CatchSwitchInst *CatchSwitch) {
118
118
119
119
// We use a pointer use visitor to track how an alloca is being used.
120
120
// 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
128
131
// 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,
131
134
// either by storing the address somewhere, or the address is used in a
132
135
// function call that might capture. If it's ever escaped, this alloca must be
133
136
// put on the frame conservatively.
137
+ //
134
138
// To answer quetion 2, we track through the variable MayWriteBeforeCoroBegin.
135
139
// Whenever a potential write happens, either through a store instruction, a
136
140
// 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
+
144
150
namespace {
145
151
struct AllocaUseVisitor : PtrUseVisitor<AllocaUseVisitor> {
146
152
using Base = PtrUseVisitor<AllocaUseVisitor>;
0 commit comments