Skip to content

Commit

Permalink
Adds meta information to control graph
Browse files Browse the repository at this point in the history
Meta info is very useful during type analysis.
It helps to make decisions based on graph structure.

In future, more flags will be added.

Issue: #17
  • Loading branch information
0x7CFE committed May 21, 2016
1 parent 385f6e0 commit 479fb29
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,13 @@ class ControlGraph {
return iDomain->second;
}

struct TMetaInfo {
bool hasLoops;
bool hasBackEdgeTau;
};

TMetaInfo& getMeta() { return m_metaInfo; }

private:
ParsedMethod* m_parsedMethod;
ParsedBlock* m_parsedBlock;
Expand All @@ -471,6 +478,8 @@ class ControlGraph {

typedef std::map<BasicBlock*, ControlDomain*> TDomainMap;
TDomainMap m_blocksToDomains;

TMetaInfo m_metaInfo;
};

template<> InstructionNode* ControlNode::cast<InstructionNode>();
Expand Down
5 changes: 5 additions & 0 deletions src/ControlGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,8 @@ class TauLinker : private BackEdgeDetector {
}
}

getGraph().getMeta().hasLoops = !getBackEdges().empty();

// When all nodes visited, process the pending list
TInstructionSet::iterator iNode = m_pendingNodes.begin();
for (; iNode != m_pendingNodes.end(); ++iNode)
Expand Down Expand Up @@ -923,6 +925,9 @@ class TauLinker : private BackEdgeDetector {
TauNode* const assignType = assignTemporary->getTauNode();
assert(inheritedType);

if ((*iAssignSite).byBackEdge)
getGraph().getMeta().hasBackEdgeTau = true;

if (! instruction.getTauNode()) {
// FIXME Could it be that the only incoming is accessible by back edge?
// Possbible scenario: push default nil, assigned later, branch up
Expand Down

0 comments on commit 479fb29

Please sign in to comment.