<commit_before>; Test that global metadata is placed in a separate section on Mach-O platforms,
; allowing dead stripping to be performed, and that the appropriate runtime
; routines are invoked.

; RUN: opt < %s -asan -asan-module -S | FileCheck %s

target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.11.0"

@global = global [1 x i32] zeroinitializer, align 4

!llvm.asan.globals = !{!0}

!0 = !{[1 x i32]* @global, !1, !"global", i1 false, i1 false}
!1 = !{!"test-globals.c", i32 1, i32 5}


; Test that there is a Needle global variable:
; CHECK: @__asan_needle = internal global i64 0

; Find the metadata for @global:
; CHECK: [[METADATA:@[0-9]+]] = internal global {{.*}} @global {{.*}} section "__DATA,__asan_globals,regular", align 1

; Find the liveness binder for @global and its metadata:
; CHECK: @{{[0-9]+}} = internal global {{.*}} @global {{.*}} [[METADATA]] {{.*}} section "__DATA,__asan_liveness,regular,live_support"

; Test that __asan_apply_to_globals is invoked from the constructor:
; CHECK-LABEL: define internal void @asan.module_ctor
; CHECK-NOT: ret
; CHECK: call void @__asan_apply_to_globals(i64 ptrtoint (void (i64, i64)* @__asan_register_globals to i64), i64 ptrtoint (i64* @__asan_needle to i64))
; CHECK: ret

; Test that __asan_apply_to_globals is invoked from the destructor:
; CHECK-LABEL: define internal void @asan.module_dtor
; CHECK-NOT: ret
; CHECK: call void @__asan_apply_to_globals(i64 ptrtoint (void (i64, i64)* @__asan_unregister_globals to i64), i64 ptrtoint (i64* @__asan_needle to i64))
; CHECK: ret<commit_msg>[asan] Fix testcase for r264645<commit_after>; Test that global metadata is placed in a separate section on Mach-O platforms,
; allowing dead stripping to be performed, and that the appropriate runtime
; routines are invoked.

; RUN: opt < %s -asan -asan-module -S | FileCheck %s

target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.11.0"

@global = global [1 x i32] zeroinitializer, align 4

!llvm.asan.globals = !{!0}

!0 = !{[1 x i32]* @global, !1, !"global", i1 false, i1 false}
!1 = !{!"test-globals.c", i32 1, i32 5}


; Test that there is the flag global variable:
; CHECK: @__asan_globals_registered = common global i64 0

; Find the metadata for @global:
; CHECK: [[METADATA:@[0-9]+]] = internal global {{.*}} @global {{.*}} section "__DATA,__asan_globals,regular", align 1

; Find the liveness binder for @global and its metadata:
; CHECK: @{{[0-9]+}} = internal global {{.*}} @global {{.*}} [[METADATA]] {{.*}} section "__DATA,__asan_liveness,regular,live_support"

; Test that __asan_register_image_globals is invoked from the constructor:
; CHECK-LABEL: define internal void @asan.module_ctor
; CHECK-NOT: ret
; CHECK: call void @__asan_register_image_globals(i64 ptrtoint (i64* @__asan_globals_registered to i64))
; CHECK: ret

; Test that __asan_unregister_image_globals is invoked from the destructor:
; CHECK-LABEL: define internal void @asan.module_dtor
; CHECK-NOT: ret
; CHECK: call void @__asan_unregister_image_globals(i64 ptrtoint (i64* @__asan_globals_registered to i64))
; CHECK: ret
{'fraction_non_alphanumeric': 0.13725490196078433, 'fraction_numerical': 0.04933586337760911, 'mean_word_length': 5.238658777120316, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3401965', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1110, 'n_words': 351}