-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module analysis #100
Module analysis #100
Conversation
80447c1
to
ad2eabf
Compare
ad2eabf
to
3c1494f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to support analyzing a known-to-be-complete program, composed of linked modules (but that can of course come later).
Can you remind me what is_leaf
is useful for? It seems that any function that's known to not be involved in a recursive loop can have a stable frame region; is there something special we can do with leaf functions that I'm forgetting? Two separate leaves could have overlapping stable regions, but that's a special case of disjoint branches.
SCC: [`%f6`] | ||
SCC: [`%f7`] | ||
|
||
`%fx` = FuncInfo { is_non_recursive: false, flow: OutgoingOnly, is_leaf: true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The FuncInfo for externally-defined %fx
is weird; local functions call it, so its flow is known to be Incoming, and we should assume that it may be Bidirectional. We also can't say that it's a leaf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is bad. I initially thought that we should remove the external function from the result, but also hesitated to do that because it breaks the consistency between the result and FuncStore
or other modules, which always manage the mapping from each FuncRef
to some information.
I'm inclined to remove the external function info from the ModuleInfo
now because the information won't be used anywhere(and actually, if it's used, it just gives wrong information or the most conservative information). What's your thought?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think it's fine to remove it and for the backend to assume the most conservative for calls to mysterious external functions.
What is additional analysis in your mind when the entire program is provided? I assumed that by using
It depends on the backend. It won't be so useful for EVM codegen(but, we might need the information in addition to the |
Just more comprehensive information; no need to be overly conservative when calling external functions, for example. In practice, fe or solc can just generate the whole program in a single sonatina module and this 'multi-module whole-program analysis' isn't needed for now. |
I see. I probably understand what you mean. So, you mean that it'd be nicer if the analysis phase could take an arbitrary number of |
e8a5ba6
to
8dc5498
Compare
Please start reviewing after #96 is merged.
NOTE: A.I. generates the comment below, but I'm not entirely sure if this comment is helpful or not.
Pull Request: Module Analysis Framework Enhancement
Summary
This PR introduces a framework for analyzing the structure and properties of a
Module
in the Sonatina IR. The additions provide functionality to assess the module's dependency flow, call graph, and strongly connected components (SCCs), enabling insights into the recursive and external dependencies of functions.Key Features
1. Module Analysis Framework
Module Analysis API:
analyze_module
function to perform analysis of a module, returning aModuleInfo
object.ModuleInfo
encapsulates:CallGraphSccs
).CallGraph
).FuncInfo
).DependencyFlow
).DependencyFlow
Enumeration:OutgoingOnly
,IncomingOnly
,Bidirectional
, andClosed
.join
operation for combining dependency states and aremove_flow
function for refining flow states.2. Call Graph Analysis
Call Graph Construction:
CallGraph
.SCC Analysis:
SccBuilder
to identify SCCs in the call graph.3. Function Information
4.
DependencyFlow
analysisDependencyFlow
of the module.