@@ -53,16 +53,16 @@ struct TransformParamsToConstRefContext
5353 // - Scan transitively the uses of the transformed ops, and add IRLoad
5454 // in front of them as well.
5555 //
56- // Phase 2 (post-fixup)
56+ // Phase 2
5757 // - Check all translated IRGetElementPtr instructions. If the index is
5858 // a newly translated IRGetElementPtr or IRFieldAddress, add an IRLoad
59- // to fetch the value of the pointer. This load was omitted in Phase 1
60- // due to the exception.
61- // - Note that the post-fixup phase avoids problems with rewrite
62- // ordering, so we don't try to fuse this in Phase 1
59+ // to fetch the value of the pointer. This insertion of load may have
60+ // been omitted in Phase 1 due to the exception.
61+ // - Note that doing a separate phase avoids problems with IR
62+ // op rewrite ordering, since all rewrites are already done in Phase
6363 //
64- // In addition, IRStore instructions are attempted to also optimize. See
65- // the related comment below.
64+ // In addition, IRStore instructions are also attempted to be
65+ // optimized. See the related comment below.
6666
6767 HashSet<IRInst*> workListSet;
6868 workListSet.add (newAddrInst);
@@ -152,17 +152,17 @@ struct TransformParamsToConstRefContext
152152 auto getElementPtr = as<IRGetElementPtr>(inst);
153153 IRInst* indexInst = getElementPtr->getOperand (1 );
154154
155- // In the postfix phase, we 'll only consider index instructions if
156- // they were transformed previously by this function. This is an
157- // extra precaution to avoid hiding bugs by other passes, should
158- // they also pass pointers directly as the index.
155+ // We 'll only consider index instructions if they were transformed
156+ // previously by this function. This is an extra precaution to avoid
157+ // hiding bugs by other passes, should they also pass pointers
158+ // directly as the IRGetElementPtr index.
159159 if (workListSet.contains (indexInst))
160160 {
161161 switch (indexInst->getOp ())
162162 {
163163 case kIROp_FieldAddress :
164164 case kIROp_GetElementPtr :
165- // post-fix needed
165+ // additional IRLoad() needed
166166 builder.setInsertBefore (getElementPtr);
167167 auto loadInst = builder.emitLoad (indexInst);
168168 getElementPtr->setOperand (1 , loadInst);
0 commit comments