[llvm-branch-commits] [clang] [Clang] Enable UBSan for AMDGPU device offload (PR #219973)

Matt Arsenault via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Sep 5 11:58:01 PDT 2026


================
@@ -0,0 +1,92 @@
+// RUN: %clang -no-canonical-prefixes -### --target=x86_64-unknown-linux-gnu \
+// RUN:     -fopenmp=libomp --offload-arch=gfx908 -fsanitize=undefined -nogpuinc \
+// RUN:     --rocm-path=%S/Inputs/rocm \
+// RUN:     -resource-dir=%S/Inputs/resource_dir_with_amdgpu_per_target_subdir %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-OPENMP
+// CHECK-OPENMP-DAG: "--device-compiler=amdgpu-amd-amdhsa=-fsanitize=undefined"
+// CHECK-OPENMP-DAG: "-u" "__ubsan_offload_init"
+// CHECK-OPENMP-DAG: "{{[^"]*}}x86_64-unknown-linux-gnu{{/|\\\\}}libclang_rt.ubsan_offload.a"
+
+// RUN: %clang -no-canonical-prefixes -### --target=x86_64-unknown-linux-gnu \
+// RUN:     -x hip --offload-arch=gfx908 -fsanitize=undefined -nogpuinc -nogpulib \
+// RUN:     --rocm-path=%S/Inputs/rocm \
+// RUN:     -resource-dir=%S/Inputs/resource_dir_with_amdgpu_per_target_subdir %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-HIP-HOST
+// CHECK-HIP-HOST-DAG: "-u" "__ubsan_offload_init"
+// CHECK-HIP-HOST-DAG: "{{[^"]*}}x86_64-unknown-linux-gnu{{/|\\\\}}libclang_rt.ubsan_offload.a"
+
+// RUN: %clang -no-canonical-prefixes -### --target=x86_64-unknown-linux-gnu \
+// RUN:     -x hip --offload-arch=gfx908 -Xarch_device -fsanitize=undefined \
+// RUN:     -nogpuinc -nogpulib --rocm-path=%S/Inputs/rocm \
+// RUN:     -resource-dir=%S/Inputs/resource_dir_with_amdgpu_per_target_subdir %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-XARCH-DEV
+// CHECK-XARCH-DEV-DAG: "-u" "__ubsan_offload_init"
+// CHECK-XARCH-DEV-DAG: "{{[^"]*}}x86_64-unknown-linux-gnu{{/|\\\\}}libclang_rt.ubsan_offload.a"
+// CHECK-XARCH-DEV-DAG: "{{[^"]*}}x86_64-unknown-linux-gnu{{/|\\\\}}libclang_rt.ubsan_standalone.a"
+
+// RUN: %clang -no-canonical-prefixes -### --target=x86_64-unknown-linux-gnu \
+// RUN:     -x hip --offload-arch=gfx908 -Xarch_host -fsanitize=undefined \
+// RUN:     -nogpuinc -nogpulib --rocm-path=%S/Inputs/rocm \
+// RUN:     -resource-dir=%S/Inputs/resource_dir_with_amdgpu_per_target_subdir %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-XARCH-HOST
+// CHECK-XARCH-HOST-NOT: ubsan_offload
+// CHECK-XARCH-HOST-NOT: __ubsan_offload_init
+
+// RUN: %clang -no-canonical-prefixes -### --target=x86_64-unknown-linux-gnu \
+// RUN:     -fsanitize=undefined \
+// RUN:     -resource-dir=%S/Inputs/resource_dir_with_amdgpu_per_target_subdir %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-HOST
+// CHECK-HOST-NOT: ubsan_offload
+// CHECK-HOST-NOT: __ubsan_offload_init
----------------
arsenm wrote:

I don't think this really tests anything useful, it's not using the amdgpu toolchains and -NOT checks are fragile 

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


More information about the llvm-branch-commits mailing list