[PATCH] D129156: Add -fpass-plugin option to Flang

2022-11-24 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D129156#3949194 , @awarzynski 
wrote:

> 



> Sorry that you are hitting this - things like this happen, sadly. I think 
> that the easiest to resolve it would be to tweak the expected error so that 
> it works on Solaris as well as other popular platforms. Given that you might 
> be the only person able to test on Solaris, would you be able to upload 
> something for  a review? Thanks!

No worries, especially given that this seems to be the first test ever to check 
the `Could not load library` error message.

I've just submitted a patch that works on Linux and Solaris (all that I can 
easily test): D138663 .


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-11-24 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D129156#3949156 , @ro wrote:

> This introduced a new failure on Solaris:
>
>   FAIL: Flang :: Driver/pass-plugin-not-found.f90
>
> Running the failing command manually shows:
>
>   error: unable to load plugin 'X.Y': 'Could not load library 'X.Y': ld.so.1: 
> flang-new: X.Y: open failed: No such file or directory'
>
> while the test currently expects
>
>   error: unable to load plugin 'X.Y': 'Could not load library 'X.Y': X.Y: 
> cannot open shared object file: No such file or directory'
>
> This expectation is unjustified, I believe: the message is produced by 
> `PassPlugin::Load` -> `sys::DynamicLibrary::getPermanentLibrary` -> 
> `HandleSet::DLOpen` -> `::dlerror`.  Obviously the output of the last is 
> system-dependent; I don't think we can put any requirements on it (maybe not 
> even the exact wording of the `No such file or directory` part.

Sorry that you are hitting this - things like this happen, sadly. I think that 
the easiest to resolve it would be to tweak the expected error so that it works 
on Solaris as well as other popular platforms. Given that you might be the only 
person able to test on Solaris, would you be able to upload something for  a 
review? Thanks!


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-11-24 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

This introduced a new failure on Solaris:

  FAIL: Flang :: Driver/pass-plugin-not-found.f90

Running the failing command manually shows:

  error: unable to load plugin 'X.Y': 'Could not load library 'X.Y': ld.so.1: 
flang-new: X.Y: open failed: No such file or directory'

while the test currently expects

  error: unable to load plugin 'X.Y': 'Could not load library 'X.Y': X.Y: 
cannot open shared object file: No such file or directory'

This expectation is unjustified, I believe: the message is produced by 
`PassPlugin::Load` -> `sys::DynamicLibrary::getPermanentLibrary` -> 
`HandleSet::DLOpen` -> `::dlerror`.  Obviously the output of the last is 
system-dependent; I don't think we can put any requirements on it (maybe not 
even the exact wording of the `No such file or directory` part.


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-11-10 Thread Tarun Prabhu via Phabricator via cfe-commits
tarunprabhu marked 2 inline comments as done.
tarunprabhu added a comment.

Yes, I am aware of the other patch which also adds 
`test/Driver/pass-plugin.f90`. I will keep an eye out for it.




Comment at: flang/test/CMakeLists.txt:65
 )
+if (NOT WIN32)
+  list(APPEND FLANG_TEST_DEPENDS Bye)

awarzynski wrote:
> awarzynski wrote:
> > IIUC, `Bye` is only needed when plugins are enabled.
> IIUC, `WIN32` is still required. Sorry for not being clearer earlier.
Ugh! Yes, of course. I looked at `llvm/CMakeLists.txt` and somehow concluded 
that `LLVM_ENABLE_PLUGINS` is disabled if WIN32, but it is in fact the _default 
value_ of `LLVM_ENABLE_PLUGINS` that is set to `false` in that case. 


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-11-10 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Please be aware of https://reviews.llvm.org/D137673 - you may need to rebase if 
it lands before this patch.

Please just go ahead and merge, but please keep `WIN32` in the final version of 
"flang/test/CMakeLists.txt" (see my comment inline).

LGTM




Comment at: flang/test/CMakeLists.txt:65
 )
