]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
Vendor import of llvm release_40 branch r292009:
[FreeBSD/FreeBSD.git] / test / Instrumentation / AddressSanitizer / global_metadata_darwin.ll
1 ; Test that global metadata is placed in a separate section on Mach-O platforms,
2 ; allowing dead stripping to be performed, and that the appropriate runtime
3 ; routines are invoked.
4
5 ; RUN: opt < %s -asan -asan-module -S | FileCheck %s
6
7 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
8 target triple = "x86_64-apple-macosx10.11.0"
9
10 @global = global [1 x i32] zeroinitializer, align 4
11
12 !llvm.asan.globals = !{!0}
13
14 !0 = !{[1 x i32]* @global, !1, !"global", i1 false, i1 false}
15 !1 = !{!"test-globals.c", i32 1, i32 5}
16
17
18 ; Find the metadata for @global:
19 ; CHECK: [[METADATA:@.+]] = internal global {{.*}} @global {{.*}} section "__DATA,__asan_globals,regular", align 64
20
21 ; Find the liveness binder for @global and its metadata:
22 ; CHECK: @__asan_binder_global = internal global {{.*}} @global {{.*}} [[METADATA]] {{.*}} section "__DATA,__asan_liveness,regular,live_support"
23
24 ; Test that there is the flag global variable:
25 ; CHECK: @__asan_globals_registered = common hidden global i64 0
26
27 ; The binder has to be inserted to llvm.compiler.used to avoid being stripped
28 ; during LTO.
29 ; CHECK: @llvm.compiler.used {{.*}} @__asan_binder_global {{.*}} section "llvm.metadata"
30
31
32 ; Test that __asan_register_image_globals is invoked from the constructor:
33 ; CHECK-LABEL: define internal void @asan.module_ctor
34 ; CHECK-NOT: ret
35 ; CHECK: call void @__asan_register_image_globals(i64 ptrtoint (i64* @__asan_globals_registered to i64))
36 ; CHECK: ret
37
38 ; Test that __asan_unregister_image_globals is invoked from the destructor:
39 ; CHECK-LABEL: define internal void @asan.module_dtor
40 ; CHECK-NOT: ret
41 ; CHECK: call void @__asan_unregister_image_globals(i64 ptrtoint (i64* @__asan_globals_registered to i64))
42 ; CHECK: ret