Skip to content

[NFC][bolt][test] Change '|&' to '2>&1 |' for lit internal shell support #102402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

connieyzhu
Copy link
Contributor

@connieyzhu connieyzhu commented Aug 7, 2024

This patches changes all references to '|&' in bolt tests to instead use the '2>&1 |' syntax for better consistency across testing and so that lit's internal shell can be used to run these tests. This addresses a suggestion made in the comments of this RFC: https://discourse.llvm.org/t/rfc-enabling-the-lit-internal-shell-by-default/80179.

Fixes #102388

This patches changes all references to '|&' in bolt tests to instead use
the '2>&1 |' syntax for better consistency across testing and so that
the internal shell can be used for these tests.
@llvmbot
Copy link
Member

llvmbot commented Aug 7, 2024

@llvm/pr-subscribers-bolt

Author: Connie (connieyzhu)

Changes

This patches changes all references to '|&' in bolt tests to instead use the '2>&1 |' syntax for better consistency across testing and so that the internal shell can be used for these tests.


Full diff: https://github.com/llvm/llvm-project/pull/102402.diff

16 Files Affected:

  • (modified) bolt/test/X86/encoding-validation.s (+1-1)
  • (modified) bolt/test/X86/gotpcrelx.s (+3-3)
  • (modified) bolt/test/X86/icf-jump-tables.test (+1-1)
  • (modified) bolt/test/X86/indirect-goto-pie.test (+1-1)
  • (modified) bolt/test/X86/jump-table-func-entry.s (+1-1)
  • (modified) bolt/test/X86/keep-nops.s (+1-1)
  • (modified) bolt/test/X86/linux-bug-table.s (+1-1)
  • (modified) bolt/test/X86/linux-orc.s (+4-4)
  • (modified) bolt/test/X86/linux-pci-fixup.s (+1-1)
  • (modified) bolt/test/X86/linux-smp-locks.s (+2-2)
  • (modified) bolt/test/X86/linux-static-calls.s (+2-2)
  • (modified) bolt/test/X86/linux-static-keys.s (+4-4)
  • (modified) bolt/test/X86/pt_gnu_relro.s (+1-1)
  • (modified) bolt/test/X86/unclaimed-jt-entries.s (+1-1)
  • (modified) bolt/test/X86/vararg.test (+1-1)
  • (modified) bolt/test/runtime/X86/unclaimed-jt-entries.s (+1-1)
diff --git a/bolt/test/X86/encoding-validation.s b/bolt/test/X86/encoding-validation.s
index 0c716abc4cc0cf..c0136129648950 100644
--- a/bolt/test/X86/encoding-validation.s
+++ b/bolt/test/X86/encoding-validation.s
@@ -2,7 +2,7 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
 # RUN: ld.lld %t.o -o %t.exe -q
-# RUN: llvm-bolt %t.exe --relocs -o %t.out --check-encoding |& FileCheck %s
+# RUN: llvm-bolt %t.exe --relocs -o %t.out --check-encoding 2>&1 | FileCheck %s
 
   .text
   .globl _start
diff --git a/bolt/test/X86/gotpcrelx.s b/bolt/test/X86/gotpcrelx.s
index 6dec125c6a72bd..c5bc7ac7d0d472 100644
--- a/bolt/test/X86/gotpcrelx.s
+++ b/bolt/test/X86/gotpcrelx.s
@@ -10,11 +10,11 @@
 # RUN: ld.lld %t.o -o %t.pie.exe -q -pie
 # RUN: ld.lld %t.o -o %t.no-relax.exe -q --no-relax
 # RUN: llvm-bolt %t.exe --relocs -o %t.out --print-cfg --print-only=_start \
-# RUN:   |& FileCheck --check-prefix=BOLT %s
+# RUN:   2>&1 | FileCheck --check-prefix=BOLT %s
 # RUN: llvm-bolt %t.pie.exe -o %t.null --print-cfg --print-only=_start \
-# RUN:   |& FileCheck --check-prefix=PIE-BOLT %s
+# RUN:   2>&1 | FileCheck --check-prefix=PIE-BOLT %s
 # RUN: llvm-bolt %t.no-relax.exe -o %t.null --print-cfg --print-only=_start \