+if (NOT WIN32)
+  list(APPEND FLANG_TEST_DEPENDS Bye)

awarzynski wrote:
> IIUC, `Bye` is only needed when plugins are enabled.
IIUC, `WIN32` is still required. Sorry for not being clearer earlier.


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-11-09 Thread Tarun Prabhu via Phabricator via cfe-commits
tarunprabhu updated this revision to Diff 474382.
tarunprabhu added a comment.

Previous revision was missing the tests.

Only add a dependence to the Bye plugin when plugins are enabled.


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

https://reviews.llvm.org/D129156

Files:
  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
  flang/test/Driver/pass-plugin.f90

Index: flang/test/Driver/pass-plugin.f90
===
--- /dev/null
+++ flang/test/Driver/pass-plugin.f90
@@ -0,0 +1,13 @@
+! Verify that the plugin passed to -fpass-plugin is loaded and run
+
+! UNSUPPORTED: system-windows
+
+! REQUIRES: plugins, shell
+
+! RUN: %flang -S %s -fpass-plugin=%llvmshlibdir/Bye%pluginext -Xflang -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -S %s -fpass-plugin=%llvmshlibdir/Bye%pluginext -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s
+
+! CHECK: Running pass: {{.*}}Bye on empty_
+
+subroutine empty
+end subroutine empty
Index: flang/test/Driver/pass-plugin-not-found.f90
===
--- /dev/null
+++ flang/test/Driver/pass-plugin-not-found.f90
@@ -0,0 +1,8 @@
+! Check the correct error diagnostic is reported when a pass plugin shared object isn't found
+
+! REQUIRES: plugins, shell
+
+! RUN: not %flang -fpass-plugin=X.Y %s 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: not %flang_fc1 -emit-llvm -o /dev/null -fpass-plugin=X.Y %s 2>&1 | FileCheck %s --check-prefix=ERROR
+
+! ERROR: error: unable to load plugin 'X.Y': 'Could not load library 'X.Y': X.Y: cannot open shared object file: No such file or directory'
Index: flang/test/Driver/frontend-forwarding.f90
===
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -15,6 +15,7 @@
 ! RUN: -fno-signed-zeros \
 ! RUN: -fassociative-math \
 ! RUN: -freciprocal-math \
+! RUN: -fpass-plugin=Bye%pluginext \
 ! RUN: -mllvm -print-before-all\
 ! RUN: -P \
 ! RUN:   | FileCheck %s
@@ -33,4 +34,5 @@
 ! CHECK: "-mreassociate"
 ! CHECK: "-freciprocal-math"
 ! CHECK: "-fconvert=little-endian"
-! CHECK:  "-mllvm" "-print-before-all"
+! CHECK: "-fpass-plugin=Bye
+! CHECK: "-mllvm" "-print-before-all"
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -46,6 +46,7 @@
 ! HELP-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
@@ -129,6 +130,7 @@
 ! HELP-FC1-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! HELP-FC1-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-FC1-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! HELP-FC1-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -48,6 +48,7 @@
 ! CHECK-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
 ! CHECK-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! CHECK-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! CHECK-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! CHECK-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic a

[PATCH] D129156: Add -fpass-plugin option to Flang

2022-11-09 Thread Tarun Prabhu via Phabricator via cfe-commits
tarunprabhu updated this revision to Diff 474381.
tarunprabhu added a comment.

Only add a dependence to the Bye plugin when plugins are enabled.


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

https://reviews.llvm.org/D129156

Files:
  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

Index: flang/test/Driver/frontend-forwarding.f90
===
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -15,6 +15,7 @@
 ! RUN: -fno-signed-zeros \
 ! RUN: -fassociative-math \
 ! RUN: -freciprocal-math \
+! RUN: -fpass-plugin=Bye%pluginext \
 ! RUN: -mllvm -print-before-all\
 ! RUN: -P \
 ! RUN:   | FileCheck %s
