From 9744a38d657c33b7c46e32da5041c5ae048d0a8c Mon Sep 17 00:00:00 2001 From: Alan Zhao Date: Thu, 4 Sep 2025 16:41:48 -0700 Subject: [PATCH 1/2] [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__) From d67cd859793c83f6b7d5a71fb8b163364dfaea8a Mon Sep 17 00:00:00 2001 From: Alan Zhao Date: Thu, 4 Sep 2025 16:55:54 -0700 Subject: [PATCH 2/2] fix spacing --- llvm/test/lit.cfg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py index 7a285468b6a0d..867a44be56727 100644 --- a/llvm/test/lit.cfg.py +++ b/llvm/test/lit.cfg.py @@ -47,7 +47,7 @@ # 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"] + config.excludes = config.excludes + ["llvm-reduce"] # test_source_root: The root path where tests are located. config.test_source_root = os.path.dirname(__file__)