-# RUN:   |& FileCheck --check-prefix=NO-RELAX-BOLT %s
+# RUN:   2>&1 | FileCheck --check-prefix=NO-RELAX-BOLT %s
 # RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex \
 # RUN:   %t.out | FileCheck --check-prefix=DISASM %s
 
diff --git a/bolt/test/X86/icf-jump-tables.test b/bolt/test/X86/icf-jump-tables.test
index 41820008b01338..57137b79bc317e 100644
--- a/bolt/test/X86/icf-jump-tables.test
+++ b/bolt/test/X86/icf-jump-tables.test
@@ -4,7 +4,7 @@
 # REQUIRES: system-linux
 
 # RUN: %clang %cflags -O1 -g %p/../Inputs/icf-jump-tables.c -o %t.exe -Wl,-q
-# RUN: llvm-bolt %t.exe --icf -o %t.bolt |& FileCheck %s
+# RUN: llvm-bolt %t.exe --icf -o %t.bolt 2>&1 | FileCheck %s
 
 ## Check that BOLT successfully folded a function with jump table:
 # CHECK: ICF folded {{.*}}. {{[^0]}} functions had jump tables.
diff --git a/bolt/test/X86/indirect-goto-pie.test b/bolt/test/X86/indirect-goto-pie.test
index 81cff9a32fbbdd..3311c1aec061c5 100644
--- a/bolt/test/X86/indirect-goto-pie.test
+++ b/bolt/test/X86/indirect-goto-pie.test
@@ -6,7 +6,7 @@ REQUIRES: x86_64-linux
 
 RUN: %clang %S/Inputs/indirect_goto.c -o %t -fpic -pie -Wl,-q
 RUN: not llvm-bolt %t -o %t.bolt --relocs=1 --print-cfg --print-only=main \
-RUN:   |& FileCheck %s
+RUN:   2>&1 | FileCheck %s
 
 ## Check that processing works if main() is skipped.
 RUN: llvm-bolt %t -o %t.bolt --relocs=1 --skip-funcs=main
diff --git a/bolt/test/X86/jump-table-func-entry.s b/bolt/test/X86/jump-table-func-entry.s
index 77b444d520a1f1..b34e7142785d4a 100644
--- a/bolt/test/X86/jump-table-func-entry.s
+++ b/bolt/test/X86/jump-table-func-entry.s
@@ -7,7 +7,7 @@
 # RUN: %clang %cflags %t.o -o %t.exe -no-pie -Wl,-q
 
 # RUN: llvm-bolt %t.exe --print-normalized --print-only=foo -o %t.out \
-# RUN:   |& FileCheck %s
+# RUN:   2>&1 | FileCheck %s
 
 
 
diff --git a/bolt/test/X86/keep-nops.s b/bolt/test/X86/keep-nops.s
index 37da2ff07b9b79..ddd34ce61d620d 100644
--- a/bolt/test/X86/keep-nops.s
+++ b/bolt/test/X86/keep-nops.s
@@ -5,7 +5,7 @@
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
 # RUN: ld.lld %t.o -o %t.exe -q
 # RUN: llvm-bolt %t.exe -o %t.bolt.exe --keep-nops --relocs --print-finalized \
-# RUN:   |& FileCheck --check-prefix=CHECK-BOLT %s
+# RUN:   2>&1 | FileCheck --check-prefix=CHECK-BOLT %s
 # RUN: llvm-objdump -d %t.bolt.exe | FileCheck %s
 
   .text
diff --git a/bolt/test/X86/linux-bug-table.s b/bolt/test/X86/linux-bug-table.s
index 63f70a0b35d9fe..07a4729ade7374 100644
--- a/bolt/test/X86/linux-bug-table.s
+++ b/bolt/test/X86/linux-bug-table.s
@@ -15,7 +15,7 @@
 ## Verify bug entry bindings again after unreachable code elimination.
 
 # RUN: llvm-bolt %t.out -o %t.out.1 --print-only=_start --print-normalized \
