[PATCH] D120999: [flang] Update the plugin API

Andrzej Warzynski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 1 08:59:32 PDT 2022


awarzynski added inline comments.


================
Comment at: flang/examples/FlangOmpReport/FlangOmpReport.cpp:56
     OpenMPCounterVisitor visitor;
     visitor.parsing = &parsing;
 
----------------
Leporacanthicus wrote:
> Just out of curiosity, why is the parsing not a constructor argument?
Of `PluginParseTreeAction`? Parsing is not available until [[ https://github.com/llvm/llvm-project/blob/main/flang/include/flang/Frontend/FrontendAction.h#L46 | BeginSourceFileAction ]] is run. That's after this object is constructed. 


================
Comment at: flang/examples/FlangOmpReport/FlangOmpReport.cpp:61
 
-    // Dump the output
-    std::unique_ptr<llvm::raw_pwrite_stream> OS{ci.CreateDefaultOutputFile(
-        /*Binary=*/true, /*InFile=*/GetCurrentFileOrBufferName(),
-        /*Extension=*/".yaml")};
-    llvm::yaml::Output yout(*OS);
+    llvm::yaml::Output yout(llvm::outs());
     yout << visitor.constructClauses;
----------------
kiranchandramohan wrote:
> I was thinking that `flang-omp-report` will run on all the source files and generate a lot of YAML files whose name is derived from the name of the source file. Then the summary python script collects a summary from all these info.
> 
> This code looks like it dumps everything to output, wouldn't it affect the running of the summarize python script?
>I was thinking that flang-omp-report will run on all the source files and generate a lot of YAML files whose name is derived from the name of the source file. 

Not quite. You will have to run the plugin manually for every file. But you can automate this by "hacking" a Makefile of the project that you are interested in. Currently, you will need these extra flags:

```lang=Makefile
  FFLAGS=-fsyntax-only -I /.../llvm-project/flang/module -Xflang -load -Xflang /.../llvm-project/build/Release/lib/flangOmpReport.so -Xflang -plugin -Xflang flang-omp-report -fopenmp
```
With this change, you will also have to pipe the output to a file (so that it does not end up in stdout):
```lang=Makefile
  FFLAGS=-fsyntax-only -I /.../llvm-project/flang/module -Xflang -load -Xflang /.../llvm-project/build/Release/lib/flangOmpReport.so -Xflang -plugin -Xflang flang-omp-report -fopenmp -o output.yaml
```

This does make using the plugin on larger projects a bit more tricky, but I feel that the API should be independent of the internals of the driver. In particular, the driver depends on various TableGen files from Clang that define diagnostics. So, in general, so does this plugin because it includes "CompilerInstance.h" from the driver. I'm trying to remove this dependency.

As for the script, it's independent of the plugin and all it needs are some *.yaml files (i.e. it does not care how you generate them).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120999/new/

https://reviews.llvm.org/D120999



More information about the llvm-commits mailing list