CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
47 lines
1.8 KiB
C++
47 lines
1.8 KiB
C++
// RUN: %clangxx_nsan -O2 %s -o %t
|
|
// RUN: %run %t 2>&1 | FileCheck %s
|
|
|
|
// RUN: %clangxx_nsan -fno-builtin -O2 %s -o %t
|
|
// RUN: %run %t 2>&1 | FileCheck %s
|
|
|
|
// This verifies that shadow memory is tracked correcty across typed and
|
|
// bitcasted swaps.
|
|
|
|
#include <cassert>
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <utility>
|
|
|
|
extern "C" void __nsan_dump_shadow_mem(const char *addr, size_t size_bytes,
|
|
size_t bytes_per_line, size_t reserved);
|
|
|
|
__attribute__((noinline)) void SwapFT(double &a, double &b) {
|
|
// LLVM typically optimizes this to an untyped swap (through i64) anyway.
|
|
std::swap(a, b);
|
|
}
|
|
|
|
__attribute__((noinline)) void SwapBitcasted(uint64_t &a, uint64_t &b) {
|
|
std::swap(a, b);
|
|
}
|
|
|
|
int main() {
|
|
double a = 1.0, b = 2.0;
|
|
__nsan_dump_shadow_mem((const char *)&a, sizeof(a), sizeof(a), 0);
|
|
__nsan_dump_shadow_mem((const char *)&b, sizeof(b), sizeof(b), 0);
|
|
SwapFT(a, b);
|
|
__nsan_dump_shadow_mem((const char *)&a, sizeof(a), sizeof(a), 0);
|
|
__nsan_dump_shadow_mem((const char *)&b, sizeof(b), sizeof(b), 0);
|
|
assert(a == 2.0 && b == 1.0);
|
|
SwapBitcasted(*reinterpret_cast<uint64_t *>(&a),
|
|
*reinterpret_cast<uint64_t *>(&b));
|
|
__nsan_dump_shadow_mem((const char *)&a, sizeof(a), sizeof(a), 0);
|
|
__nsan_dump_shadow_mem((const char *)&b, sizeof(b), sizeof(b), 0);
|
|
assert(a == 1.0 && b == 2.0);
|
|
// CHECK: 0x{{[a-f0-9]*}}: d0 d1 d2 d3 d4 d5 d6 d7 (1.0{{.*}}
|
|
// CHECK-NEXT: 0x{{[a-f0-9]*}}: d0 d1 d2 d3 d4 d5 d6 d7 (2.0{{.*}}
|
|
// CHECK-NEXT: 0x{{[a-f0-9]*}}: d0 d1 d2 d3 d4 d5 d6 d7 (2.0{{.*}}
|
|
// CHECK-NEXT: 0x{{[a-f0-9]*}}: d0 d1 d2 d3 d4 d5 d6 d7 (1.0{{.*}}
|
|
// CHECK-NEXT: 0x{{[a-f0-9]*}}: d0 d1 d2 d3 d4 d5 d6 d7 (1.0{{.*}}
|
|
// CHECK-NEXT: 0x{{[a-f0-9]*}}: d0 d1 d2 d3 d4 d5 d6 d7 (2.0{{.*}}
|
|
}
|