1; RUN: opt < %s -mtriple aarch64-linux-android29 -hwasan -S | FileCheck %s --check-prefix=NOPERS
2; RUN: opt < %s -mtriple aarch64-linux-android30 -hwasan -S | FileCheck %s --check-prefix=PERS
3
4; NOPERS: define void @nostack() #{{[0-9]+}} {
5; PERS: define void @nostack() #{{[0-9]+}} {
6define void @nostack() sanitize_hwaddress {
7  ret void
8}
9
10; NOPERS: define void @stack1() #{{[0-9]+}} {
11; PERS: personality {{.*}} @__hwasan_personality_thunk
12define void @stack1() sanitize_hwaddress {
13  %p = alloca i8
14  call void @sink(i8* %p)
15  ret void
16}
17
18
19; NOPERS: personality void ()* @global
20; PERS: personality {{.*}} @__hwasan_personality_thunk.global
21define void @stack2() sanitize_hwaddress personality void ()* @global {
22  %p = alloca i8
23  call void @sink(i8* %p)
24  ret void
25}
26
27define internal void @local() {
28  ret void
29}
30
31@local_alias = internal alias void (), void ()* @local
32
33; NOPERS: personality void ()* @local
34; PERS: personality {{.*}} @__hwasan_personality_thunk.local
35define void @stack3() sanitize_hwaddress personality void ()* @local {
36  %p = alloca i8
37  call void @sink(i8* %p)
38  ret void
39}
40
41; NOPERS: personality void ()* @local_alias
42; PERS: personality {{.*}} @__hwasan_personality_thunk.local_alias
43define void @stack4() sanitize_hwaddress personality void ()* @local_alias {
44  %p = alloca i8
45  call void @sink(i8* %p)
46  ret void
47}
48
49; NOPERS: personality void ()* inttoptr (i64 1 to void ()*)
50; PERS: personality i32 (i32, i32, i64, i8*, i8*)* @__hwasan_personality_thunk.
51define void @stack5() sanitize_hwaddress personality void ()* inttoptr (i64 1 to void ()*) {
52  %p = alloca i8
53  call void @sink(i8* %p)
54  ret void
55}
56
57; NOPERS: personality void ()* inttoptr (i64 2 to void ()*)
58; PERS: personality i32 (i32, i32, i64, i8*, i8*)* @__hwasan_personality_thunk..1
59define void @stack6() sanitize_hwaddress personality void ()* inttoptr (i64 2 to void ()*) {
60  %p = alloca i8
61  call void @sink(i8* %p)
62  ret void
63}
64
65declare void @global()
66declare void @sink(i8*)
67
68; PERS: define linkonce_odr hidden i32 @__hwasan_personality_thunk(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4) comdat
69; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4, i8* null, i8* bitcast (void ()* @_Unwind_GetGR to i8*), i8* bitcast (void ()* @_Unwind_GetCFA to i8*))
70; PERS: ret i32 %5
71
72; PERS: define linkonce_odr hidden i32 @__hwasan_personality_thunk.global(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4) comdat
73; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4, i8* bitcast (void ()* @global to i8*), i8* bitcast (void ()* @_Unwind_GetGR to i8*), i8* bitcast (void ()* @_Unwind_GetCFA to i8*))
74; PERS: ret i32 %5
75
76; PERS: define internal i32 @__hwasan_personality_thunk.local(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4)
77; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4, i8* bitcast (void ()* @local to i8*), i8* bitcast (void ()* @_Unwind_GetGR to i8*), i8* bitcast (void ()* @_Unwind_GetCFA to i8*))
78; PERS: ret i32 %5
79
80; PERS: define internal i32 @__hwasan_personality_thunk.local_alias(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4)
81; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4, i8* bitcast (void ()* @local_alias to i8*), i8* bitcast (void ()* @_Unwind_GetGR to i8*), i8* bitcast (void ()* @_Unwind_GetCFA to i8*))
82; PERS: ret i32 %5
83
84; PERS: define internal i32 @__hwasan_personality_thunk.(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4) {
85; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4, i8* inttoptr (i64 1 to i8*), i8* bitcast (void ()* @_Unwind_GetGR to i8*), i8* bitcast (void ()* @_Unwind_GetCFA to i8*))
86; PERS: ret i32 %5
87
88; PERS: define internal i32 @__hwasan_personality_thunk..1(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4) {
89; PERS: %5 = tail call i32 @__hwasan_personality_wrapper(i32 %0, i32 %1, i64 %2, i8* %3, i8* %4, i8* inttoptr (i64 2 to i8*), i8* bitcast (void ()* @_Unwind_GetGR to i8*), i8* bitcast (void ()* @_Unwind_GetCFA to i8*))
90; PERS: ret i32 %5
91