[llvm] [BOLT][test] Various minor fixes (PR #117043)

Raul Tambre via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 20 12:21:48 PST 2024


https://github.com/tambry created https://github.com/llvm/llvm-project/pull/117043

Fixes for some tests that I noticed due to particularities of my setup (Clang default to C++26, GNU extensions disabled by default).

There's 3 more failing after these for which I don't see an obvious reason though:
[bolt-failing-tests.txt](https://github.com/user-attachments/files/17836334/bolt-failing-tests.txt)

If you've any ideas for these I'd be happy to also help get those fixed. :slightly_smiling_face: 

>From 2eadee2703620893f6a6e4719dafa51d235de30a Mon Sep 17 00:00:00 2001
From: Raul Tambre <raul at tambre.ee>
Date: Wed, 20 Nov 2024 22:03:52 +0200
Subject: [PATCH 1/3] [BOLT][test] Fix uses of clang C exe for C++ files

The C frontend executable will fail if there's for example a Clang resource file for the C++ mode that sets C++-specific options:
```
+ /home/tambre/dev/llvm/build/bin/clang --target=x86_64-unknown-linux-gnu -fPIE -fuse-ld=lld -Wl,--unresolved-symbols=ignore-all -pie -fPIC -shared /home/tambre/dev/llvm/bolt/test/R_ABS.pic.lld.cpp -o /home/tambre/dev/llvm/build/tools/bolt/test/Output/R_ABS.pic.lld.cpp.tmp.so -Wl,-q -fuse-ld=lld
clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
error: invalid argument '-std=c23' not allowed with 'C++'
```
---
 bolt/test/AArch64/double_jump.cpp                  | 2 +-
 bolt/test/R_ABS.pic.lld.cpp                        | 2 +-
 bolt/test/X86/double-jump.test                     | 2 +-
 bolt/test/X86/jmp-optimization.test                | 2 +-
 bolt/test/X86/match-functions-with-call-graph.test | 2 +-
 bolt/test/pie.test                                 | 2 +-
 bolt/test/runtime/bolt-reserved.cpp                | 4 ++--
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/bolt/test/AArch64/double_jump.cpp b/bolt/test/AArch64/double_jump.cpp
index d82c4e4bb8dad2..7bbc67f1af8806 100644
--- a/bolt/test/AArch64/double_jump.cpp
+++ b/bolt/test/AArch64/double_jump.cpp
@@ -1,6 +1,6 @@
 // A contrived example to test the double jump removal peephole.
 
-// RUN: %clang %cflags -O0 %s -o %t.exe
+// RUN: %clangxx %cxxflags -O0 %s -o %t.exe
 // RUN: llvm-bolt %t.exe -o %t.bolt --peepholes=double-jumps | \
 // RUN:   FileCheck %s -check-prefix=CHECKBOLT
 // RUN: llvm-objdump --no-print-imm-hex -d %t.bolt | FileCheck %s
diff --git a/bolt/test/R_ABS.pic.lld.cpp b/bolt/test/R_ABS.pic.lld.cpp
index b1396209567e20..df6143e7763a62 100644
--- a/bolt/test/R_ABS.pic.lld.cpp
+++ b/bolt/test/R_ABS.pic.lld.cpp
@@ -6,7 +6,7 @@
  * with libc available.
  * REQUIRES: system-linux
  *
- * RUN: %clang %cflags -fPIC -shared %s -o %t.so -Wl,-q -fuse-ld=lld
+ * RUN: %clangxx %cxxflags -fPIC -shared %s -o %t.so -Wl,-q -fuse-ld=lld
  * RUN: llvm-bolt %t.so -o %t.so.bolt --relocs
  */
 
diff --git a/bolt/test/X86/double-jump.test b/bolt/test/X86/double-jump.test
index 791872a2b4f896..424747c4e140bf 100644
--- a/bolt/test/X86/double-jump.test
+++ b/bolt/test/X86/double-jump.test
@@ -4,7 +4,7 @@
 ## correctly on Windows e.g. subshell execution
 REQUIRES: shell
 
-RUN: %clang %cflags %p/Inputs/double_jump.cpp -o %t.exe
+RUN: %clangxx %cxxflags %p/Inputs/double_jump.cpp -o %t.exe
 RUN: (llvm-bolt %t.exe --peepholes=double-jumps \
 RUN:   --eliminate-unreachable -o %t 2>&1 \
 RUN:   && llvm-objdump -d %t --print-imm-hex --no-show-raw-insn) | FileCheck %s
diff --git a/bolt/test/X86/jmp-optimization.test b/bolt/test/X86/jmp-optimization.test
index a98be115734162..f969578a5b1a0c 100644
--- a/bolt/test/X86/jmp-optimization.test
+++ b/bolt/test/X86/jmp-optimization.test
@@ -4,7 +4,7 @@
 ## correctly on Windows e.g. unsupported parameter expansion
 REQUIRES: shell
 
-RUN: %clang %cflags -O2 %S/Inputs/jmp_opt{,2,3}.cpp -o %t
+RUN: %clangxx %cxxflags -O2 %S/Inputs/jmp_opt{,2,3}.cpp -o %t
 RUN: llvm-bolt -inline-small-functions %t -o %t.bolt
 RUN: llvm-objdump -d %t.bolt --print-imm-hex | FileCheck %s
 
diff --git a/bolt/test/X86/match-functions-with-call-graph.test b/bolt/test/X86/match-functions-with-call-graph.test
index e826c57f35312c..fe073736865e8a 100644
--- a/bolt/test/X86/match-functions-with-call-graph.test
+++ b/bolt/test/X86/match-functions-with-call-graph.test
@@ -2,7 +2,7 @@
 
 # REQUIRES: system-linux
 # RUN: split-file %s %t
-# RUN: %clang %cflags %t/main.cpp -o %t.exe -Wl,-q -nostdlib
+# RUN: %clangxx %cxxflags %t/main.cpp -o %t.exe -Wl,-q -nostdlib
 # RUN: llvm-bolt %t.exe -o %t.out --data %t/yaml --profile-ignore-hash -v=1 \
 # RUN:   --dyno-stats --print-cfg --infer-stale-profile=1 --match-with-call-graph 2>&1 | FileCheck %s
 
diff --git a/bolt/test/pie.test b/bolt/test/pie.test
index 7c833c09bbf09b..b5c414500c930b 100644
--- a/bolt/test/pie.test
+++ b/bolt/test/pie.test
@@ -4,7 +4,7 @@
 ## on Linux systems where the host triple matches the target.
 REQUIRES: system-linux
 
-RUN: %clang %cflags -fPIC -pie %p/Inputs/jump_table_icp.cpp -o %t
+RUN: %clangxx %cxxflags -fPIC -pie %p/Inputs/jump_table_icp.cpp -o %t
 RUN: llvm-bolt %t -o %t.null 2>&1 | FileCheck %s
 
 CHECK: BOLT-INFO: shared object or position-independent executable detected
diff --git a/bolt/test/runtime/bolt-reserved.cpp b/bolt/test/runtime/bolt-reserved.cpp
index c88b1e284d074e..2ebadfea5fa028 100644
--- a/bolt/test/runtime/bolt-reserved.cpp
+++ b/bolt/test/runtime/bolt-reserved.cpp
@@ -5,7 +5,7 @@
  * new sections.
  */
 
-// RUN: %clang %s -o %t.exe -Wl,-q
+// RUN: %clangxx %s -o %t.exe -Wl,-q
 // RUN: llvm-bolt %t.exe -o %t.bolt.exe 2>&1 | FileCheck %s
 // RUN: %t.bolt.exe
 
@@ -16,7 +16,7 @@
  * not enough for allocating new sections.
  */
 
-// RUN: %clang %s -o %t.tiny.exe -Wl,--no-eh-frame-hdr -Wl,-q -DTINY
+// RUN: %clangxx %s -o %t.tiny.exe -Wl,--no-eh-frame-hdr -Wl,-q -DTINY
 // RUN: not llvm-bolt %t.tiny.exe -o %t.tiny.bolt.exe 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CHECK-TINY
 

>From c89db78f9d33948436b2aa6bbf0baa16324f6170 Mon Sep 17 00:00:00 2001
From: Raul Tambre <raul at tambre.ee>
Date: Wed, 20 Nov 2024 22:08:23 +0200
Subject: [PATCH 2/3] [BOLT][test] Don't unnecessarily pass an explicit target

The X86 directory lit config sets it already, there's no reason for this test to do it by itself.
---
 .../X86/dwarf5-df-inlined-subroutine-gc-sections-range.test     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bolt/test/X86/dwarf5-df-inlined-subroutine-gc-sections-range.test b/bolt/test/X86/dwarf5-df-inlined-subroutine-gc-sections-range.test
index 3132208475bd77..9082a8b6a4957d 100644
--- a/bolt/test/X86/dwarf5-df-inlined-subroutine-gc-sections-range.test
+++ b/bolt/test/X86/dwarf5-df-inlined-subroutine-gc-sections-range.test
@@ -6,7 +6,7 @@
 ; RUN: -split-dwarf-file=main.dwo -o main.o
 ; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-inlined-subroutine-gc-sections-range-helper.s \
 ; RUN: -split-dwarf-file=helper.dwo -o helper.o
-; RUN: %clang --target=x86_64-pc-linux -fuse-ld=lld -Wl,-gc-sections -Wl,-q -gdwarf-5 -gsplit-dwarf=split main.o helper.o -o main.exe
+; RUN: %clang -fuse-ld=lld -Wl,-gc-sections -Wl,-q -gdwarf-5 -gsplit-dwarf=split main.o helper.o -o main.exe
 ; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
 ; RUN: llvm-dwarfdump --debug-addr main.exe > log.txt
 ; RUN: llvm-dwarfdump --debug-rnglists --verbose --show-form main.dwo >> log.txt

>From c07a65b8f595a22bfe03aa8feda959a8509738b5 Mon Sep 17 00:00:00 2001
From: Raul Tambre <raul at tambre.ee>
Date: Wed, 20 Nov 2024 22:17:26 +0200
Subject: [PATCH 3/3] [BOLT][test] Enable GNU extensions where necessary

With a Clang that doesn't default to GNU extensions they need to be enabled explicitly.
---
 bolt/test/AArch64/data-at-0-offset.c             | 2 +-
 bolt/test/runtime/X86/instrumentation-indirect.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bolt/test/AArch64/data-at-0-offset.c b/bolt/test/AArch64/data-at-0-offset.c
index e0c689a19bedd4..01248a637d393b 100644
--- a/bolt/test/AArch64/data-at-0-offset.c
+++ b/bolt/test/AArch64/data-at-0-offset.c
@@ -1,4 +1,4 @@
-// RUN: %clang %cflags -O2 -fPIE -Wl,-q -pie  %s -o %t.exe
+// RUN: %clang %cflags -O2 -fPIE -std=gnu99 -Wl,-q -pie  %s -o %t.exe
 // RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
 // CHECK-NOT: BOLT-WARNING: unable to disassemble instruction at offset
 
diff --git a/bolt/test/runtime/X86/instrumentation-indirect.c b/bolt/test/runtime/X86/instrumentation-indirect.c
index 5f02a6020c74be..634240c3698239 100644
--- a/bolt/test/runtime/X86/instrumentation-indirect.c
+++ b/bolt/test/runtime/X86/instrumentation-indirect.c
@@ -38,7 +38,7 @@ int main(int argc, char **argv) {
 /*
 REQUIRES: system-linux,bolt-runtime,lit-max-individual-test-time
 
-RUN: %clang %cflags %s -o %t.exe -Wl,-q -pie -fpie
+RUN: %clang %cflags -D_GNU_SOURCE %s -o %t.exe -Wl,-q -pie -fpie
 
 RUN: llvm-bolt %t.exe --instrument --instrumentation-file=%t.fdata \
 RUN:   --instrumentation-wait-forks=1 --conservative-instrumentation \



More information about the llvm-commits mailing list