[flang-commits] [clang] [flang] [lld] [llvm] Test entry-points for pass-plugins with Bye in clang, flang and lld (PR #172463)

Michael Kruse via flang-commits flang-commits at lists.llvm.org
Thu Dec 18 03:28:53 PST 2025


Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/172463 at github.com>


================
@@ -0,0 +1,62 @@
+! REQUIRES: plugins, examples
+
+! Entry-points in default and -O0 pipeline
+!
+! RUN: %flang -fpass-plugin=%llvmshlibdir/Bye%pluginext \
+! RUN:        -Xflang -load -Xflang %llvmshlibdir/Bye%pluginext \
+! RUN:        -mllvm -print-ep-callbacks -o /dev/null -S %s | FileCheck --check-prefix=EP %s
+!
+! RUN: %flang -fpass-plugin=%llvmshlibdir/Bye%pluginext -flto=full -O0 \
+! RUN:        -Xflang -load -Xflang %llvmshlibdir/Bye%pluginext \
+! RUN:        -mllvm -print-ep-callbacks -o /dev/null -S %s | FileCheck --check-prefix=EP %s
+!
+! RUN: %flang -fpass-plugin=%llvmshlibdir/Bye%pluginext -flto=thin -O0 \
+! RUN:        -Xflang -load -Xflang %llvmshlibdir/Bye%pluginext \
+! RUN:        -mllvm -print-ep-callbacks -o /dev/null -S %s | FileCheck --check-prefix=EP %s
+!
+! EP:     PipelineStart
+! EP:     PipelineEarlySimplification
+! EP-NOT: Peephole
+! EP:     ScalarOptimizerLate
+! EP-NOT: Peephole
+! EP:     OptimizerEarly
+! EP:     VectorizerStart
+! EP:     VectorizerEnd
+! EP:     OptimizerLast
----------------
Meinersbur wrote:

Consider add an optimization option such as `-O1` to the tests so Clang stops adding `optnone`.

`optnone` is added so that in a LTO build, the linker doesn't start optimizing object files that were compiled with optimizations disabled[^1]. Potentially Flang should do the same.

On the other side, it feels inconcistent if `buildO0DefaultPipeline` explicitly invokes those callbacks only to get ignored later because of `optnone`.

[^1]: This has caused a lot of confusion with users who get the LLVM-IR with `-emit-llvm` to pass it to `opt` which doesn't do anything because Clang's default is to annotate all functions with `optnone`.

https://github.com/llvm/llvm-project/pull/172463


More information about the flang-commits mailing list