diff --git a/llvm/lib/CheerpWriter/CheerpWasmWriter.cpp b/llvm/lib/CheerpWriter/CheerpWasmWriter.cpp index 5b5e112fbcd2..5b0eed7d983c 100644 --- a/llvm/lib/CheerpWriter/CheerpWasmWriter.cpp +++ b/llvm/lib/CheerpWriter/CheerpWasmWriter.cpp @@ -4339,6 +4339,8 @@ std::map CheerpWasmWriter::select std::pair best{0, nullptr}; for (const PHINode& phi : BB->phis()) { + if (phi.use_empty()) + continue; std::pair curr{gainOfHandlingPhiOnTheEdge(&phi), &phi}; if (curr > best) best = curr;