@@ -33,4 +34,5 @@
 ! CHECK: "-mreassociate"
 ! CHECK: "-freciprocal-math"
 ! CHECK: "-fconvert=little-endian"
-! CHECK:  "-mllvm" "-print-before-all"
+! CHECK: "-fpass-plugin=Bye
+! CHECK: "-mllvm" "-print-before-all"
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -46,6 +46,7 @@
 ! HELP-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
@@ -129,6 +130,7 @@
 ! HELP-FC1-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! HELP-FC1-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-FC1-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! HELP-FC1-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -48,6 +48,7 @@
 ! CHECK-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
 ! CHECK-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! CHECK-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! CHECK-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! CHECK-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
@@ -76,4 +77,3 @@
 
 ! Frontend driver -help-hidden is not supported
 ! ERROR-FLANG-FC1: error: unknown argument: '{{.*}}'
-
Index: flang/test/CMakeLists.txt
===
--- flang/test/CMakeLists.txt
+++ flang/test/CMakeLists.txt
@@ -63,6 +63,9 @@
   Fortran_main
   FortranDecimal
 )
+if (LLVM_ENABLE_PLUGINS)
+  list(APPEND FLANG_TEST_DEPENDS Bye)
+endif()
 
 if (FLANG_INCLUDE_TESTS)
   if (FLANG_GTEST_AVAIL)
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -48,6 +48,7 @@
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Passes/PassBuilder.h"
+#include "llvm/Passes/PassPlugin.h"
 #include "llvm/Passes/StandardInstrumentations.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/SourceMgr.h"
@@ -675,6 +676,7 @@
 
 void CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream &os) {
   auto opts = getInstance().getInvocation().getCodeGenOpts();
+  auto &diags = getInstance().getDiagnostics();
   llvm::OptimizationLevel level = mapToLevel(opts);
 
   // Create the analysis managers.
@@ -691,6 +693,17 @@
   si.registerCallbacks(pic, &fam);
   llvm::PassB

[PATCH] D129156: Add -fpass-plugin option to Flang

2022-11-04 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: flang/test/CMakeLists.txt:65
 )
+if (NOT WIN32)
+  list(APPEND FLANG_TEST_DEPENDS Bye)

IIUC, `Bye` is only needed when plugins are enabled.


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-31 Thread Tarun Prabhu via Phabricator via cfe-commits
tarunprabhu updated this revision to Diff 472161.
tarunprabhu added a comment.

Added a dependence for the flang tests on LLVM's Bye plugin. This results in 
the Bye plugin being built when check-flang is run, even if building examples 
has been explicitly disabled.

Removed the dependency on 'examples' in the pass-plugin.f90 test.

Some minor changes to function names for better consistency.


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

https://reviews.llvm.org/D129156

Files:
  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
  flang/test/Driver/pass-plugin.f90

Index: flang/test/Driver/pass-plugin.f90
===
--- /dev/null
+++ flang/test/Driver/pass-plugin.f90
@@ -0,0 +1,13 @@
+! Verify that the plugin passed to -fpass-plugin is loaded and run
+
+! UNSUPPORTED: system-windows
+
+! REQUIRES: plugins, shell
+
+! RUN: %flang -S %s -fpass-plugin=%llvmshlibdir/Bye%pluginext -Xflang -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -S %s -fpass-plugin=%llvmshlibdir/Bye%pluginext -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s
+
+! CHECK: Running pass: {{.*}}Bye on empty_
+
+subroutine empty
+end subroutine empty
Index: flang/test/Driver/pass-plugin-not-found.f90
===
--- /dev/null
+++ flang/test/Driver/pass-plugin-not-found.f90
@@ -0,0 +1,8 @@
+! Check the correct error diagnostic is reported when a pass plugin shared object isn't found
+
+! REQUIRES: plugins, shell
+
+! RUN: not %flang -fpass-plugin=X.Y %s 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: not %flang_fc1 -emit-llvm -o /dev/null -fpass-plugin=X.Y %s 2>&1 | FileCheck %s --check-prefix=ERROR
+
+! ERROR: error: unable to load plugin 'X.Y': 'Could not load library 'X.Y': X.Y: cannot open shared object file: No such file or directory'
Index: flang/test/Driver/frontend-forwarding.f90
===
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -9,6 +9,7 @@
 ! RUN: -flarge-sizes \
 ! RUN: -fconvert=little-endian \
 ! RUN: -ffp-contract=fast \
