tudasc / MetaCG

MetaCG offers an annotated whole program call-graph tool for Clang/LLVM.
BSD 3-Clause "New" or "Revised" License
32 stars 4 forks source link

CGCollector does not terminate when applied to OpenFOAM #1

Open sebastiankreutzer opened 2 years ago

sebastiankreutzer commented 2 years ago

I'm trying to run cgcollector on source code from OpenFOAM. After having tried multiple different source files, it seems that cgcollector does not terminate on any of them (I've tried letting in run for up to three hours). I am running cgcollector directly without the wrapper script, setting the necessary system includes (and a few other parameters) manually.

The command looks as follows: tools/cgcollector /opt/OpenFOAM-v2106/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C -- -DWM_LABEL_SIZE=64 -DWM_DP -I/opt/modules/packages/llvm/11.1.0/lib/clang/11.1.0/include -I/opt/OpenFOAM-v2106/src/OpenFOAM/lnInclude -I/opt/OpenFOAM-v2106/src/OSspecific/POSIX/lnInclude

I observe the following behavior:

I should note that I've tried out MetaCG on some other test codes with no issues.

I have attached a log file of the full output after running for a few minutes: cgc_octree.log

sebastiankreutzer commented 2 years ago

My workaround for now is to comment out everything in CGBuilder::handleFunctionPointerInArguments.

jplehr commented 2 years ago

Hi @sebastiankreutzer thank you for the report.

This is unfortunate, and we are aware of the issues in the current implementation. Increasing the runtime limit may resolve the issue, but without guarantee. We saw similar behavior in another C++ code from the SPEC CPU benchmark suite that eventually terminated after 12 hours or so.

We are working on this issue, and hopefully it will be addressed in the not so distant future. ;)

In the meantime, you should certainly apply CGValidate with a Score-P profile to validate the CG, and potentially patch-in missing edges. You can also try out Phasar for its LLVM-based CG generation. Although I don't know whether this is possible in your particular case.

sebastiankreutzer commented 2 years ago

Thanks for the suggestions, I will try out CGValidate. As I understand it, the current issue only concerns the tracking of calls through function pointers. Leaving those out hopefully won't have a dramatic impact on the quality of the CG.

Regarding Phasar: If I'm not mistaken, they rely on merging on all LLVM-IR modules into one. Considering the size of our target application, this might be impractical. I'll keep it in mind in case the current approach does not work out.