[flang] Add -fpass-plugin option to flang
authorTarun Prabhu <tarun@lanl.gov>
Thu, 10 Nov 2022 14:56:03 +0000 (07:56 -0700)
committerTarun Prabhu <tarun@lanl.gov>
Thu, 10 Nov 2022 15:03:46 +0000 (08:03 -0700)
commitc3821b8d2aacd1d7c0281db1b8db011e1158cf4d
tree8827d248ee8888d44d9217354a35286c2d9d449c
parentf3e8a117d2bc8d439434db5cb77b1c8a425a38c0
[flang] Add -fpass-plugin option to flang

This patch adds the -fpass-plugin option to flang which dynamically loads LLVM
passes from the shared object passed as the argument to the flag. The behavior
of the option is designed to replicate that of the same option in clang and
thus has the same capabilities and limitations.

Features:

  Multiple instances of -fpass-plugin=path-to-file can be specified and each
  of the files will be loaded in that order.

  The flag can be passed to both flang-new and flang-new -fc1.

  The flag will be listed when the -help flag is passed to both flang-new and
  flang-new -fc1. It will also be listed when the --help-hidden flag is passed.

Limitations:

  Dynamically loaded plugins are not supported in clang on Windows and are not
  supported in flang either.

Addenda:

  Some minor stylistic changes are made in the files that were modified to
  enable this functionality. Those changes make the naming of functions more
  consistent, but do not change any functionality that is not directly
  related to enabling -fpass-plugin.

Differential Revision: https://reviews.llvm.org/D129156
14 files changed:
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
clang/lib/Driver/ToolChains/Flang.h
flang/docs/FlangDriver.md
flang/docs/ReleaseNotes.md
flang/include/flang/Frontend/CodeGenOptions.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/test/CMakeLists.txt
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90
flang/test/Driver/frontend-forwarding.f90
flang/test/Driver/pass-plugin-not-found.f90 [new file with mode: 0644]
flang/test/Driver/pass-plugin.f90 [new file with mode: 0644]