+! RUN: -fpass-plugin=Bye%pluginext \
 ! RUN: -mllvm -print-before-all\
 ! RUN: -P \
 ! RUN:   | FileCheck %s
@@ -21,4 +22,5 @@
 ! CHECK: "-flarge-sizes"
 ! CHECK: "-ffp-contract=fast"
 ! CHECK: "-fconvert=little-endian"
-! CHECK:  "-mllvm" "-print-before-all"
+! CHECK: "-fpass-plugin=Bye
+! CHECK: "-mllvm" "-print-before-all"
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -44,6 +44,7 @@
 ! HELP-NEXT: -fno-integrated-as  Disable the integrated assembler
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: -help  Display available options
@@ -124,6 +125,7 @@
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E mode
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! HELP-FC1-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-FC1-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-FC1-NEXT: -help  Display available options
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -46,6 +46,7 @@
 ! CHECK-NEXT: -fno-integrated-as Disable the integrated assembler
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
 ! CHECK-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! CHECK-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! CHECK-NEXT: -fsyntax-only  Run the preprocessor, parser and semant

[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-12 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D129156#3853045 , @tarunprabhu 
wrote:

> The tests still passed.

No, it wasn't run. We need to understand why before proceeding.


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-12 Thread Tarun Prabhu via Phabricator via cfe-commits
tarunprabhu added a comment.

In D129156#3851843 , @awarzynski 
wrote:

> @tarunprabhu Could you confirm that with the build command above 
> "pass-plugin.f90" is failing for you? It is for me.

The tests still passed. Some relevant output from the test is below (I added 
the `-DLLVM_LIT_ARGS="-v"` to the configure line).

  UNSUPPORTED: Flang :: Driver/pass-plugin.f90 (1721 of 1809)
  PASS: Flang :: Driver/pass-plugin-not-found.f90 (560 of 1809)
  
  Testing Time: 4.81s
Unsupported  :   11
Passed   : 1780
Expectedly Failed:   18

I am not sure what I am doing differently. This is starting from an empty build 
directory.


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-12 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D129156#3852553 , @tarunprabhu 
wrote:

> In D129156#3851843 , @awarzynski 
> wrote:
>
>> @tarunprabhu Could you confirm that with the build command above 
>> "pass-plugin.f90" is failing for you? It is for me.
>
> @awarzynski What compiler do you use to build this? gcc doesn't seem to like 
> `-gmlt`, clang-12 complains about `-fuse-ld=lld` (could be the clang 
> installation on the machine on which I am building), and clang-13 causes a 
> compile error.
>
> [EDIT: Tag @awarzynski]

I doubt those particular flags matter here. You can trim that CMake command as 
follows:

  cmake ../llvm -D LLVM_ENABLE_PROJECTS="mlir;flang;clang;llvm" -G Ninja -D 
CMAKE_BUILD_TYPE=Release -D LLVM_ENABLE_ASSERTIONS=ON -D LLVM_BUILD_EXAMPLES=ON 
  ninja check-flang


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-12 Thread Tarun Prabhu via Phabricator via cfe-commits
tarunprabhu added a comment.

In D129156#3851843 , @awarzynski 
wrote:

> @tarunprabhu Could you confirm that with the build command above 
> "pass-plugin.f90" is failing for you? It is for me.

What compiler do you use to build this? gcc doesn't seem to like `-gmlt`, 
clang-12 complains about `-fuse-ld=lld` (could be the clang installation on the 
machine on which I am building), and clang-13 causes a compile error.


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-12 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

@tarunprabhu Could you confirm that with the build command above 
"pass-plugin.f90" is failing for you? It is for me.

In order to fix that, you will have to add this 

 in Flang's test/CMakeLists.txt 
.
 After the change, `libBye.so` will be added as a dependency to Flang tests, 
but only when `FLANG_BUILD_EXAMPLES` is set. I would also add a note in 
"pass-plugin.f90" that it depends on the "Bye" pass from LLVM.


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-11 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In @clementval 's CMake invocation `LLVM_BUILD_EXAMPLES` is not set, which 
means that the examples (e.g. the `Bye` plugin) are not built. Adding  `! 
REQUIRES: examples` to the test should fix the failure in this case. I did 
verify locally.

However, the pre-commit CI that was failing did include the examples:

  cmake ../llvm -D LLVM_ENABLE_PROJECTS="mlir;flang;clang;llvm" -G Ninja -D 
CMAKE_BUILD_TYPE=Release -D LLVM_ENABLE_ASSERTIONS=ON -D LLVM_BUILD_EXAMPLES=ON 
-D LLVM_LIT_ARGS="-v --xunit-xml-output test-results.xml" -D LLVM_ENABLE_LLD=ON 
-D CMAKE_CXX_FLAGS=-gmlt -DBOLT_CLANG_EXE=/usr/bin/clang

You can see there 
 that 
`libBye.so` is not built. Could you try that command, pls?

In D129156#3849487 , @tarunprabhu 
wrote:

> I imagine that we want the feature to be tested even when building flang 
> out-of-tree.

I don't built standalone LLVM Flang, so won't be needing it. Perhaps somebody 
else will, dunno :)


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-11 Thread Tarun Prabhu via Phabricator via cfe-commits
tarunprabhu added a comment.

