[llvm-branch-commits] [clang] [Clang] Enable UBSan for AMDGPU device offload (PR #219973)
Joseph Huber via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Sep 6 05:17:41 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
----------------
jhuber6 wrote:
An attempt to show how the new UBSan library is only used for offloading jobs so it's non-invasive. I can remove it, but I think this one would fail quite reliably if it stopped being the case.
https://github.com/llvm/llvm-project/pull/219973
More information about the llvm-branch-commits
mailing list