llvm-project/clang/test/CodeGen/new-pass-manager-opt-bisect.c
Cristian Assaiante 81eb7defa2
[OptBisect][IR] Adding a new OptPassGate for disabling passes via name (#145059)
This commit adds a new pass gate that allows selective disabling
of one or more passes via the clang command line using the
`-opt-disable` option. Passes to be disabled should be specified as a
comma-separated list of their names.
The implementation resides in the same file as the bisection tool. The
`getGlobalPassGate()` function returns the currently enabled gate.

Example: `-opt-disable="PassA,PassB"`

Pass names are matched using case-insensitive comparisons. However, note
that special characters, including spaces, must be included exactly as
they appear in the pass names.

Additionally, a `-opt-disable-enable-verbosity` flag has been introduced to
enable verbose output when this functionality is in use. When enabled,
it prints the status of all passes (either running or NOT running),
similar to the default behavior of `-opt-bisect-limit`. This flag is
disabled by default, which is the opposite of the `-opt-bisect-verbose`
flag (which defaults to enabled).

To validate this functionality, a test file has also been provided. It reuses
the same infrastructure as the opt-bisect test, but disables three
specific passes and checks the output to ensure the expected behavior.

---------

Co-authored-by: Nikita Popov <github@npopov.com>
2025-07-16 16:51:58 -07:00

13 lines
389 B
C

// REQUIRES: x86-registered-target
// Make sure opt-bisect works through both pass managers
//
// RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 %s -mllvm -opt-bisect-limit=-1 -emit-obj -o /dev/null 2>&1 | FileCheck %s
// CHECK: BISECT: running pass (1)
// CHECK-NOT: BISECT: running pass (1)
// Make sure that legacy pass manager is running
// CHECK: -isel
int func(int a) { return a; }