In D129156#3848728 , @awarzynski 
wrote:

> Thanks Valentin! Switching between generators will definitely change the 
> order in which libraries will built (and, AFAIK, the order is 
> non-deterministic to begin with). I will try to experiment later today.

I ran this with Unix Makefiles as the generator and it passes there too.

What I did notice when I tried the out-of-tree build of flang is that the test 
did not run. The message I got was that the test was "unsupported".

I assume that is because there is no dependence on LLVM examples in an 
out-of-tree build. Would adding an explicit dependence on LLVM's examples cause 
the test to run? I imagine that we want the feature to be tested even when 
building flang out-of-tree.


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-11 Thread Mats Petersson via Phabricator via cfe-commits
Leporacanthicus added a comment.

> @MatsPetersson & @clementval , could you share you build command so that the 
> failure can be reproduced before this re-lands?

I can't share the same command that I used, because it's some old CMAKE command 
that I no longer have in my history. But I tested this patch, and it works in 
the same tree that I was using it last week.

I just double-checked again in my release-build directory, and it also works. 
So I think the latest version works...


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-11 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D129156#3848704 , @clementval 
wrote:

>>> I still cannot reproduce the build failure on my end. @MatsPetersson tested 
>>> this patch and the tests passed.
>>
>> @MatsPetersson & @clementval , could you share you build command so that the 
>> failure can be reproduced before this re-lands?
>
> I shared it with @tarunprabhu and I think the only major difference is the 
> use of Ninja vs. Unix Makefiles.
>
>   cmake \
> -G "Unix Makefiles" \
> -DCMAKE_BUILD_TYPE=Release \
> -DLLVM_ENABLE_ASSERTIONS=ON \
> -DLLVM_TARGETS_TO_BUILD=host \
> -DLLVM_ENABLE_PROJECTS="clang;mlir;flang" \
> -DLLVM_ENABLE_RUNTIMES="compiler-rt"

Thanks Valentin! Switching between generators will definitely change the order 
in which libraries will built (and, AFAIK, the order is non-deterministic to 
begin with). I will try to experiment later today.

