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 -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-unknown-unknown-eabi"
32 @_ZTIi = external dso_local constant i8*
34 ; Function Attrs: noreturn sanitize_memtag
35 define dso_local void @_Z3barv() local_unnamed_addr #0 {
37 %exception = tail call i8* @__cxa_allocate_exception(i64 4) #4
38 %0 = bitcast i8* %exception to i32*
39 store i32 42, i32* %0, align 16, !tbaa !2
40 tail call void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #5
44 declare dso_local i8* @__cxa_allocate_exception(i64) local_unnamed_addr
46 declare dso_local void @__cxa_throw(i8*, i8*, i8*) local_unnamed_addr
48 ; Function Attrs: noreturn sanitize_memtag
49 define dso_local void @_Z3foov() local_unnamed_addr #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
51 %A0 = alloca i32, align 4
52 %0 = bitcast i32* %A0 to i8*
53 call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %0) #4
54 call void asm sideeffect "", "r"(i32* nonnull %A0) #4, !srcloc !6
55 invoke void @_Z3barv()
56 to label %try.cont unwind label %lpad
58 lpad: ; preds = %entry
59 %1 = landingpad { i8*, i32 }
61 catch i8* bitcast (i8** @_ZTIi to i8*)
62 %2 = extractvalue { i8*, i32 } %1, 1
63 %3 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #4
64 %matches = icmp eq i32 %2, %3
65 br i1 %matches, label %catch, label %ehcleanup
67 catch: ; preds = %lpad
68 %4 = extractvalue { i8*, i32 } %1, 0
69 %5 = call i8* @__cxa_begin_catch(i8* %4) #4
70 call void @__cxa_end_catch() #4
73 try.cont: ; preds = %entry, %catch
74 %exception = call i8* @__cxa_allocate_exception(i64 4) #4
75 %6 = bitcast i8* %exception to i32*
76 store i32 15532, i32* %6, align 16, !tbaa !2
77 call void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #5
80 ehcleanup: ; preds = %lpad
81 call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %0) #4
82 resume { i8*, i32 } %1
85 ; Function Attrs: argmemonly nounwind willreturn
86 declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
88 declare dso_local i32 @__gxx_personality_v0(...)
90 ; Function Attrs: nounwind readnone
91 declare i32 @llvm.eh.typeid.for(i8*) #2
93 declare dso_local i8* @__cxa_begin_catch(i8*) local_unnamed_addr
95 declare dso_local void @__cxa_end_catch() local_unnamed_addr
97 ; Function Attrs: argmemonly nounwind willreturn
98 declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
100 ; Function Attrs: norecurse sanitize_memtag
101 define dso_local i32 @main() local_unnamed_addr #3 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
103 ; CHECK-LABEL: entry:
104 %A0.i = alloca i32, align 4
105 %0 = bitcast i32* %A0.i to i8*
106 call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %0) #4
107 call void asm sideeffect "", "r"(i32* nonnull %A0.i) #4, !srcloc !6
108 ; CHECK: call void @llvm.aarch64.settag(i8* %1, i64 16)
109 ; CHECK-NEXT: call void asm sideeffect
110 %exception.i6 = call i8* @__cxa_allocate_exception(i64 4) #4
111 %1 = bitcast i8* %exception.i6 to i32*
112 store i32 42, i32* %1, align 16, !tbaa !2
113 invoke void @__cxa_throw(i8* %exception.i6, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #5
114 to label %.noexc7 unwind label %lpad.i
116 .noexc7: ; preds = %entry
119 lpad.i: ; preds = %entry
120 %2 = landingpad { i8*, i32 }
122 catch i8* bitcast (i8** @_ZTIi to i8*)
123 %3 = extractvalue { i8*, i32 } %2, 1
124 %4 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #4
125 %matches.i = icmp eq i32 %3, %4
126 br i1 %matches.i, label %catch.i, label %ehcleanup.i
128 catch.i: ; preds = %lpad.i
129 %5 = extractvalue { i8*, i32 } %2, 0
130 %6 = call i8* @__cxa_begin_catch(i8* %5) #4
131 call void @__cxa_end_catch() #4
132 %exception.i = call i8* @__cxa_allocate_exception(i64 4) #4
133 %7 = bitcast i8* %exception.i to i32*
134 store i32 15532, i32* %7, align 16, !tbaa !2
135 invoke void @__cxa_throw(i8* %exception.i, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #5
136 to label %.noexc unwind label %lpad
138 .noexc: ; preds = %catch.i
141 ehcleanup.i: ; preds = %lpad.i
142 call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %0) #4
145 lpad: ; preds = %catch.i
146 %8 = landingpad { i8*, i32 }
147 catch i8* bitcast (i8** @_ZTIi to i8*)
148 %.pre = extractvalue { i8*, i32 } %8, 1
151 lpad.body: ; preds = %ehcleanup.i, %lpad
152 %.pre-phi = phi i32 [ %3, %ehcleanup.i ], [ %.pre, %lpad ]
153 %eh.lpad-body = phi { i8*, i32 } [ %2, %ehcleanup.i ], [ %8, %lpad ]
154 %matches = icmp eq i32 %.pre-phi, %4
155 br i1 %matches, label %catch, label %eh.resume
157 catch: ; preds = %lpad.body
158 %9 = extractvalue { i8*, i32 } %eh.lpad-body, 0
159 %10 = call i8* @__cxa_begin_catch(i8* %9) #4
160 call void @__cxa_end_catch() #4
163 eh.resume: ; preds = %lpad.body
164 resume { i8*, i32 } %eh.lpad-body
167 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" }
168 attributes #1 = { argmemonly nounwind willreturn }
169 attributes #2 = { nounwind readnone }
170 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" }
171 attributes #4 = { nounwind }
172 attributes #5 = { noreturn }
174 !llvm.module.flags = !{!0}
177 !0 = !{i32 1, !"wchar_size", i32 4}
178 !1 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git c38188c5fe41751fda095edde1a878b2a051ae58)"}
179 !2 = !{!3, !3, i64 0}
180 !3 = !{!"int", !4, i64 0}
181 !4 = !{!"omnipotent char", !5, i64 0}
182 !5 = !{!"Simple C++ TBAA"}