[llvm] [profcheck] Change the FileCheck substitute command (PR #156985)

Alan Zhao via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 4 16:50:04 PDT 2025


https://github.com/alanzhao1 created https://github.com/llvm/llvm-project/pull/156985

The intent of the original regex doesn't work if, for example, the last RUN line was a pipe and FileCheck is in the next RUN line. See for example
[`function-specialization3.ll`](https://github.com/llvm/llvm-project/blob/a7c2ce6009a8034ebbf718c12a6e56c085036b57/llvm/test/Transforms/FunctionSpecialization/function-specialization3.ll). To fix this we just replace the redirerect stdout to `/dev/null` with `cat /dev/null`, which works because it's effectively a no-op command that can be piped to or run standalone.

Tracking issue: #147390

>From 9744a38d657c33b7c46e32da5041c5ae048d0a8c Mon Sep 17 00:00:00 2001
From: Alan Zhao <ayzhao at google.com>
Date: Thu, 4 Sep 2025 16:41:48 -0700
Subject: [PATCH] [profcheck] Change the FileCheck substitute command

The intent of the original regex doesn't work if, for example, the last
RUN line was a pipe and FileCheck is in the next RUN line. See for
example
[`function-specialization3.ll`](https://github.com/llvm/llvm-project/blob/a7c2ce6009a8034ebbf718c12a6e56c085036b57/llvm/test/Transforms/FunctionSpecialization/function-specialization3.ll).
To fix this we just replace the redirerect stdout to `/dev/null` with
`cat /dev/null`, which works because it's effectively a no-op command
that can be piped to or run standalone.

Tracking issue: #147390
---
 llvm/test/lit.cfg.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index 05b5f02b9bd9a..7a285468b6a0d 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -20,8 +20,8 @@
 # testFormat: The test format to use to interpret tests.
 extra_substitutions = extra_substitutions = (
     [
-        (r"\| not FileCheck .*", "> /dev/null"),
-        (r"\| FileCheck .*", "> /dev/null"),
+        (r"FileCheck .*", "cat > /dev/null"),
+        (r"not FileCheck .*", "cat > /dev/null"),
     ]
     if config.enable_profcheck
     else []
@@ -39,6 +39,16 @@
 # directories.
 config.excludes = ["Inputs", "CMakeLists.txt", "README.txt", "LICENSE.txt"]
 
+# Exclude llvm-reduce tests for profcheck because we substitute the FileCheck
+# binary with a no-op command for profcheck, but llvm-reduce tests have RUN
+# commands of the form llvm-reduce --test FileCheck, which explode if we
+# substitute FileCheck because llvm-reduce expects FileCheck in these tests.
+# It's not really possible to exclude these tests from the command substitution,
+# so we just exclude llvm-reduce tests from this config altogether. This should
+# be fine though as profcheck config tests are mostly concerned with opt.
+if config.enable_profcheck:
+  config.excludes = config.excludes + ["llvm-reduce"]
+
 # test_source_root: The root path where tests are located.
 config.test_source_root = os.path.dirname(__file__)
 



More information about the llvm-commits mailing list