[clang] [compiler-rt] [ubsan] Limit _BitInt ubsan tests to x86-64 platform only (PR #104494)

via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 15 13:07:46 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: None (earnol)

<details>
<summary>Changes</summary>

The patch https://github.com/llvm/llvm-project/pull/104462 broke Sun Solaris build.
Limit the tests to the tested platform only.

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


3 Files Affected:

- (modified) clang/test/CodeGen/bit-int-ubsan.c (+2-20) 
- (modified) compiler-rt/test/ubsan/TestCases/Integer/bit-int-pass.c (+1) 
- (modified) compiler-rt/test/ubsan/TestCases/Integer/bit-int.c (+1) 


``````````diff
diff --git a/clang/test/CodeGen/bit-int-ubsan.c b/clang/test/CodeGen/bit-int-ubsan.c
index 35f96963c181d1..10c0d8a23f8f97 100644
--- a/clang/test/CodeGen/bit-int-ubsan.c
+++ b/clang/test/CodeGen/bit-int-ubsan.c
@@ -1,11 +1,9 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang -Wno-constant-conversion -Wno-array-bounds -Wno-division-by-zero -Wno-shift-negative-value -Wno-shift-count-negative -Wno-int-to-pointer-cast -fsanitize=array-bounds,enum,float-cast-overflow,integer-divide-by-zero,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation,implicit-integer-sign-change,unsigned-integer-overflow,signed-integer-overflow,shift-base,shift-exponent -O0 -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -Wno-constant-conversion -Wno-array-bounds -Wno-division-by-zero -Wno-shift-negative-value -Wno-shift-count-negative -Wno-int-to-pointer-cast -fsanitize=array-bounds,enum,float-cast-overflow,integer-divide-by-zero,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation,implicit-integer-sign-change,unsigned-integer-overflow,signed-integer-overflow,shift-base,shift-exponent -O0 -emit-llvm -o - %s | FileCheck %s
 
 // The runtime test checking the _BitInt ubsan feature is located in compiler-rt/test/ubsan/TestCases/Integer/bit-int.c
 
-#include <stdint.h>
-#include <stdio.h>
-
+typedef unsigned int uint32_t;
 uint32_t float_divide_by_zero() {
   float f = 1.0f / 0.0f;
   // CHECK: constant { i16, i16, [8 x i8] } { i16 1, i16 32, [8 x i8] c"'float'\00" }
@@ -78,19 +76,3 @@ uint32_t negative_shift5(unsigned _BitInt(37) x)
   return x >> c;
   // CHECK: constant { i16, i16, [20 x i8] } { i16 2, i16 {{([[:xdigit:]]{2})}}, [20 x i8] c"'_BitInt(68)'\00D\00\00\00\00\00" }
 }
-
-int main(int argc, char **argv) {
-  // clang-format off
-  uint64_t result =
-      1ULL +
-      implicit_unsigned_integer_truncation() +
-      (uint32_t)array_bounds() +
-      float_cast_overflow() +
-      (uint64_t)implicit_signed_integer_truncation() +
-      negative_shift1(5) +
-      negative_shift2(5) +
-      negative_shift3(5) +
-      negative_shift5(5);
-  // clang-format on
-  printf("%u\n", (uint32_t)(result & 0xFFFFFFFF));
-}
diff --git a/compiler-rt/test/ubsan/TestCases/Integer/bit-int-pass.c b/compiler-rt/test/ubsan/TestCases/Integer/bit-int-pass.c
index a25428f0eb872f..2255d2d08c7661 100644
--- a/compiler-rt/test/ubsan/TestCases/Integer/bit-int-pass.c
+++ b/compiler-rt/test/ubsan/TestCases/Integer/bit-int-pass.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86_64-target-arch
 // RUN: %clang -Wno-constant-conversion -Wno-array-bounds -Wno-division-by-zero -Wno-shift-negative-value -Wno-shift-count-negative -Wno-int-to-pointer-cast -O0 -fsanitize=alignment,array-bounds,bool,float-cast-overflow,implicit-integer-sign-change,implicit-signed-integer-truncation,implicit-unsigned-integer-truncation,integer-divide-by-zero,nonnull-attribute,null,nullability-arg,nullability-assign,nullability-return,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,unsigned-integer-overflow,unsigned-shift-base,vla-bound %s -o %t1 && %run %t1 2>&1 | FileCheck %s
 
 #include <stdint.h>
diff --git a/compiler-rt/test/ubsan/TestCases/Integer/bit-int.c b/compiler-rt/test/ubsan/TestCases/Integer/bit-int.c
index 18dc10bf3a3889..27a919b09946ae 100644
--- a/compiler-rt/test/ubsan/TestCases/Integer/bit-int.c
+++ b/compiler-rt/test/ubsan/TestCases/Integer/bit-int.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86_64-target-arch
 // RUN: %clang -Wno-constant-conversion -Wno-array-bounds -Wno-division-by-zero -Wno-shift-negative-value -Wno-shift-count-negative -Wno-int-to-pointer-cast -O0 -fsanitize=array-bounds,float-cast-overflow,implicit-integer-sign-change,implicit-signed-integer-truncation,implicit-unsigned-integer-truncation,integer-divide-by-zero,pointer-overflow,shift-base,shift-exponent,signed-integer-overflow,unsigned-integer-overflow,unsigned-shift-base,vla-bound %s -o %t1 && %run %t1 2>&1 | FileCheck %s
 
 #include <stdint.h>

``````````

</details>


https://github.com/llvm/llvm-project/pull/104494


More information about the cfe-commits mailing list