aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/JSBackend/JSBackend.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-04-08 18:18:36 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-04-08 18:18:36 -0700
commitb5114a24ef4532bc2dcc3bcff2360ca0b6022666 (patch)
treea59d694eb5f3e301ab063a11914022eed8e5ab84 /lib/Target/JSBackend/JSBackend.cpp
parent333cc5e85460953ab159462360f6c7c0209ba70e (diff)
break phi var cycles only between actual phi vars
Diffstat (limited to 'lib/Target/JSBackend/JSBackend.cpp')
-rw-r--r--lib/Target/JSBackend/JSBackend.cpp9
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;
}