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

Kiran Chandramohan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 3 02:46:20 PDT 2022


kiranchandramohan added inline comments.


================
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;
----------------
awarzynski wrote:
> 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).
>  but I feel that the API should be independent of the internals of the driver

That is a good goal for plugins. But at the same time the advantage of running flang-omp-report as a plugin is the fact that we can run it on large projects. Most drivers default to using the file name as the default. Why can't we ask the driver to provide the output stream just like you did for `Parsing`?


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