From b5114a24ef4532bc2dcc3bcff2360ca0b6022666 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 8 Apr 2014 18:18:36 -0700 Subject: break phi var cycles only between actual phi vars --- lib/Target/JSBackend/JSBackend.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Target/JSBackend/JSBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp index 03d07aabe9..4322be3c8c 100644 --- a/lib/Target/JSBackend/JSBackend.cpp +++ b/lib/Target/JSBackend/JSBackend.cpp @@ -554,6 +554,13 @@ std::string JSWriter::getPhiCode(const BasicBlock *From, const BasicBlock *To) { // FIXME this is all quite inefficient, and also done once per incoming to each phi // Find the phis, and generate assignments and dependencies + std::set PhiVars; + for (BasicBlock::const_iterator I = To->begin(), E = To->end(); + I != E; ++I) { + const PHINode* P = dyn_cast(I); + if (!P) break; + PhiVars.insert(getJSName(P)); + } typedef std::map StringMap; StringMap assigns; // variable -> assign statement std::map values; // variable -> Value @@ -575,7 +582,7 @@ std::string JSWriter::getPhiCode(const BasicBlock *From, const BasicBlock *To) { values[name] = V; std::string vname = getValueAsStr(V); if (const Instruction *VI = dyn_cast(V)) { - if (VI->getParent() == To) { + if (VI->getParent() == To && PhiVars.find(vname) != PhiVars.end()) { deps[name] = vname; undeps[vname] = name; } -- cgit v1.2.3-18-g5258