aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/JSBackend/JSBackend.cpp
diff options
context:
space:
mode:
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;
}