Commit 4f03c2d0 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Add a bunch more kill flags

and switch the llvm tier to use them instead of its own analysis
parent 85da6551
......@@ -52,28 +52,17 @@ private:
}
};
llvm::DenseSet<AST_Name*> kills;
llvm::DenseMap<InternedString, AST_Name*> last_uses;
llvm::DenseMap<InternedString, Status> statuses;
LivenessAnalysis* analysis;
void _doLoad(InternedString name, AST_Name* node) {
Status& status = statuses[name];
status.addUsage(Status::USED);
last_uses[name] = node;
}
void _doStore(InternedString name) {
Status& status = statuses[name];
status.addUsage(Status::DEFINED);
auto it = last_uses.find(name);
if (it != last_uses.end()) {
kills.insert(it->second);
last_uses.erase(it);
}
}
Status::Usage getStatusFirst(InternedString name) const {
......@@ -90,22 +79,7 @@ public:
bool firstIsDef(InternedString name) const { return getStatusFirst(name) == Status::DEFINED; }
bool isKilledAt(AST_Name* node, bool is_live_at_end) const {
if (kills.count(node))
return true;
// If it's not live at the end, then the last use is a kill
// even though we weren't able to determine that in a single
// pass
if (!is_live_at_end) {
auto it = last_uses.find(node->id);
if (it != last_uses.end() && node == it->second)
return true;
}
return false;
}
bool isKilledAt(AST_Name* node, bool is_live_at_end) { return node->is_kill; }
bool visit_classdef(AST_ClassDef* node) {
......
......@@ -1691,7 +1691,6 @@ Value ASTInterpreter::visit_name(AST_Name* node) {
bool is_live = true;
if (node->is_kill) {
is_live = false;
assert(!source_info->getLiveness()->isLiveAtEnd(node->id, current_block));
} else if (node->lookup_type == ScopeInfo::VarScopeType::FAST)
is_live = source_info->getLiveness()->isLiveAtEnd(node->id, current_block);
......
This diff is collapsed.
......@@ -120,6 +120,7 @@ public:
class SourceInfo;
CFG* computeCFG(SourceInfo* source, std::vector<AST_stmt*> body);
void printCFG(CFG* cfg);
}
#endif
# expected: fail
# - we have an extra evaluation of __nonzero__ at the end
class A(object):
def __init__(self, n):
print "init", n
self.n = n
def __lt__(self, rhs):
print "lt", self.n, rhs.n
return self
def __nonzero__(self):
print "nonzero", self.n
return True
def __repr__(self):
return "<A (%d)>" % self.n
print A(1) < A(2) < A(3)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment