Skip to content

Commit

Permalink
[NFC] Disallow unused prefixes under llvm/test
Browse files Browse the repository at this point in the history
This patch sets the default for llvm tests, with the exception of tests
under Reduce, because quite a few of them use 'FileCheck' as parameter
to a tool, and including a flag as that parameter would complicate
matters.

The rest of the patch undo-es the lit.local.cfg changes we progressively
introduced as temporary measure to avoid regressions under various
directories.

Differential Revision: https://reviews.llvm.org/D95111
  • Loading branch information
mtrofin authored and memfrob committed Oct 4, 2022
1 parent b585f53 commit 6dd0a61
Show file tree
Hide file tree
Showing 22 changed files with 53 additions and 94 deletions.
9 changes: 0 additions & 9 deletions llvm/test/Analysis/lit.local.cfg

This file was deleted.

7 changes: 0 additions & 7 deletions llvm/test/CodeGen/lit.local.cfg

This file was deleted.

9 changes: 9 additions & 0 deletions llvm/test/FileCheck/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,12 @@ config.test_format = lit.formats.ShTest(execute_external=False)
# that test results throughout all test suites are affected.
config.substitutions.append(('%ProtectFileCheckOutput',
'env -u FILECHECK_OPTS'))

# FIXME: remove this once the default is flipped.
from lit.llvm.subst import ToolSubst

fc = ToolSubst('FileCheck', unresolved='fatal')
# the parent introduced the opposite rule, so we replace it if we see it.
if len(config.substitutions) > 0 and config.substitutions[0] == (fc.regex, 'FileCheck --allow-unused-prefixes=false'):
del config.substitutions[0]

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-globals-live-support=0 -mtriple=x86_64-unknown-linux-gnu -S | FileCheck --check-prefixes=CHECK,CHECK-S3 %s
; RUN: opt < %s -passes='asan-pipeline' -asan-globals-live-support=0 -mtriple=x86_64-unknown-linux-gnu -S | FileCheck --check-prefixes=CHECK,CHECK-S3 %s
; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-globals-live-support=0 -mtriple=x86_64-apple-macosx10.11.0 -S | FileCheck --check-prefixes=CHECK,CHECK-S3 %s
; RUN: opt < %s -passes='asan-pipeline' -asan-globals-live-support=0 -mtriple=x86_64-apple-macosx10.11.0 -S | FileCheck --check-prefixes=CHECK,CHECK-S3 %s
; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-globals-live-support=0 -mtriple=x86_64-pc-windows-msvc19.0.24215 -S | FileCheck --check-prefixes=CHECK,CHECK-S3 %s
; RUN: opt < %s -passes='asan-pipeline' -asan-globals-live-support=0 -mtriple=x86_64-pc-windows-msvc19.0.24215 -S | FileCheck --check-prefixes=CHECK,CHECK-S3 %s
; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-globals-live-support=0 -mtriple=x86_64-unknown-linux-gnu -S | FileCheck --check-prefix=CHECK %s
; RUN: opt < %s -passes='asan-pipeline' -asan-globals-live-support=0 -mtriple=x86_64-unknown-linux-gnu -S | FileCheck --check-prefix=CHECK %s
; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-globals-live-support=0 -mtriple=x86_64-apple-macosx10.11.0 -S | FileCheck --check-prefix=CHECK %s
; RUN: opt < %s -passes='asan-pipeline' -asan-globals-live-support=0 -mtriple=x86_64-apple-macosx10.11.0 -S | FileCheck --check-prefix=CHECK %s
; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-globals-live-support=0 -mtriple=x86_64-pc-windows-msvc19.0.24215 -S | FileCheck --check-prefix=CHECK %s
; RUN: opt < %s -passes='asan-pipeline' -asan-globals-live-support=0 -mtriple=x86_64-pc-windows-msvc19.0.24215 -S | FileCheck --check-prefix=CHECK %s
; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-globals-live-support=0 -asan-mapping-scale=5 -mtriple=x86_64-unknown-linux-gnu -S | FileCheck --check-prefixes=CHECK,CHECK-S5 %s
; RUN: opt < %s -passes='asan-pipeline' -asan-globals-live-support=0 -asan-mapping-scale=5 -mtriple=x86_64-unknown-linux-gnu -S | FileCheck --check-prefixes=CHECK,CHECK-S5 %s

Expand Down
8 changes: 4 additions & 4 deletions llvm/test/Instrumentation/HWAddressSanitizer/basic.ll
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
; Test basic address sanitizer instrumentation.
;
; RUN: opt < %s -hwasan -hwasan-recover=0 -hwasan-with-ifunc=1 -hwasan-with-tls=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT,ABORT-DYNAMIC-SHADOW
; RUN: opt < %s -hwasan -hwasan-recover=0 -hwasan-with-ifunc=1 -hwasan-with-tls=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT
; RUN: opt < %s -hwasan -hwasan-recover=1 -hwasan-with-ifunc=1 -hwasan-with-tls=0 -S | FileCheck %s --check-prefixes=CHECK,RECOVER,RECOVER-DYNAMIC-SHADOW
; RUN: opt < %s -hwasan -hwasan-recover=0 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT,ABORT-ZERO-BASED-SHADOW
; RUN: opt < %s -hwasan -hwasan-recover=0 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT
; RUN: opt < %s -hwasan -hwasan-recover=1 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,RECOVER,RECOVER-ZERO-BASED-SHADOW

; Ensure than hwasan runs with the new PM pass
; RUN: opt < %s -passes=hwasan -hwasan-recover=0 -hwasan-with-ifunc=1 -hwasan-with-tls=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT,ABORT-DYNAMIC-SHADOW
; RUN: opt < %s -passes=hwasan -hwasan-recover=0 -hwasan-with-ifunc=1 -hwasan-with-tls=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT
; RUN: opt < %s -passes=hwasan -hwasan-recover=1 -hwasan-with-ifunc=1 -hwasan-with-tls=0 -S | FileCheck %s --check-prefixes=CHECK,RECOVER,RECOVER-DYNAMIC-SHADOW
; RUN: opt < %s -passes=hwasan -hwasan-recover=0 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT,ABORT-ZERO-BASED-SHADOW
; RUN: opt < %s -passes=hwasan -hwasan-recover=0 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT
; RUN: opt < %s -passes=hwasan -hwasan-recover=1 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,RECOVER,RECOVER-ZERO-BASED-SHADOW

; CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @hwasan.module_ctor, i8* bitcast (void ()* @hwasan.module_ctor to i8*) }]
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Instrumentation/HWAddressSanitizer/prologue.ll
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
; RUN: opt -hwasan -S -hwasan-with-ifunc=0 -hwasan-with-tls=0 < %s | \
; RUN: FileCheck %s --check-prefixes=CHECK,CHECK-GLOBAL,CHECK-NOHISTORY
; RUN: opt -hwasan -S -hwasan-with-ifunc=1 -hwasan-with-tls=0 < %s | \
; RUN: FileCheck %s --check-prefixes=CHECK,CHECk-NOGLOBAL,CHECK-IFUNC,CHECK-NOHISTORY
; RUN: FileCheck %s --check-prefixes=CHECK,CHECK-IFUNC,CHECK-NOHISTORY

target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64--linux-android22"
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Instrumentation/MemorySanitizer/array_types.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \
; RUN: -passes=msan 2>&1 | FileCheck -check-prefix=CHECK \
; RUN: -check-prefix=CHECK-ORIGINS %s --allow-empty
; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
; RUN: %s --allow-empty
; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -check-prefix=CHECK %s

target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Instrumentation/MemorySanitizer/check-array.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; RUN: opt < %s -msan-eager-checks -msan-check-access-address=0 -msan-track-origins=1 -S -passes='module(msan-module),function(msan)' 2>&1 | \
; RUN: FileCheck -allow-deprecated-dag-overlap -check-prefixes=CHECK,CHECK-ORIGINS %s
; RUN: FileCheck -allow-deprecated-dag-overlap --check-prefix=CHECK %s

target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Instrumentation/MemorySanitizer/check-struct.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S -passes='module(msan-module),function(msan)' 2>&1 | \
; RUN: FileCheck -allow-deprecated-dag-overlap -check-prefixes=CHECK,CHECK-ORIGINS %s
; RUN: FileCheck -allow-deprecated-dag-overlap --check-prefix=CHECK %s

target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Instrumentation/MemorySanitizer/freeze.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck %s
; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=2 -S -passes=msan 2>&1 | FileCheck %s -check-prefixes=CHECK,CHECK-ORIGIN
; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=2 -S -passes=msan 2>&1 | FileCheck %s
; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
; Test for handling of asm constraints in MSan instrumentation.
; RUN: opt < %s -msan-kernel=1 -msan-check-access-address=0 \
; RUN: -msan-handle-asm-conservative=0 -S -passes=msan 2>&1 | FileCheck \
; RUN: "-check-prefixes=CHECK,CHECK-NONCONS" %s
; RUN: opt < %s -msan -msan-kernel=1 -msan-check-access-address=0 -msan-handle-asm-conservative=0 -S | FileCheck -check-prefixes=CHECK,CHECK-NONCONS %s
; RUN: "-check-prefix=CHECK" %s
; RUN: opt < %s -msan -msan-kernel=1 -msan-check-access-address=0 -msan-handle-asm-conservative=0 -S | FileCheck -check-prefixes=CHECK %s
; RUN: opt < %s -msan-kernel=1 -msan-check-access-address=0 \
; RUN: -msan-handle-asm-conservative=1 -S -passes=msan 2>&1 | FileCheck \
; RUN: "-check-prefixes=CHECK,CHECK-CONS" %s
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Instrumentation/MemorySanitizer/msan_eager.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -msan-eager-checks -S -passes='module(msan-module),function(msan)' 2>&1 | \
; RUN: FileCheck -allow-deprecated-dag-overlap -check-prefixes=CHECK,CHECK-ORIGINS %s
; RUN: FileCheck -allow-deprecated-dag-overlap --check-prefix=CHECK %s

target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Instrumentation/MemorySanitizer/msan_x86_bts_asm.ll
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
; Test for the conservative assembly handling mode used by KMSAN.
; RUN: opt < %s -msan-kernel=1 -msan-check-access-address=0 \
; RUN: -msan-handle-asm-conservative=0 -S -passes=msan 2>&1 | FileCheck \
; RUN: "-check-prefixes=CHECK,CHECK-NONCONS" %s
; RUN: opt < %s -msan -msan-kernel=1 -msan-check-access-address=0 -msan-handle-asm-conservative=0 -S | FileCheck -check-prefixes=CHECK,CHECK-NONCONS %s
; RUN: "-check-prefix=CHECK" %s
; RUN: opt < %s -msan -msan-kernel=1 -msan-check-access-address=0 -msan-handle-asm-conservative=0 -S | FileCheck -check-prefixes=CHECK %s
; RUN: opt < %s -msan-kernel=1 -msan-check-access-address=0 \
; RUN: -msan-handle-asm-conservative=1 -S -passes=msan 2>&1 | FileCheck \
; RUN: "-check-prefixes=CHECK,CHECK-CONS" %s
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Instrumentation/MemorySanitizer/reduce.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S -passes='module(msan-module),function(msan)' 2>&1 | \
; RUN: FileCheck -allow-deprecated-dag-overlap -check-prefixes=CHECK,CHECK-ORIGINS %s
; RUN: FileCheck -allow-deprecated-dag-overlap --check-prefix=CHECK %s

target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
Expand Down
8 changes: 0 additions & 8 deletions llvm/test/MC/AArch64/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
from lit.llvm.subst import ToolSubst

if 'AArch64' not in config.root.targets:
config.unsupported = True

fc = ToolSubst('FileCheck', unresolved='fatal')
# Insert this first. Then, we'll first update the blank FileCheck command; then,
# the default substitution of FileCheck will replace it to its full path.
config.substitutions.insert(0, (fc.regex,
'FileCheck --allow-unused-prefixes=false'))
8 changes: 0 additions & 8 deletions llvm/test/MC/AMDGPU/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
from lit.llvm.subst import ToolSubst

if not 'AMDGPU' in config.root.targets:
config.unsupported = True

fc = ToolSubst('FileCheck', unresolved='fatal')
# Insert this first. Then, we'll first update the blank FileCheck command; then,
# the default substitution of FileCheck will replace it to its full path.
config.substitutions.insert(0, (fc.regex,
'FileCheck --allow-unused-prefixes=false'))
8 changes: 0 additions & 8 deletions llvm/test/MC/ARM/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
from lit.llvm.subst import ToolSubst

if not 'ARM' in config.root.targets:
config.unsupported = True

fc = ToolSubst('FileCheck', unresolved='fatal')
# Insert this first. Then, we'll first update the blank FileCheck command; then,
# the default substitution of FileCheck will replace it to its full path.
config.substitutions.insert(0, (fc.regex,
'FileCheck --allow-unused-prefixes=false'))
8 changes: 0 additions & 8 deletions llvm/test/MC/RISCV/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
from lit.llvm.subst import ToolSubst

if not 'RISCV' in config.root.targets:
config.unsupported = True

fc = ToolSubst('FileCheck', unresolved='fatal')
# Insert this first. Then, we'll first update the blank FileCheck command; then,
# the default substitution of FileCheck will replace it to its full path.
config.substitutions.insert(0, (fc.regex,
'FileCheck --allow-unused-prefixes=false'))
12 changes: 0 additions & 12 deletions llvm/test/Other/lit.local.cfg

This file was deleted.

8 changes: 8 additions & 0 deletions llvm/test/Reduce/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
# FIXME: remove this file when we flip the default for --allow-unused-prefixes.
from lit.llvm.subst import ToolSubst

fc = ToolSubst('FileCheck', unresolved='fatal')
# the parent introduced the opposite rule, so we replace it if we see it.
if len(config.substitutions) > 0 and config.substitutions[0] == (fc.regex, 'FileCheck --allow-unused-prefixes=false'):
del config.substitutions[0]
8 changes: 0 additions & 8 deletions llvm/test/Transforms/lit.local.cfg

This file was deleted.

18 changes: 14 additions & 4 deletions llvm/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,20 @@ def get_asan_rtlib():
return ''
return found_dylibs[0]

# Define this first. Afterwards, use_default_substitutions will add the rule for
# expanding FileCheck to the full path.
config.substitutions.append(('%FileCheckWithUnusedPrefixes%',
'FileCheck --allow-unused-prefixes=true'))

####################################################
# FIXME: remove this when we flip the default value for --allow-unused-prefixes
# to false.
fc = ToolSubst('FileCheck', unresolved='fatal')
# Insert this first. Then, we'll first update the blank FileCheck command; then,
# the default substitution of FileCheck will replace it to its full path.
config.substitutions.insert(0, (fc.regex,
'FileCheck --allow-unused-prefixes=false'))
# When addressing this fixme, replace %FileCheckRaw% with just FileCheck.
config.substitutions.append(('%FileCheckRaw%', 'FileCheck'))
# Also remove the lit.local.cfg under llvm/test/Reduce
# and the pertinent FIXME in llvm/test/FileCheck
####################################################

llvm_config.use_default_substitutions()

Expand Down

0 comments on commit 6dd0a61

Please sign in to comment.