[llvm] It is really the byte order of the target that matters (PR #107915)

Sean Perry via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 9 14:14:47 PDT 2024


https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/107915

I came across the subtly when setting up lit for z/OS and running it on a Linux on Power machine.  Linux on Power is little endian.  This was resulting in all of these tests being run even though the target triple was z/OS which is big endian.  The lit should really be checking if the target is little endian not the host.  The previous way didn't handle cross compilation while running lit.

>From 53e069a8579028993b266621cfaf1605b81bbdd3 Mon Sep 17 00:00:00 2001
From: Sean Perry <perry at ca.ibm.com>
Date: Mon, 9 Sep 2024 16:11:07 -0500
Subject: [PATCH] It is really the byte order of the target that matters

---
 llvm/test/CodeGen/Generic/allow-check.ll                | 2 +-
 llvm/test/Object/AArch64/chained-fixups-header.test     | 2 +-
 llvm/test/Object/AArch64/filetype-fileset.yaml          | 2 +-
 llvm/test/lit.cfg.py                                    | 5 ++++-
 llvm/test/tools/dsymutil/X86/reflection-dump.test       | 2 +-
 llvm/test/tools/sancov/covered_functions.test           | 2 +-
 llvm/test/tools/sancov/ignorelist.test                  | 2 +-
 llvm/test/tools/sancov/not_covered_functions.test       | 2 +-
 llvm/test/tools/sancov/print.test                       | 2 +-
 llvm/test/tools/sancov/stats.test                       | 2 +-
 llvm/test/tools/sancov/symbolize.test                   | 2 +-
 llvm/test/tools/sancov/symbolize_noskip_dead_files.test | 2 +-
 12 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/llvm/test/CodeGen/Generic/allow-check.ll b/llvm/test/CodeGen/Generic/allow-check.ll
index a08488959862ab..148ee811ea806c 100644
--- a/llvm/test/CodeGen/Generic/allow-check.ll
+++ b/llvm/test/CodeGen/Generic/allow-check.ll
@@ -1,5 +1,5 @@
 ; Avoid `!DL->isLittleEndian() && !CLI->enableBigEndian()` missmatch on PPC64BE.
-; REQUIRES: host-byteorder-little-endian
+; REQUIRES: target-byteorder-little-endian
 
 ; -global-isel=1 is unsupported.
 ; XFAIL: target=loongarch{{.*}}
diff --git a/llvm/test/Object/AArch64/chained-fixups-header.test b/llvm/test/Object/AArch64/chained-fixups-header.test
index 5bdf07a56d3609..409c1222ffa39f 100644
--- a/llvm/test/Object/AArch64/chained-fixups-header.test
+++ b/llvm/test/Object/AArch64/chained-fixups-header.test
@@ -1,4 +1,4 @@
-REQUIRES: host-byteorder-little-endian
+REQUIRES: target-byteorder-little-endian
 RUN: cat %p/../Inputs/MachO/chained-fixups.yaml \
 RUN:   | sed 's/__LINKEDIT:      00000000/__LINKEDIT:      AB000000/' \
 RUN:   | yaml2obj | not llvm-objdump --macho --dyld-info - 2>&1 \
diff --git a/llvm/test/Object/AArch64/filetype-fileset.yaml b/llvm/test/Object/AArch64/filetype-fileset.yaml
index 0f9631ff076b2f..73bb2e01db43fb 100644
--- a/llvm/test/Object/AArch64/filetype-fileset.yaml
+++ b/llvm/test/Object/AArch64/filetype-fileset.yaml
@@ -1,4 +1,4 @@
-# REQUIRES: host-byteorder-little-endian
+# REQUIRES: target-byteorder-little-endian
 # RUN: yaml2obj %s \
 # RUN:   | llvm-objdump --macho --private-header - 2>&1 \
 # RUN:   | FileCheck %s
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index 1e0dd0a7df34f1..cff6dc962e98be 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -363,7 +363,10 @@ def version_int(ver):
 ):
     config.available_features.add("llvm-64-bits")
 
-config.available_features.add("host-byteorder-" + sys.byteorder + "-endian")
+if re.match(r"(aarch64_be|arc|armeb|bpfeb|lanai|m68k|mips|mips64|powerpc|powerpc64|sparc|sparcv9|s390x|s390|tce|thumbeb)-.*", config.target_triple):
+    config.available_features.add("target-byteorder-big-endian")
+else:
+    config.available_features.add("target-byteorder-little-endian")
 
 if sys.platform in ["win32"]:
     # ExecutionEngine, no weak symbols in COFF.
diff --git a/llvm/test/tools/dsymutil/X86/reflection-dump.test b/llvm/test/tools/dsymutil/X86/reflection-dump.test
index 9cf9874f4acddd..dc58d399596145 100644
--- a/llvm/test/tools/dsymutil/X86/reflection-dump.test
+++ b/llvm/test/tools/dsymutil/X86/reflection-dump.test
@@ -12,7 +12,7 @@ RUN: llvm-objdump -s %t.dir/main.dSYM/Contents/Resources/DWARF/main | FileCheck
 RUN: dsymutil --linker parallel -oso-prepend-path=%t.dir %t.dir/main -o %t.dir/main.dSYM
 RUN: llvm-objdump -s %t.dir/main.dSYM/Contents/Resources/DWARF/main | FileCheck %s
 
-REQUIRES: host-byteorder-little-endian
+REQUIRES: target-byteorder-little-endian
 
 
 CHECK: Contents of section __DWARF,__swift5_assocty:
diff --git a/llvm/test/tools/sancov/covered_functions.test b/llvm/test/tools/sancov/covered_functions.test
index bcdfaf8879d41a..bca37bb7bdf878 100644
--- a/llvm/test/tools/sancov/covered_functions.test
+++ b/llvm/test/tools/sancov/covered_functions.test
@@ -1,4 +1,4 @@
-REQUIRES: x86-registered-target && host-byteorder-little-endian
+REQUIRES: x86-registered-target && target-byteorder-little-endian
 RUN: sancov -covered-functions %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 RUN: sancov -covered-functions -strip_path_prefix=Inputs/ %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck --check-prefix=STRIP_PATH %s
 RUN: sancov -demangle=0 -covered-functions %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck --check-prefix=NO_DEMANGLE %s
diff --git a/llvm/test/tools/sancov/ignorelist.test b/llvm/test/tools/sancov/ignorelist.test
index 01d03aed05b237..0456b9b0dc1ded 100644
--- a/llvm/test/tools/sancov/ignorelist.test
+++ b/llvm/test/tools/sancov/ignorelist.test
@@ -1,4 +1,4 @@
-REQUIRES: x86-registered-target && host-byteorder-little-endian
+REQUIRES: x86-registered-target && target-byteorder-little-endian
 RUN: sancov -covered-functions %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s --check-prefix=ALL
 RUN: sancov -covered-functions -ignorelist %p/Inputs/fun_ignorelist.txt %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 RUN: sancov -covered-functions -ignorelist %p/Inputs/src_ignorelist.txt %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.1.sancov | FileCheck --check-prefix=CHECK1 %s
diff --git a/llvm/test/tools/sancov/not_covered_functions.test b/llvm/test/tools/sancov/not_covered_functions.test
index d1b91f6e56820a..54541bbcb124bb 100644
--- a/llvm/test/tools/sancov/not_covered_functions.test
+++ b/llvm/test/tools/sancov/not_covered_functions.test
@@ -1,4 +1,4 @@
-REQUIRES: x86-registered-target && host-byteorder-little-endian
+REQUIRES: x86-registered-target && target-byteorder-little-endian
 RUN: sancov -skip-dead-files=0 -not-covered-functions %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 RUN: sancov -not-covered-functions %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.1.sancov | FileCheck --check-prefix=CHECK1 --allow-empty %s
 
diff --git a/llvm/test/tools/sancov/print.test b/llvm/test/tools/sancov/print.test
index 62ab3d991b8e3c..26bbf47f4d987e 100644
--- a/llvm/test/tools/sancov/print.test
+++ b/llvm/test/tools/sancov/print.test
@@ -1,4 +1,4 @@
-REQUIRES: x86-registered-target && host-byteorder-little-endian
+REQUIRES: x86-registered-target && target-byteorder-little-endian
 RUN: sancov -print %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 
 CHECK: 0x4e132b
diff --git a/llvm/test/tools/sancov/stats.test b/llvm/test/tools/sancov/stats.test
index 46ff6e5e5db10e..1777a6d04fed74 100644
--- a/llvm/test/tools/sancov/stats.test
+++ b/llvm/test/tools/sancov/stats.test
@@ -1,4 +1,4 @@
-REQUIRES: x86-registered-target && host-byteorder-little-endian
+REQUIRES: x86-registered-target && target-byteorder-little-endian
 RUN: sancov -print-coverage-stats %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 
 CHECK: all-edges: 8
diff --git a/llvm/test/tools/sancov/symbolize.test b/llvm/test/tools/sancov/symbolize.test
index acf58ae1171238..4ffafb7448815f 100644
--- a/llvm/test/tools/sancov/symbolize.test
+++ b/llvm/test/tools/sancov/symbolize.test
@@ -1,4 +1,4 @@
-REQUIRES: x86-registered-target && host-byteorder-little-endian
+REQUIRES: x86-registered-target && target-byteorder-little-endian
 RUN: sancov -symbolize -strip_path_prefix="llvm/" %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s --check-prefixes=CHECK,STRIP
 RUN: sancov -symbolize %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s --check-prefixes=CHECK,NOSTRIP
 
diff --git a/llvm/test/tools/sancov/symbolize_noskip_dead_files.test b/llvm/test/tools/sancov/symbolize_noskip_dead_files.test
index 0038ea197735aa..e366bdcb2ef75f 100644
--- a/llvm/test/tools/sancov/symbolize_noskip_dead_files.test
+++ b/llvm/test/tools/sancov/symbolize_noskip_dead_files.test
@@ -1,4 +1,4 @@
-REQUIRES: x86-registered-target && host-byteorder-little-endian
+REQUIRES: x86-registered-target && target-byteorder-little-endian
 RUN: sancov -symbolize -skip-dead-files=0 -strip_path_prefix="llvm/" %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 
 CHECK: {



More information about the llvm-commits mailing list