-# RUN:   |& FileCheck --check-prefix=CHECK-REOPT %s
+# RUN:   2>&1 | FileCheck --check-prefix=CHECK-REOPT %s
 
 # CHECK:      BOLT-INFO: Linux kernel binary detected
 # CHECK:      BOLT-INFO: parsed 2 bug table entries
diff --git a/bolt/test/X86/linux-orc.s b/bolt/test/X86/linux-orc.s
index 5f2096278e92d6..1b0e681b1dbf96 100644
--- a/bolt/test/X86/linux-orc.s
+++ b/bolt/test/X86/linux-orc.s
@@ -9,7 +9,7 @@
 
 ## Verify reading contents of ORC sections.
 
-# RUN: llvm-bolt %t.exe --dump-orc -o /dev/null |& FileCheck %s \
+# RUN: llvm-bolt %t.exe --dump-orc -o /dev/null 2>&1 | FileCheck %s \
 # RUN:   --check-prefix=CHECK-ORC
 
 # CHECK-ORC: 	    BOLT-INFO: ORC unwind information:
@@ -27,19 +27,19 @@
 ## Verify ORC bindings to instructions.
 
 # RUN: llvm-bolt %t.exe --print-normalized --dump-orc --print-orc -o %t.out \
-# RUN:   --keep-nops=0 --bolt-info=0 |& FileCheck %s
+# RUN:   --keep-nops=0 --bolt-info=0 2>&1 | FileCheck %s
 
 
 ## Verify ORC bindings after rewrite.
 
 # RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized --print-orc \
-# RUN:   |& FileCheck %s
+# RUN:   2>&1 | FileCheck %s
 
 ## Verify ORC binding after rewrite when some of the functions are skipped.
 
 # RUN: llvm-bolt %t.exe -o %t.out --skip-funcs=bar --bolt-info=0 --keep-nops=0
 # RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized --print-orc \
-# RUN:   |& FileCheck %s
+# RUN:   2>&1 | FileCheck %s
 
 # CHECK:      BOLT-INFO: Linux kernel binary detected
 # CHECK:      BOLT-INFO: parsed 9 ORC entries
diff --git a/bolt/test/X86/linux-pci-fixup.s b/bolt/test/X86/linux-pci-fixup.s
index a574ba84c4df11..42504c108d339c 100644
--- a/bolt/test/X86/linux-pci-fixup.s
+++ b/bolt/test/X86/linux-pci-fixup.s
@@ -3,7 +3,7 @@
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
 # RUN: %clang %cflags -nostdlib %t.o -o %t.exe \
 # RUN:   -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr,--no-pie
-# RUN: llvm-bolt %t.exe --print-normalized -o %t.out |& FileCheck %s
+# RUN: llvm-bolt %t.exe --print-normalized -o %t.out 2>&1 | FileCheck %s
 
 ## Check that BOLT correctly parses the Linux kernel .pci_fixup section and
 ## verify that PCI fixup hook in the middle of a function is detected.
diff --git a/bolt/test/X86/linux-smp-locks.s b/bolt/test/X86/linux-smp-locks.s
index 5f4410d14fc6b0..50d9e632b11720 100644
--- a/bolt/test/X86/linux-smp-locks.s
+++ b/bolt/test/X86/linux-smp-locks.s
@@ -7,11 +7,11 @@
 # RUN: %clang %cflags -nostdlib %t.o -o %t.exe \
 # RUN:   -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr,--no-pie
 # RUN: llvm-bolt %t.exe --print-normalized --keep-nops=0 --bolt-info=0 -o %t.out \
-# RUN:   |& FileCheck %s
+# RUN:   2>&1 | FileCheck %s
 
 ## Check the output of BOLT with NOPs removed.
 
-# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized |& FileCheck %s
+# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized 2>&1 | FileCheck %s
 
 # CHECK:      BOLT-INFO: Linux kernel binary detected
 # CHECK:      BOLT-INFO: parsed 2 SMP lock entries
diff --git a/bolt/test/X86/linux-static-calls.s b/bolt/test/X86/linux-static-calls.s
index caf95e1c03227d..ce90f4bb79c094 100644
--- a/bolt/test/X86/linux-static-calls.s
+++ b/bolt/test/X86/linux-static-calls.s
@@ -9,11 +9,11 @@
 ## Verify static calls bindings to instructions.
 
 # RUN: llvm-bolt %t.exe --print-normalized -o %t.out --keep-nops=0 \
-# RUN:   --bolt-info=0 |& FileCheck %s
+# RUN:   --bolt-info=0 2>&1 | FileCheck %s
 
 ## Verify the bindings again on the rewritten binary with nops removed.
 
-# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized |& FileCheck %s
+# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized 2>&1 | FileCheck %s
 
 # CHECK:      BOLT-INFO: Linux kernel binary detected
 # CHECK:      BOLT-INFO: parsed 2 static call entries
diff --git a/bolt/test/X86/linux-static-keys.s b/bolt/test/X86/linux-static-keys.s
index fb419e0f762755..0bd17a375d8824 100644
--- a/bolt/test/X86/linux-static-keys.s
+++ b/bolt/test/X86/linux-static-keys.s
@@ -11,17 +11,17 @@
 ## Verify static keys jump bindings to instructions.
 
 # RUN: llvm-bolt %t.exe --print-normalized -o %t.out --keep-nops=0 \
-# RUN:   --bolt-info=0 |& FileCheck %s
+# RUN:   --bolt-info=0 2>&1 | FileCheck %s
 
 ## Verify that profile is matched correctly.
 
 # RUN: llvm-bolt %t.exe --print-normalized -o %t.out --keep-nops=0 \
-# RUN:   --bolt-info=0 --data %t.fdata |& \
-# RUN:   FileCheck --check-prefix=CHECK-FDATA %s
+# RUN:   --bolt-info=0 --data %t.fdata 2>&1 \
+# RUN:   | FileCheck --check-prefix=CHECK-FDATA %s
 
 ## Verify the bindings again on the rewritten binary with nops removed.
 
-# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized |& FileCheck %s
+# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized 2>&1 | FileCheck %s
 
 # CHECK:      BOLT-INFO: Linux kernel binary detected
 # CHECK:      BOLT-INFO: parsed 2 static keys jump entries
diff --git a/bolt/test/X86/pt_gnu_relro.s b/bolt/test/X86/pt_gnu_relro.s
index d7cfad5f954be5..ff897b96e09097 100644
--- a/bolt/test/X86/pt_gnu_relro.s
+++ b/bolt/test/X86/pt_gnu_relro.s
@@ -22,7 +22,7 @@
 # READELF: 04 .got
 
 # RUN: llvm-bolt %t.exe --relocs -o %t.null -v=1 \
-# RUN:   |& FileCheck --check-prefix=BOLT %s
+# RUN:   2>&1 | FileCheck --check-prefix=BOLT %s
 # BOLT: BOLT-INFO: marking .got as GNU_RELRO
 
   .globl _start
diff --git a/bolt/test/X86/unclaimed-jt-entries.s b/bolt/test/X86/unclaimed-jt-entries.s
index 2d56167286c36b..1102e4ae413e27 100644
--- a/bolt/test/X86/unclaimed-jt-entries.s
+++ b/bolt/test/X86/unclaimed-jt-entries.s
@@ -18,7 +18,7 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
 # RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q
-# RUN: llvm-bolt %t.exe -v=1 -o %t.out |& FileCheck %s
+# RUN: llvm-bolt %t.exe -v=1 -o %t.out 2>&1 | FileCheck %s
 
 # CHECK: BOLT-WARNING: unclaimed data to code reference (possibly an unrecognized jump table entry) to .Ltmp[[#]] in main
 # CHECK: BOLT-WARNING: unclaimed data to code reference (possibly an unrecognized jump table entry) to .Ltmp[[#]] in main
diff --git a/bolt/test/X86/vararg.test b/bolt/test/X86/vararg.test
index 0b8668a842ed4d..296c739c6e1138 100644
--- a/bolt/test/X86/vararg.test
+++ b/bolt/test/X86/vararg.test
@@ -5,7 +5,7 @@
 REQUIRES: x86_64-linux
 
 RUN: %clangxx %cxxflags -no-pie %p/../Inputs/vararg.s -o %t -Wl,-q