If anyone manages to test this in the meantime, please share here - that's part 
of the public review process :)


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-11 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

In D129156#3848692 , @awarzynski 
wrote:

> In D129156#3847396 , @tarunprabhu 
> wrote:
>
>> Added `examples` to `REQUIRES` in `test/Driver/pass-plugin.f90.
>
> Thanks for the update!
>
>> I still cannot reproduce the build failure on my end. @MatsPetersson tested 
>> this patch and the tests passed.
>
> @MatsPetersson & @clementval , could you share you build command so that the 
> failure can be reproduced before this re-lands?

I shared it with @tarunprabhu and I think the only major difference is the use 
of Ninja vs. Unix Makefiles.

  cmake \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_TARGETS_TO_BUILD=host \
-DLLVM_ENABLE_PROJECTS="clang;mlir;flang" \
-DLLVM_ENABLE_RUNTIMES="compiler-rt"


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-11 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D129156#3847396 , @tarunprabhu 
wrote:

> Added `examples` to `REQUIRES` in `test/Driver/pass-plugin.f90.

Thanks for the update!

> I still cannot reproduce the build failure on my end. @MatsPetersson tested 
> this patch and the tests passed.

@MatsPetersson & @clementval , could you share you build command so that the 
failure can be reproduced before this re-lands?

> Could someone else test this on their build and let me know if it works - 
> especially if the previous version failed for you.

I can try as soon as folks share their build commands. In general, I'm 
concerned that this fix is not enough. It merely makes sure that 
"pass-plugin.f90" is only run when `LLVM_BUILD_EXAMPLES` is set (or whatever 
other flag that sets `examples` in LIT). However, that's not sufficient to make 
sure that `libBye.so` is built when running `ninja check-flang`. I might wrong 
though - have you checked this?


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-10 Thread Tarun Prabhu via Phabricator via cfe-commits
tarunprabhu added a comment.

I tried an out-of-tree flang build. check-flang passes in that case too.


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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-10 Thread Tarun Prabhu via Phabricator via cfe-commits
tarunprabhu updated this revision to Diff 466561.
tarunprabhu added a comment.

