Skip to content

Commit

Permalink
Fix getRegisterId called on unused PHI instruction
Browse files Browse the repository at this point in the history
Do not use "use-less" PHI instructions as the result of CFG tokens. This
results in a crash because the registerize pass does not assign
registers to instructions with 0 users, so the `getRegisterId` lookup
for the PHI instruction would fail.
  • Loading branch information
DutChen18 committed Jun 18, 2024
1 parent 3657544 commit 3566acf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/CheerpWriter/CheerpWasmWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4339,6 +4339,8 @@ std::map<const llvm::BasicBlock*, const llvm::PHINode*> CheerpWasmWriter::select
std::pair<int, const llvm::PHINode*> best{0, nullptr};
for (const PHINode& phi : BB->phis())
{
if (phi.use_empty())
continue;
std::pair<int, const llvm::PHINode*> curr{gainOfHandlingPhiOnTheEdge(&phi), &phi};
if (curr > best)
best = curr;
Expand Down

0 comments on commit 3566acf

Please sign in to comment.