diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-04-08 18:18:36 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-04-08 18:18:36 -0700 |
commit | b5114a24ef4532bc2dcc3bcff2360ca0b6022666 (patch) | |
tree | a59d694eb5f3e301ab063a11914022eed8e5ab84 | |
parent | 333cc5e85460953ab159462360f6c7c0209ba70e (diff) |
break phi var cycles only between actual phi vars
-rw-r--r-- | lib/Target/JSBackend/JSBackend.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
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<std::string> PhiVars; + for (BasicBlock::const_iterator I = To->begin(), E = To->end(); + I != E; ++I) { + const PHINode* P = dyn_cast<PHINode>(I); + if (!P) break; + PhiVars.insert(getJSName(P)); + } typedef std::map<std::string, std::string> StringMap; StringMap assigns; // variable -> assign statement std::map<std::string, const Value*> 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<const Instruction>(V)) { - if (VI->getParent() == To) { + if (VI->getParent() == To && PhiVars.find(vname) != PhiVars.end()) { deps[name] = vname; undeps[vname] = name; } |