From 479fb29d4cd2fb458ad3e2f57139b348fd1aebc5 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Sat, 21 May 2016 12:33:21 +0600 Subject: [PATCH] Adds meta information to control graph 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 --- include/analysis.h | 9 +++++++++ src/ControlGraph.cpp | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/include/analysis.h b/include/analysis.h index 5448652..b9b6ede 100644 --- a/include/analysis.h +++ b/include/analysis.h @@ -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; @@ -471,6 +478,8 @@ class ControlGraph { typedef std::map TDomainMap; TDomainMap m_blocksToDomains; + + TMetaInfo m_metaInfo; }; template<> InstructionNode* ControlNode::cast(); diff --git a/src/ControlGraph.cpp b/src/ControlGraph.cpp index 6b7e5d8..4d83657 100644 --- a/src/ControlGraph.cpp +++ b/src/ControlGraph.cpp @@ -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) @@ -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