Skip to content

Adding Fortran call graph collector#115

Open
gomfol12 wants to merge 119 commits intotudasc:develfrom
gomfol12:fortran_collector
Open

Adding Fortran call graph collector#115
gomfol12 wants to merge 119 commits intotudasc:develfrom
gomfol12:fortran_collector

Conversation

@gomfol12
Copy link
Contributor

@gomfol12 gomfol12 commented Feb 5, 2026

This adds a call graph collector for Fortran. The collector is implemented as a flang plugin and generates a call graph from source-level. See the tests for a list of language features this plugin covers.

This pull request is quite large, but it is not really possible splitting it in multiply requests without pushing broken code. The tests could be separate into a different pull request, but they are tightly coupled with the collector and would fail without it, so I think keeping it in one pull request makes sense.

What this adds:

  • new directory cgfcollector that includes flang plugin, tests, tools, etc.
  • flang plugin that generates call graph in metacg format.
  • two wrapper script cgfcollector_wrapper.sh and cgfcollector_comp_wrapper.sh that simplify running the plugin.
  • cgCompare tool: for comparing two call graphs (can be replaced with cgdiff)
  • another test runner

How to run: see cgfcollector/README.md

The commit history is a mess, and I don't know how strongly you value a clean git history and if I should clean this up.

Copy link
Member

@pearzt pearzt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for all the work, the structure looks really good. I have some initial comments, but I will try to do a more in-depth review soon.

NO_DEFAULT_PATH
)

# target_link_libraries(${target} PUBLIC flangFrontendTool)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be commented out?

The plugin is compiled into a dynamic library and can be run with the
Flang compiler like so:

`flang -fc1 -load "build/cgfcollector/libfcollector.so" -plugin "genCG"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The collector should be installed (add install rules, if necessary), so that users don't need to use the library from the build directory/

add_flang(${PROJECT_NAME})
add_metacg(${PROJECT_NAME})
add_spdlog_libraries(${PROJECT_NAME})
# add_json(${PROJECT_NAME})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover?

return equal;
}

int main(int argc, char* argv[]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a look at CGDiff and see you can use it instead of this tool or what would be necessary to merge the tools. I would like to avoid having both tools in MetaCG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants