Skip to content

Add target-byteorder for cases where endian in target triple is what matters #107915

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 9 commits into from
Sep 23, 2024

Conversation

perry-ca
Copy link
Contributor

@perry-ca perry-ca commented Sep 9, 2024

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.

@llvmbot
Copy link
Member

llvmbot commented Sep 9, 2024

@llvm/pr-subscribers-debuginfo

Author: Sean Perry (perry-ca)

Changes

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.


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

12 Files Affected:

  • (modified) llvm/test/CodeGen/Generic/allow-check.ll (+1-1)
  • (modified) llvm/test/Object/AArch64/chained-fixups-header.test (+1-1)
  • (modified) llvm/test/Object/AArch64/filetype-fileset.yaml (+1-1)
  • (modified) llvm/test/lit.cfg.py (+4-1)
  • (modified) llvm/test/tools/dsymutil/X86/reflection-dump.test (+1-1)
  • (modified) llvm/test/tools/sancov/covered_functions.test (+1-1)
  • (modified) llvm/test/tools/sancov/ignorelist.test (+1-1)
  • (modified) llvm/test/tools/sancov/not_covered_functions.test (+1-1)
  • (modified) llvm/test/tools/sancov/print.test (+1-1)
  • (modified) llvm/test/tools/sancov/stats.test (+1-1)
  • (modified) llvm/test/tools/sancov/symbolize.test (+1-1)
  • (modified) llvm/test/tools/sancov/symbolize_noskip_dead_files.test (+1-1)
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: {

@llvmbot
Copy link
Member

llvmbot commented Sep 9, 2024

@llvm/pr-subscribers-llvm-binary-utilities

Author: Sean Perry (perry-ca)

Changes

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.


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

12 Files Affected:

  • (modified) llvm/test/CodeGen/Generic/allow-check.ll (+1-1)
  • (modified) llvm/test/Object/AArch64/chained-fixups-header.test (+1-1)
  • (modified) llvm/test/Object/AArch64/filetype-fileset.yaml (+1-1)
  • (modified) llvm/test/lit.cfg.py (+4-1)
  • (modified) llvm/test/tools/dsymutil/X86/reflection-dump.test (+1-1)
  • (modified) llvm/test/tools/sancov/covered_functions.test (+1-1)
  • (modified) llvm/test/tools/sancov/ignorelist.test (+1-1)
  • (modified) llvm/test/tools/sancov/not_covered_functions.test (+1-1)
  • (modified) llvm/test/tools/sancov/print.test (+1-1)
  • (modified) llvm/test/tools/sancov/stats.test (+1-1)
  • (modified) llvm/test/tools/sancov/symbolize.test (+1-1)
  • (modified) llvm/test/tools/sancov/symbolize_noskip_dead_files.test (+1-1)
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: {

Copy link

github-actions bot commented Sep 9, 2024

✅ With the latest revision this PR passed the Python code formatter.

@perry-ca
Copy link
Contributor Author

perry-ca commented Sep 9, 2024

@redstar @daltenty could you review. Thanks

Copy link
Collaborator

@jh7370 jh7370 left a comment

Choose a reason for hiding this comment

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

I can't believe that this PR is correct for all cases (I don't know enough about some of the tools to know whether it does for those ones, but certainly the yaml2obj/llvm-objdump ones are wrong).

Also, there are certainly cases where the host machine's endianness is significant to the test, because it impacts how numbers are represented in memory. If the program were to then print those numbers as bytes, rather than as their representation (or equally, if the program were to try to interpret an arbitrary set of bytes as a number without considering whether byte swapping was necessary), then the output would be different. I therefore cannot believe that removing the host-byteorder-* directives can be correct in all cases.

Please provide more explanation why in each test case (or family of related test cases) what you've done is correct.

@@ -1,4 +1,4 @@
REQUIRES: host-byteorder-little-endian
REQUIRES: target-byteorder-little-endian
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't make sense: there is no concept of default target endianness for yaml2obj as yaml2obj is target agnostic. The endianness is determined by the yaml input file's contents.

Similarly, llvm-objdump should handle both big and little endian, with the endianness determined by the input file: there's nothing for lit to check here.

@@ -1,4 +1,4 @@
# REQUIRES: host-byteorder-little-endian
# REQUIRES: target-byteorder-little-endian
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as above.

@perry-ca perry-ca changed the title It is really the byte order of the target that matters Add target-byteorder for cases where endian in target triple is what matters Sep 10, 2024
@perry-ca
Copy link
Contributor Author

I had thought that yaml2obj would have been host independent. It probably should be so you can generate object files for a target independent of what host you are running on. If it is meant to be then we might need to look deeper into these tests. The llvm/test/Object/AArch64/filetype-fileset.yaml does pass in all four variations (target big/little, host big/little). I think I had missed one variation when double checking the rest. I put the host-byteorder back in for the yaml2obj cases.

Copy link
Collaborator

@efriedma-quic efriedma-quic left a comment

Choose a reason for hiding this comment

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

I had thought that yaml2obj would have been host independent. It probably should be so you can generate object files for a target independent of what host you are running on. If it is meant to be then we might need to look deeper into these tests.

Yes, but it's orthogonal to this patch.

@@ -364,6 +364,13 @@ 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,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe stick this check under the if config.target_triple:?

Copy link
Collaborator

@jh7370 jh7370 left a comment

Choose a reason for hiding this comment

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

Thanks. I'm "approving" this, to clear my "needs changes", but somebody who understands the original test should actually still review it.

@@ -1,5 +1,5 @@
; Avoid `!DL->isLittleEndian() && !CLI->enableBigEndian()` missmatch on PPC64BE.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this comment still appropriate?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Really, what we want to check here is "does the target support globalisel", since we only want to check the behavior of -global-isel=1 on such targets. But the comment is basically correct; big-endian targets don't support globalisel (with the exception of m68k), so checking endianness is a reasonable approximation.

Copy link
Collaborator

@efriedma-quic efriedma-quic left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -1,5 +1,5 @@
; Avoid `!DL->isLittleEndian() && !CLI->enableBigEndian()` missmatch on PPC64BE.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Really, what we want to check here is "does the target support globalisel", since we only want to check the behavior of -global-isel=1 on such targets. But the comment is basically correct; big-endian targets don't support globalisel (with the exception of m68k), so checking endianness is a reasonable approximation.

@abhina-sree abhina-sree merged commit 27b5dc4 into llvm:main Sep 23, 2024
8 checks passed
@perry-ca perry-ca deleted the perry/use-target-endian branch September 25, 2024 14:52
@perry-ca perry-ca restored the perry/use-target-endian branch September 25, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants