File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -239,10 +239,21 @@ void FlowAwareEmbedder::computeEmbeddings(const BasicBlock &BB) const {
239239 // If the operand is defined elsewhere, we use its embedding
240240 if (const auto *DefInst = dyn_cast<Instruction>(Op)) {
241241 auto DefIt = InstVecMap.find (DefInst);
242- assert (DefIt != InstVecMap.end () &&
243- " Instruction should have been processed before its operands" );
244- ArgEmb += DefIt->second ;
245- continue ;
242+ // Fixme (#159171): Ideally we should never miss an instruction
243+ // embedding here.
244+ // But when we have cyclic dependencies (e.g., phi
245+ // nodes), we might miss the embedding. In such cases, we fall back to
246+ // using the vocabulary embedding. This can be fixed by iterating to a
247+ // fixed-point, or by using a simple solver for the set of simultaneous
248+ // equations.
249+ // Another case when we might miss an instruction embedding is when
250+ // the operand instruction is in a different basic block that has not
251+ // been processed yet. This can be fixed by processing the basic blocks
252+ // in a topological order.
253+ if (DefIt != InstVecMap.end ())
254+ ArgEmb += DefIt->second ;
255+ else
256+ ArgEmb += Vocab[*Op];
246257 }
247258 // If the operand is not defined by an instruction, we use the vocabulary
248259 else {
You can’t perform that action at this time.
0 commit comments