Added `examples` to `REQUIRES` in `test/Driver/pass-plugin.f90.

I still cannot reproduce the build failure on my end. @MatsPetersson tested 
this patch and the tests passed. Could someone else test this on their build 
and let me know if it works - especially if the previous version failed for you.


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

https://reviews.llvm.org/D129156

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  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/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
  flang/test/Driver/pass-plugin.f90

Index: flang/test/Driver/pass-plugin.f90
===
--- /dev/null
+++ flang/test/Driver/pass-plugin.f90
@@ -0,0 +1,13 @@
+! Verify that the plugin passed to -fpass-plugin is loaded and run
+
+! UNSUPPORTED: system-windows
+
+! REQUIRES: examples, plugins, shell
+
+! RUN: %flang -S %s -fpass-plugin=%llvmshlibdir/Bye%pluginext -Xflang -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -S %s -fpass-plugin=%llvmshlibdir/Bye%pluginext -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s
+
+! CHECK: Running pass: {{.*}}Bye on empty_
+
+subroutine empty
+end subroutine empty
Index: flang/test/Driver/pass-plugin-not-found.f90
===
--- /dev/null
+++ flang/test/Driver/pass-plugin-not-found.f90
@@ -0,0 +1,8 @@
+! Check the correct error diagnostic is reported when a pass plugin shared object isn't found
+
+! REQUIRES: plugins, shell
+
+! RUN: not %flang -fpass-plugin=X.Y %s 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: not %flang_fc1 -emit-llvm -o /dev/null -fpass-plugin=X.Y %s 2>&1 | FileCheck %s --check-prefix=ERROR
+
+! ERROR: error: unable to load plugin 'X.Y': 'Could not load library 'X.Y': X.Y: cannot open shared object file: No such file or directory'
Index: flang/test/Driver/frontend-forwarding.f90
===
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -7,6 +7,7 @@
 ! RUN: -fdefault-integer-8 \
 ! RUN: -fdefault-real-8 \
 ! RUN: -flarge-sizes \
+! RUN: -fpass-plugin=Bye%pluginext \
 ! RUN: -mllvm -print-before-all\
 ! RUN: -P \
 ! RUN:   | FileCheck %s
@@ -17,4 +18,5 @@
 ! CHECK: "-fdefault-integer-8"
 ! CHECK: "-fdefault-real-8"
 ! CHECK: "-flarge-sizes"
-! CHECK:  "-mllvm" "-print-before-all"
+! CHECK: "-fpass-plugin=Bye
+! CHECK: "-mllvm" "-print-before-all"
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -42,6 +42,7 @@
 ! HELP-NEXT: -fno-integrated-as  Disable the integrated assembler
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: -help  Display available options
@@ -120,6 +121,7 @@
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E mode
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! HELP-FC1-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-FC1-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-FC1-NEXT: -help  Display available options
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -44,6 +44,7 @@
 ! CHECK-NEXT: -fno-integrated-as Disable the integrated assembler
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
 ! CHECK-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! CHECK-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! CHECK-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym 

[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-05 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

As @awarzynski mentioned, it is likely a missing dependency on the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-05 Thread Mats Petersson via Phabricator via cfe-commits
MatsPetersson added a comment.

In D129156#3837709 , @awarzynski 
wrote:

> I suspect that this fails when running `ninja check-flang`, right?
>
> Most likely `Bye` needs to be added as a dependency for Flang tests, 
> something akin to this 
> .
>   Alternatively, try adding `examples` to `! REQUIRES:` in pass-plugin.f90.

As this seems to be breaking the testing on the public servers, as well as 
locally on my machine, I've reverted the commit for now. Please feel free to 
submit an updated version, this is not a criticism of the work as such, just 
trying to keep the "build & test" green.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-05 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

I suspect that this fails when running `ninja check-flang`, right?

Most likely `Bye` needs to be added as a dependency for Flang tests, something 
akin to this 
.
  Alternatively, try adding `examples` to `! REQUIRES:` in pass-plugin.f90.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-05 Thread David Truby via Phabricator via cfe-commits
DavidTruby added a comment.

This is also causing phabricator's pre-commit CI builds to fail, for example 
this build for my patch: 
https://buildkite.com/llvm-project/premerge-checks/builds/115370#0183a8a5-6684-4602-952f-81bde55220ea
Could we revert this until it is fixed? I think the CI passing is quite 
important.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-05 Thread Mats Petersson via Phabricator via cfe-commits
MatsPetersson added a comment.

In D129156#3836895 , @tarunprabhu 
wrote:

> In D129156#3836838 , @clementval 
> wrote:
>
>> I probably didn't copy the error correctly .. this is the correct libs that 
>> is not found `llvm-project/build/lib/Bye.so`
>
> I need some help with this.
>
> The failing build is building flang out-of-tree. It looks like %llvmshlibdir/ 
> does not get set correctly in this case. Bye.so is located in %llvmshlibdir 
> which is within the LLVM build directory.
>
> Do you know if there is a way to tell the test-suite about %llvmshlibdir?

I'm fairly sure it is not a "out of tree" build, I'm seeing the same problem 
building in tree.
As far as I can see, there's nothing creatubg a "Bye.so" plugin. Maybe I'm 
missing something tho'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-05 Thread Tarun Prabhu via Phabricator via cfe-commits
tarunprabhu added a comment.

In D129156#3836838 , @clementval 
wrote:

> I probably didn't copy the error correctly .. this is the correct libs that 
> is not found `llvm-project/build/lib/Bye.so`

I need some help with this.

The failing build is building flang out-of-tree. It looks like %llvmshlibdir/ 
does not get set correctly in this case. Bye.so is located in %llvmshlibdir 
which is within the LLVM build directory.

Do you know if there is a way to tell the test-suite about %llvmshlibdir?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-05 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

In D129156#3836768 , @tarunprabhu 
wrote:

> I think there is a typo somehow. It should be "Bye.so". Not sure how that 
> happened. I'm looking into this.

I probably didn't copy the error correctly .. this is the correct libs that is 
not found `llvm-project/build/lib/Bye.so`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-05 Thread Tarun Prabhu via Phabricator via cfe-commits
tarunprabhu added a comment.

I think there is a typo somehow. It should be "Bye.so". Not sure how that 
happened. I'm looking into this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-05 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

I get a failure  since this commit. `Could not load library By.so` ... `cannot 
open shared object file: No such file or directory`. Maybe a missing dependency?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-04 Thread Tarun Prabhu via Phabricator via cfe-commits
tarunprabhu added a comment.

Thanks for the review and the comments. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129156: Add -fpass-plugin option to Flang

2022-10-04 Thread Tarun Prabhu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG43fe6f7cc35d: [flang] Add -fpass-plugin option to Flang 
frontend (authored by tarunprabhu).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129156

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  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/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
  flang/test/Driver/pass-plugin.f90

Index: flang/test/Driver/pass-plugin.f90
===
--- /dev/null
+++ flang/test/Driver/pass-plugin.f90
@@ -0,0 +1,13 @@
+! Verify that the plugin passed to -fpass-plugin is loaded and run
+
+! UNSUPPORTED: system-windows
+
+! REQUIRES: plugins, shell
+
+! RUN: %flang -S %s -fpass-plugin=%llvmshlibdir/Bye%pluginext -Xflang -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -S %s -fpass-plugin=%llvmshlibdir/Bye%pluginext -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s
+
+! CHECK: Running pass: {{.*}}Bye on empty_
+
+subroutine empty
+end subroutine empty
Index: flang/test/Driver/pass-plugin-not-found.f90
===
--- /dev/null
+++ flang/test/Driver/pass-plugin-not-found.f90
@@ -0,0 +1,8 @@
+! Check the correct error diagnostic is reported when a pass plugin shared object isn't found
+
+! REQUIRES: plugins, shell
+
+! RUN: not %flang -fpass-plugin=X.Y %s 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: not %flang_fc1 -emit-llvm -o /dev/null -fpass-plugin=X.Y %s 2>&1 | FileCheck %s --check-prefix=ERROR
+
+! ERROR: error: unable to load plugin 'X.Y': 'Could not load library 'X.Y': X.Y: cannot open shared object file: No such file or directory'
Index: flang/test/Driver/frontend-forwarding.f90
===
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -7,6 +7,7 @@
 ! RUN: -fdefault-integer-8 \
 ! RUN: -fdefault-real-8 \
 ! RUN: -flarge-sizes \
+! RUN: -fpass-plugin=Bye%pluginext \
 ! RUN: -mllvm -print-before-all\
 ! RUN: -P \
 ! RUN:   | FileCheck %s
@@ -17,4 +18,5 @@
 ! CHECK: "-fdefault-integer-8"
 ! CHECK: "-fdefault-real-8"
 ! CHECK: "-flarge-sizes"
-! CHECK:  "-mllvm" "-print-before-all"
+! CHECK: "-fpass-plugin=Bye
+! CHECK: "-mllvm" "-print-before-all"
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -42,6 +42,7 @@
 ! HELP-NEXT: -fno-integrated-as  Disable the integrated assembler
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: -help  Display available options
@@ -120,6 +121,7 @@
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E mode
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! HELP-FC1-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-FC1-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-FC1-NEXT: -help  Display available options
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -44,6 +44,7 @@
 ! CHECK-NEXT: -fno-integrated-as Disable the integrated assembler
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
 ! CHECK-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
+! CHECK-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! CHECK-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! CHECK-NEXT: -help Display available options
@@ -71,4 +72,3 @@
 
 ! Frontend dri