1 ; clang -target aarch64-eabi -O2 -march=armv8.5-a+memtag -fsanitize=memtag -S -emit-llvm test.cc
8 ; __asm volatile("" : : "r"(&A0));
27 ; RUN: opt -S -aarch64-stack-tagging %s -o - | FileCheck %s
29 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
30 target triple = "aarch64"
32 @_ZTIi = external dso_local constant ptr
34 ; Function Attrs: noreturn sanitize_memtag
35 define dso_local void @_Z3barv() local_unnamed_addr #0 {
37 %exception = tail call ptr @__cxa_allocate_exception(i64 4) #4
38 store i32 42, ptr %exception, align 16, !tbaa !2
39 tail call void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null) #5
43 declare dso_local ptr @__cxa_allocate_exception(i64) local_unnamed_addr
45 declare dso_local void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr
47 ; Function Attrs: noreturn sanitize_memtag
48 define dso_local void @_Z3foov() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
50 %A0 = alloca i32, align 4
51 call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %A0) #4
52 call void asm sideeffect "", "r"(ptr nonnull %A0) #4, !srcloc !6
53 invoke void @_Z3barv()
54 to label %try.cont unwind label %lpad
56 lpad: ; preds = %entry
57 %0 = landingpad { ptr, i32 }
60 %1 = extractvalue { ptr, i32 } %0, 1
61 %2 = call i32 @llvm.eh.typeid.for(ptr @_ZTIi) #4
62 %matches = icmp eq i32 %1, %2
63 br i1 %matches, label %catch, label %ehcleanup
65 catch: ; preds = %lpad
66 %3 = extractvalue { ptr, i32 } %0, 0
67 %4 = call ptr @__cxa_begin_catch(ptr %3) #4
68 call void @__cxa_end_catch() #4
71 try.cont: ; preds = %entry, %catch
72 %exception = call ptr @__cxa_allocate_exception(i64 4) #4
73 store i32 15532, ptr %exception, align 16, !tbaa !2
74 call void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null) #5
77 ehcleanup: ; preds = %lpad
78 call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %A0) #4
79 resume { ptr, i32 } %0
82 ; Function Attrs: argmemonly nounwind willreturn
83 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
85 declare dso_local i32 @__gxx_personality_v0(...)
87 ; Function Attrs: nounwind readnone
88 declare i32 @llvm.eh.typeid.for(ptr) #2
90 declare dso_local ptr @__cxa_begin_catch(ptr) local_unnamed_addr
92 declare dso_local void @__cxa_end_catch() local_unnamed_addr
94 ; Function Attrs: argmemonly nounwind willreturn
95 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
97 ; Function Attrs: norecurse sanitize_memtag
98 define dso_local i32 @main() local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
100 ; CHECK-LABEL: entry:
101 %A0.i = alloca i32, align 4
102 call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %A0.i) #4
103 call void asm sideeffect "", "r"(ptr nonnull %A0.i) #4, !srcloc !6
104 ; CHECK: call void @llvm.aarch64.settag(ptr %A0.i.tag, i64 16)
105 ; CHECK-NEXT: call void asm sideeffect
106 %exception.i6 = call ptr @__cxa_allocate_exception(i64 4) #4
107 store i32 42, ptr %exception.i6, align 16, !tbaa !2
108 invoke void @__cxa_throw(ptr %exception.i6, ptr @_ZTIi, ptr null) #5
109 to label %.noexc7 unwind label %lpad.i
111 .noexc7: ; preds = %entry
114 lpad.i: ; preds = %entry
115 %0 = landingpad { ptr, i32 }
118 %1 = extractvalue { ptr, i32 } %0, 1
119 %2 = call i32 @llvm.eh.typeid.for(ptr @_ZTIi) #4
120 %matches.i = icmp eq i32 %1, %2
121 br i1 %matches.i, label %catch.i, label %ehcleanup.i
123 catch.i: ; preds = %lpad.i
124 %3 = extractvalue { ptr, i32 } %0, 0
125 %4 = call ptr @__cxa_begin_catch(ptr %3) #4
126 call void @__cxa_end_catch() #4
127 %exception.i = call ptr @__cxa_allocate_exception(i64 4) #4
128 store i32 15532, ptr %exception.i, align 16, !tbaa !2
129 invoke void @__cxa_throw(ptr %exception.i, ptr @_ZTIi, ptr null) #5
130 to label %.noexc unwind label %lpad
132 .noexc: ; preds = %catch.i
135 ehcleanup.i: ; preds = %lpad.i
136 call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %A0.i) #4
139 lpad: ; preds = %catch.i
140 %5 = landingpad { ptr, i32 }
142 %.pre = extractvalue { ptr, i32 } %5, 1
145 lpad.body: ; preds = %ehcleanup.i, %lpad
146 %.pre-phi = phi i32 [ %1, %ehcleanup.i ], [ %.pre, %lpad ]
147 %eh.lpad-body = phi { ptr, i32 } [ %0, %ehcleanup.i ], [ %5, %lpad ]
148 %matches = icmp eq i32 %.pre-phi, %2
149 br i1 %matches, label %catch, label %eh.resume
151 catch: ; preds = %lpad.body
152 %6 = extractvalue { ptr, i32 } %eh.lpad-body, 0
153 %7 = call ptr @__cxa_begin_catch(ptr %6) #4
154 call void @__cxa_end_catch() #4
157 eh.resume: ; preds = %lpad.body
158 resume { ptr, i32 } %eh.lpad-body
161 attributes #0 = { noreturn sanitize_memtag "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+mte,+neon,+v8.5a" "unsafe-fp-math"="false" "use-soft-float"="false" }
162 attributes #1 = { argmemonly nounwind willreturn }
163 attributes #2 = { nounwind readnone }
164 attributes #3 = { norecurse sanitize_memtag "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+mte,+neon,+v8.5a" "unsafe-fp-math"="false" "use-soft-float"="false" }
165 attributes #4 = { nounwind }
166 attributes #5 = { noreturn }
168 !llvm.module.flags = !{!0}
171 !0 = !{i32 1, !"wchar_size", i32 4}
172 !1 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git c38188c5fe41751fda095edde1a878b2a051ae58)"}
173 !2 = !{!3, !3, i64 0}
174 !3 = !{!"int", !4, i64 0}
175 !4 = !{!"omnipotent char", !5, i64 0}
176 !5 = !{!"Simple C++ TBAA"}