| 1 |
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-attributes --check-globals all --version 6 |
| 2 |
// RUN: %clang_cc1 -O -fexperimental-sanitize-metadata=covered -fexperimental-sanitize-metadata=atomics -fexperimental-sanitize-metadata=uar -triple x86_64-gnu-linux -x c -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK |
| 3 |
|
| 4 |
//. |
| 5 |
// CHECK: @__start_sanmd_covered2 = extern_weak hidden global ptr |
| 6 |
// CHECK: @__stop_sanmd_covered2 = extern_weak hidden global ptr |
| 7 |
// CHECK: @__start_sanmd_atomics2 = extern_weak hidden global ptr |
| 8 |
// CHECK: @__stop_sanmd_atomics2 = extern_weak hidden global ptr |
| 9 |
// CHECK: @llvm.used = appending global [4 x ptr] [ptr @__sanitizer_metadata_covered2.module_ctor, ptr @__sanitizer_metadata_covered2.module_dtor, ptr @__sanitizer_metadata_atomics2.module_ctor, ptr @__sanitizer_metadata_atomics2.module_dtor], section "llvm.metadata" |
| 10 |
// CHECK: @llvm.global_ctors = appending global [2 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 2, ptr @__sanitizer_metadata_covered2.module_ctor, ptr @__sanitizer_metadata_covered2.module_ctor }, { i32, ptr, ptr } { i32 2, ptr @__sanitizer_metadata_atomics2.module_ctor, ptr @__sanitizer_metadata_atomics2.module_ctor }] |
| 11 |
// CHECK: @llvm.global_dtors = appending global [2 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 2, ptr @__sanitizer_metadata_covered2.module_dtor, ptr @__sanitizer_metadata_covered2.module_dtor }, { i32, ptr, ptr } { i32 2, ptr @__sanitizer_metadata_atomics2.module_dtor, ptr @__sanitizer_metadata_atomics2.module_dtor }] |
| 12 |
//. |
| 13 |
// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: none, target_mem0: none, target_mem1: none) |
| 14 |
// CHECK-LABEL: define dso_local void @escape( |
| 15 |
// CHECK-SAME: ptr noundef [[P:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] !pcsections [[META6:![0-9]+]] { |
| 16 |
// CHECK-NEXT: [[ENTRY:.*:]] |
| 17 |
// CHECK-NEXT: ret void |
| 18 |
// |
| 19 |
__attribute__((noinline, not_tail_called)) void escape(const volatile void *p) { |
| 20 |
static const volatile void *sink; |
| 21 |
sink = p; |
| 22 |
} |
| 23 |
|
| 24 |
// CHECK: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none, target_mem0: none, target_mem1: none) |
| 25 |
// CHECK-LABEL: define dso_local i32 @normal_function( |
| 26 |
// CHECK-SAME: ptr noundef [[X:%.*]], ptr noundef readonly captures(none) [[Y:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] !pcsections [[META8:![0-9]+]] { |
| 27 |
// CHECK-NEXT: [[ENTRY:.*:]] |
| 28 |
// CHECK-NEXT: [[X_ADDR:%.*]] = alloca ptr, align 8 |
| 29 |
// CHECK-NEXT: store ptr [[X]], ptr [[X_ADDR]], align 8, !tbaa [[INTPTR_TBAA10:![0-9]+]] |
| 30 |
// CHECK-NEXT: store atomic i32 1, ptr [[X]] monotonic, align 4, !pcsections [[META13:![0-9]+]] |
| 31 |
// CHECK-NEXT: notail call void @escape(ptr noundef nonnull [[X_ADDR]]) |
| 32 |
// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[Y]], align 4, !tbaa [[INT_TBAA2:![0-9]+]] |
| 33 |
// CHECK-NEXT: ret i32 [[TMP0]] |
| 34 |
// |
| 35 |
int normal_function(int *x, int *y) { |
| 36 |
__atomic_store_n(x, 1, __ATOMIC_RELAXED); |
| 37 |
escape(&x); |
| 38 |
return *y; |
| 39 |
} |
| 40 |
|
| 41 |
// CHECK: Function Attrs: disable_sanitizer_instrumentation mustprogress nofree norecurse nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none, target_mem0: none, target_mem1: none) |
| 42 |
// CHECK-LABEL: define dso_local i32 @test_disable_sanitize_instrumentation( |
| 43 |
// CHECK-SAME: ptr noundef [[X:%.*]], ptr noundef readonly captures(none) [[Y:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { |
| 44 |
// CHECK-NEXT: [[ENTRY:.*:]] |
| 45 |
// CHECK-NEXT: [[X_ADDR:%.*]] = alloca ptr, align 8 |
| 46 |
// CHECK-NEXT: store ptr [[X]], ptr [[X_ADDR]], align 8, !tbaa [[INTPTR_TBAA10]] |
| 47 |
// CHECK-NEXT: store atomic i32 1, ptr [[X]] monotonic, align 4 |
| 48 |
// CHECK-NEXT: notail call void @escape(ptr noundef nonnull [[X_ADDR]]) |
| 49 |
// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[Y]], align 4, !tbaa [[INT_TBAA2]] |
| 50 |
// CHECK-NEXT: ret i32 [[TMP0]] |
| 51 |
// |
| 52 |
__attribute__((disable_sanitizer_instrumentation)) int test_disable_sanitize_instrumentation(int *x, int *y) { |
| 53 |
__atomic_store_n(x, 1, __ATOMIC_RELAXED); |
| 54 |
escape(&x); |
| 55 |
return *y; |
| 56 |
} |
| 57 |
|
| 58 |
// CHECK: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none, target_mem0: none, target_mem1: none) |
| 59 |
// CHECK-LABEL: define dso_local i32 @test_no_sanitize_thread( |
| 60 |
// CHECK-SAME: ptr noundef [[X:%.*]], ptr noundef readonly captures(none) [[Y:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] !pcsections [[META14:![0-9]+]] { |
| 61 |
// CHECK-NEXT: [[ENTRY:.*:]] |
| 62 |
// CHECK-NEXT: [[X_ADDR:%.*]] = alloca ptr, align 8 |
| 63 |
// CHECK-NEXT: store ptr [[X]], ptr [[X_ADDR]], align 8, !tbaa [[INTPTR_TBAA10]] |
| 64 |
// CHECK-NEXT: store atomic i32 1, ptr [[X]] monotonic, align 4, !pcsections [[META13]] |
| 65 |
// CHECK-NEXT: notail call void @escape(ptr noundef nonnull [[X_ADDR]]) |
| 66 |
// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[Y]], align 4, !tbaa [[INT_TBAA2]] |
| 67 |
// CHECK-NEXT: ret i32 [[TMP0]] |
| 68 |
// |
| 69 |
__attribute__((no_sanitize("thread"))) int test_no_sanitize_thread(int *x, int *y) { |
| 70 |
__atomic_store_n(x, 1, __ATOMIC_RELAXED); |
| 71 |
escape(&x); |
| 72 |
return *y; |
| 73 |
} |
| 74 |
|
| 75 |
// CHECK: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none, target_mem0: none, target_mem1: none) |
| 76 |
// CHECK-LABEL: define dso_local i32 @test_no_sanitize_all( |
| 77 |
// CHECK-SAME: ptr noundef [[X:%.*]], ptr noundef readonly captures(none) [[Y:%.*]]) local_unnamed_addr #[[ATTR3]] !pcsections [[META14]] { |
| 78 |
// CHECK-NEXT: [[ENTRY:.*:]] |
| 79 |
// CHECK-NEXT: [[X_ADDR:%.*]] = alloca ptr, align 8 |
| 80 |
// CHECK-NEXT: store ptr [[X]], ptr [[X_ADDR]], align 8, !tbaa [[INTPTR_TBAA10]] |
| 81 |
// CHECK-NEXT: store atomic i32 1, ptr [[X]] monotonic, align 4, !pcsections [[META13]] |
| 82 |
// CHECK-NEXT: notail call void @escape(ptr noundef nonnull [[X_ADDR]]) |
| 83 |
// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[Y]], align 4, !tbaa [[INT_TBAA2]] |
| 84 |
// CHECK-NEXT: ret i32 [[TMP0]] |
| 85 |
// |
| 86 |
__attribute__((no_sanitize("all"))) int test_no_sanitize_all(int *x, int *y) { |
| 87 |
__atomic_store_n(x, 1, __ATOMIC_RELAXED); |
| 88 |
escape(&x); |
| 89 |
return *y; |
| 90 |
} |
| 91 |
//. |
| 92 |
// CHECK: attributes #[[ATTR0]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: none, target_mem0: none, target_mem1: none) "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } |
| 93 |
// CHECK: attributes #[[ATTR1]] = { mustprogress nofree norecurse nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none, target_mem0: none, target_mem1: none) "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } |
| 94 |
// CHECK: attributes #[[ATTR2]] = { disable_sanitizer_instrumentation mustprogress nofree norecurse nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none, target_mem0: none, target_mem1: none) "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } |
| 95 |
// CHECK: attributes #[[ATTR3]] = { mustprogress nofree norecurse nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none, target_mem0: none, target_mem1: none) "min-legal-vector-width"="0" "no-trapping-math"="true" "no_sanitize_thread" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } |
| 96 |
// CHECK: attributes #[[ATTR4:[0-9]+]] = { nounwind "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } |
| 97 |
//. |
| 98 |
// CHECK: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4} |
| 99 |
// CHECK: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"} |
| 100 |
// CHECK: [[INT_TBAA2]] = !{[[META3:![0-9]+]], [[META3]], i64 0} |
| 101 |
// CHECK: [[META3]] = !{!"int", [[META4:![0-9]+]], i64 0} |
| 102 |
// CHECK: [[META4]] = !{!"omnipotent char", [[META5:![0-9]+]], i64 0} |
| 103 |
// CHECK: [[META5]] = !{!"Simple C/C++ TBAA"} |
| 104 |
// CHECK: [[META6]] = !{!"sanmd_covered2!C", [[META7:![0-9]+]]} |
| 105 |
// CHECK: [[META7]] = !{i64 0} |
| 106 |
// CHECK: [[META8]] = !{!"sanmd_covered2!C", [[META9:![0-9]+]]} |
| 107 |
// CHECK: [[META9]] = !{i64 3} |
| 108 |
// CHECK: [[INTPTR_TBAA10]] = !{[[META11:![0-9]+]], [[META11]], i64 0} |
| 109 |
// CHECK: [[META11]] = !{!"p1 int", [[META12:![0-9]+]], i64 0} |
| 110 |
// CHECK: [[META12]] = !{!"any pointer", [[META4]], i64 0} |
| 111 |
// CHECK: [[META13]] = !{!"sanmd_atomics2!C"} |
| 112 |
// CHECK: [[META14]] = !{!"sanmd_covered2!C", [[META15:![0-9]+]]} |
| 113 |
// CHECK: [[META15]] = !{i64 2} |
| 114 |
//. |