-RUN: llvm-bolt %t -o %t.null --print-cfg --print-only=.*printf.* |& FileCheck %s
+RUN: llvm-bolt %t -o %t.null --print-cfg --print-only=.*printf.* 2>&1 | FileCheck %s
 
 CHECK: IsSimple    : 0
 CHECK: Entry Point
diff --git a/bolt/test/runtime/X86/unclaimed-jt-entries.s b/bolt/test/runtime/X86/unclaimed-jt-entries.s
index d0691d256ba045..1725fb808efbff 100644
--- a/bolt/test/runtime/X86/unclaimed-jt-entries.s
+++ b/bolt/test/runtime/X86/unclaimed-jt-entries.s
@@ -18,7 +18,7 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
 # RUN: %clang %cflags %S/Inputs/unclaimed-jt-entries.c -no-pie %t.o -o %t.exe -Wl,-q
-# RUN: llvm-bolt %t.exe -v=1 -o %t.out --sequential-disassembly |& FileCheck %s
+# RUN: llvm-bolt %t.exe -v=1 -o %t.out --sequential-disassembly 2>&1 | FileCheck %s
 
 # CHECK: BOLT-WARNING: unclaimed data to code reference (possibly an unrecognized jump table entry) to .Ltmp[[#]] in func
 # CHECK: BOLT-WARNING: unclaimed data to code reference (possibly an unrecognized jump table entry) to .Ltmp[[#]] in func

@connieyzhu
Copy link
Contributor Author

CC: @ilovepi @petrhosek

@yota9
Copy link
Member

yota9 commented Aug 9, 2024

Hi. I'm not too deep in lit internal shell thematics, but it won't prevent on creating new tests with 2>&1 syntax. Is there any reason that 2>&1 is not supported by lit shell? Maybe it should be fixed there?

@ilovepi
Copy link
Contributor

ilovepi commented Aug 9, 2024

Hi. I'm not too deep in lit internal shell thematics, but it won't prevent on creating new tests with 2>&1 syntax. Is there any reason that 2>&1 is not supported by lit shell? Maybe it should be fixed there?

2>&1 is supported. This change removes the bashism |&, and replaces it w/ 2>&1, unless I've misunderstood.

Copy link
Contributor

@ilovepi ilovepi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but let's have a BOLT maintainer weigh in just to be safe. This is the only occurrence of |& in the entire project, so it should be safe to replace w/ the spelling we use in the rest of LLVM.

@ilovepi
Copy link
Contributor

ilovepi commented Aug 9, 2024

Also, this is related to this RFC: https://discourse.llvm.org/t/rfc-enabling-the-lit-internal-shell-by-default/80179

Removing |& was specifically called out by other contributors to be replaced. @connieyzhu I'd suggest mentioning that in the commit message.

@yota9
Copy link
Member

yota9 commented Aug 10, 2024

Hi. I'm not too deep in lit internal shell thematics, but it won't prevent on creating new tests with 2>&1 syntax. Is there any reason that 2>&1 is not supported by lit shell? Maybe it should be fixed there?

2>&1 is supported. This change removes the bashism |&, and replaces it w/ 2>&1, unless I've misunderstood.

Haha, it's better to just go sleep at nights, I meant the opposite of course :)

Also, this is related to this RFC: https://discourse.llvm.org/t/rfc-enabling-the-lit-internal-shell-by-default/80179

Thanks for the link!

Copy link
Contributor

@maksfb maksfb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@ilovepi ilovepi merged commit 887f700 into llvm:main Aug 13, 2024
9 checks passed
@connieyzhu connieyzhu deleted the bolt-redirection branch August 20, 2024 17:28
qiaojbao pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Aug 29, 2024
…0653ec5af

Local branch amd-gfx 3ae0653 Merged main:b10ecfa914dd1bc2013584917d0505ba5f15f75c into amd-gfx:8182b88afaa8
Remote branch main 887f700 [NFC][bolt][test] Change |& to 2>&1 | for lit internal shell support (llvm#102402)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[llvm-lit] Unsupported |& redirection syntax in lit internal shell
6 participants