1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --global-value-regex ".*global_ctors.*" --version 5
2 ; RUN: opt < %s -passes=asan -S | FileCheck %s
3 ; RUN: opt < %s -passes=asan -S -asan-initialization-order=0 | FileCheck %s --check-prefixes=NOINIT
5 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
6 target triple = "x86_64-unknown-linux-gnu"
8 @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @__late_ctor, ptr null }]
9 @g = internal global i32 0, align 4, sanitize_address_dyninit ; With dynamic initializer.
12 ; CHECK: @llvm.global_ctors = appending global [2 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @__late_ctor, ptr null }, { i32, ptr, ptr } { i32 1, ptr @asan.module_ctor, ptr @asan.module_ctor }]
14 ; NOINIT: @llvm.global_ctors = appending global [2 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @__late_ctor, ptr null }, { i32, ptr, ptr } { i32 1, ptr @asan.module_ctor, ptr @asan.module_ctor }]
16 define i32 @initializer() uwtable {
17 ; CHECK-LABEL: define i32 @initializer(
18 ; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
19 ; CHECK-NEXT: [[ENTRY:.*:]]
20 ; CHECK-NEXT: ret i32 42
22 ; NOINIT-LABEL: define i32 @initializer(
23 ; NOINIT-SAME: ) #[[ATTR0:[0-9]+]] {
24 ; NOINIT-NEXT: [[ENTRY:.*:]]
25 ; NOINIT-NEXT: ret i32 42
31 define internal void @__cxx_global_var_init() section ".text.startup" {
32 ; CHECK-LABEL: define internal void @__cxx_global_var_init() section ".text.startup" {
33 ; CHECK-NEXT: [[ENTRY:.*:]]
34 ; CHECK-NEXT: [[CALL:%.*]] = call i32 @initializer()
35 ; CHECK-NEXT: store i32 [[CALL]], ptr @g, align 4
36 ; CHECK-NEXT: ret void
38 ; NOINIT-LABEL: define internal void @__cxx_global_var_init() section ".text.startup" {
39 ; NOINIT-NEXT: [[ENTRY:.*:]]
40 ; NOINIT-NEXT: [[CALL:%.*]] = call i32 @initializer()
41 ; NOINIT-NEXT: store i32 [[CALL]], ptr @g, align 4
42 ; NOINIT-NEXT: ret void
45 %call = call i32 @initializer()
46 store i32 %call, ptr @g, align 4
50 define internal void @__late_ctor() sanitize_address section ".text.startup" {
51 ; CHECK-LABEL: define internal void @__late_ctor(
52 ; CHECK-SAME: ) #[[ATTR1:[0-9]+]] section ".text.startup" {
53 ; CHECK-NEXT: [[ENTRY:.*:]]
54 ; CHECK-NEXT: call void @__asan_before_dynamic_init(i64 ptrtoint (ptr @___asan_gen_module to i64))
55 ; CHECK-NEXT: call void @__asan_after_dynamic_init()
56 ; CHECK-NEXT: ret void
58 ; NOINIT-LABEL: define internal void @__late_ctor(
59 ; NOINIT-SAME: ) #[[ATTR1:[0-9]+]] section ".text.startup" {
60 ; NOINIT-NEXT: [[ENTRY:.*:]]
61 ; NOINIT-NEXT: ret void