Skip to content

Commit aaab7e9

Browse files
authored
[DeviceMSAN] fix origin check e2e tests (#19137)
With non -O0, the call stack is not preserved, like malloc_shared will be inlined, the call stack would be like ``` #0 in int* sycl::_V1::malloc_host<int>(unsigned long, sycl::_V1::context const&, sycl::_V1::property_list const&, sycl::_V1::detail::code_location const&) /tmp/syclws/include/sycl/usm.hpp:215:27 #1 in ?? (/lib/x86_64-linux-gnu/libc.so.6+0x757867a2a1c9) #2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x757867a2a28a) ``` instead of ``` #0 in int* sycl::_V1::malloc_host<int>(unsigned long, sycl::_V1::context const&, sycl::_V1::property_list const&, sycl::_V1::detail::code_location const&) /tmp/syclws/include/sycl/usm.hpp:215:27 #1 in int* sycl::_V1::malloc_host<int>(unsigned long, sycl::_V1::queue const&, sycl::_V1::property_list const&, sycl::_V1::detail::code_location const&) /tmp/syclws/include/sycl/usm.hpp:223:10 #2 in main /tmp/syclws/llvm/sycl/test-e2e/MemorySanitizer/track-origins/check_host_usm_initialized_on_host.cpp:15:17 #3 in ?? (/lib/x86_64-linux-gnu/libc.so.6+0x7a67f842a1c9) #4 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x7a67f842a28a) ``` Also, add env to every %{run} directive to make sure they are not affected by system env.
1 parent ea4d084 commit aaab7e9

File tree

6 files changed

+25
-19
lines changed

6 files changed

+25
-19
lines changed

sycl/test-e2e/MemorySanitizer/track-origins/check_host_usm.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// REQUIRES: linux, cpu || (gpu && level_zero)
2-
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O0 -g -o %t2.out
3-
// RUN: %{run} %t2.out 2>&1 | FileCheck %s
2+
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O0 -g -o %t1.out
3+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t1.out 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-ORIGIN-STACK
44
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O1 -g -o %t2.out
5-
// RUN: %{run} %t2.out 2>&1 | FileCheck %s
5+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t2.out 2>&1 | FileCheck %s --check-prefixes CHECK
66
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O2 -g -o %t3.out
7-
// RUN: %{run} %t3.out 2>&1 | FileCheck %s
7+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t3.out 2>&1 | FileCheck %s --check-prefixes CHECK
88
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:0 %{run} %t3.out 2>&1 | FileCheck %s --check-prefixes CHECK-HOSTUSM
99

1010
#include <sycl/detail/core.hpp>
@@ -25,7 +25,7 @@ int main() {
2525
// CHECK: kernel <{{.*MyKernel}}>
2626
// CHECK: #{{.*}} {{.*check_host_usm.cpp}}:[[@LINE-6]]
2727
// CHECK: ORIGIN: Host USM allocation
28-
// CHECK: #{{.*}} {{.*check_host_usm.cpp}}:[[@LINE-11]]
28+
// CHECK-ORIGIN-STACK: #{{.*}} {{.*check_host_usm.cpp}}:[[@LINE-11]]
2929
// CHECK-HOSTUSM-NOT: use-of-uninitialized-value
3030

3131
sycl::free(array, Q);

sycl/test-e2e/MemorySanitizer/track-origins/check_host_usm_initialized_on_host.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// REQUIRES: linux, cpu || (gpu && level_zero)
2+
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O0 -g -o %t0.out
3+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t0.out 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-ORIGIN-STACK
24
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O2 -g -o %t1.out
3-
// RUN: %{run} %t1.out 2>&1 | FileCheck %s
5+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t1.out 2>&1 | FileCheck %s
46
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:0 %{run} %t1.out 2>&1 | FileCheck %s --check-prefixes CHECK-HOSTUSM
57

68
#include <sycl/detail/core.hpp>
@@ -22,7 +24,7 @@ int main() {
2224
// CHECK: kernel <{{.*MyKernel}}>
2325
// CHECK: #{{.*}} {{.*check_host_usm_initialized_on_host.cpp}}:[[@LINE-6]]
2426
// CHECK: ORIGIN: Host USM allocation
25-
// CHECK: #{{.*}} {{.*check_host_usm_initialized_on_host.cpp}}:[[@LINE-12]]
27+
// CHECK-ORIGIN-STACK: #{{.*}} {{.*check_host_usm_initialized_on_host.cpp}}:[[@LINE-12]]
2628
// CHECK-HOSTUSM-NOT: use-of-uninitialized-value
2729

2830
sycl::free(array, Q);

sycl/test-e2e/MemorySanitizer/track-origins/check_kernel_memcpy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// REQUIRES: linux, cpu || (gpu && level_zero)
22
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O2 -g -o %t1.out
3-
// RUN: %{run} %t1.out 2>&1 | FileCheck %s
3+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t1.out 2>&1 | FileCheck %s
44
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -DINIT_SOURCE -O2 -g -o %t2.out
5-
// RUN: %{run} %t2.out 2>&1 | FileCheck %s --check-prefixes CHECK-INIT
5+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t2.out 2>&1 | FileCheck %s --check-prefixes CHECK-INIT
66

77
#include <sycl/detail/core.hpp>
88
#include <sycl/usm.hpp>

sycl/test-e2e/MemorySanitizer/track-origins/check_kernel_memmove_no_overlap.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// REQUIRES: linux, cpu || (gpu && level_zero)
2+
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O0 -g -o %t0.out
3+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t0.out 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-ORIGIN-STACK
24
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O2 -g -o %t1.out
3-
// RUN: %{run} %t1.out 2>&1 | FileCheck %s
5+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t1.out 2>&1 | FileCheck %s
46
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -DINIT_SOURCE -O2 -g -o %t2.out
5-
// RUN: %{run} %t2.out 2>&1 | FileCheck %s --check-prefixes CHECK-INIT
7+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t2.out 2>&1 | FileCheck %s --check-prefixes CHECK-INIT
68

79
#include <sycl/detail/core.hpp>
810
#include <sycl/usm.hpp>
@@ -36,7 +38,7 @@ void no_overlap() {
3638
// CHECK: kernel <{{.*MyKernel3}}>
3739
// CHECK: #{{.*}} {{.*check_kernel_memmove_no_overlap.cpp}}:[[@LINE-6]]
3840
// CHECK: ORIGIN: Host USM allocation
39-
// CHECK: #{{.*}} {{.*check_kernel_memmove_no_overlap.cpp}}:[[@LINE-24]]
41+
// CHECK-ORIGIN-STACK: #{{.*}} {{.*check_kernel_memmove_no_overlap.cpp}}:[[@LINE-24]]
4042
// CHECK-INIT-NOT: use-of-uninitialized-value
4143

4244
sycl::free(array1, Q);

sycl/test-e2e/MemorySanitizer/track-origins/check_kernel_memmove_overlap.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// REQUIRES: linux, cpu || (gpu && level_zero)
2+
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O0 -g -o %t0.out
3+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t0.out 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-ORIGIN-STACK
24
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O2 -g -o %t1.out
3-
// RUN: %{run} %t1.out 2>&1 | FileCheck %s
5+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t1.out 2>&1 | FileCheck %s
46

57
#include <sycl/detail/core.hpp>
68
#include <sycl/usm.hpp>
@@ -30,7 +32,7 @@ void overlap() {
3032
// CHECK: kernel <{{.*MyKernel2}}>
3133
// CHECK: #{{.*}} {{.*check_kernel_memmove_overlap.cpp}}:[[@LINE-6]]
3234
// CHECK: ORIGIN: Shared USM allocation
33-
// CHECK: #{{.*}} {{.*check_kernel_memmove_overlap.cpp}}:[[@LINE-20]]
35+
// CHECK-ORIGIN-STACK: #{{.*}} {{.*check_kernel_memmove_overlap.cpp}}:[[@LINE-20]]
3436

3537
sycl::free(array, Q);
3638
}

sycl/test-e2e/MemorySanitizer/track-origins/check_shared_usm.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// REQUIRES: linux, cpu || (gpu && level_zero)
2-
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O0 -g -o %t2.out
3-
// RUN: %{run} %t2.out 2>&1 | FileCheck %s
2+
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O0 -g -o %t1.out
3+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t1.out 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-ORIGIN-STACK
44
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O1 -g -o %t2.out
5-
// RUN: %{run} %t2.out 2>&1 | FileCheck %s
5+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t2.out 2>&1 | FileCheck %s
66
// RUN: %{build} %device_msan_flags -Xarch_device -fsanitize-memory-track-origins=1 -O2 -g -o %t3.out
7-
// RUN: %{run} %t3.out 2>&1 | FileCheck %s
7+
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:1 %{run} %t3.out 2>&1 | FileCheck %s
88
// RUN: env UR_LAYER_MSAN_OPTIONS=msan_check_host_and_shared_usm:0 %{run} %t3.out 2>&1 | FileCheck %s --check-prefixes CHECK-SHAREDUSM
99

1010
#include <sycl/detail/core.hpp>
@@ -25,7 +25,7 @@ int main() {
2525
// CHECK: kernel <{{.*MyKernel}}>
2626
// CHECK: #{{.*}} {{.*check_shared_usm.cpp}}:[[@LINE-6]]
2727
// CHECK: ORIGIN: Shared USM allocation
28-
// CHECK: #{{.*}} {{.*check_shared_usm.cpp}}:[[@LINE-11]]
28+
// CHECK-ORIGIN-STACK: #{{.*}} {{.*check_shared_usm.cpp}}:[[@LINE-11]]
2929
// CHECK-SHAREDUSM-NOT: use-of-uninitialized-value
3030

3131
sycl::free(array, Q);

0 commit comments

Comments
 (0)