1 ; RUN: llc -O2 -march=hexagon -mcpu=hexagonv5 < %s | FileCheck %s
2 ; we do not want to see a segv.
3 ; CHECK-NOT: segmentation
6 target datalayout = "e-m:e-p:32:32-i1:32-i64:64-a:0-v32:32-n16:32"
7 target triple = "hexagon"
9 %"class.std::__1::basic_string" = type { %"class.std::__1::__compressed_pair" }
10 %"class.std::__1::__compressed_pair" = type { %"class.std::__1::__libcpp_compressed_pair_imp" }
11 %"class.std::__1::__libcpp_compressed_pair_imp" = type { %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep" }
12 %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep" = type { %union.anon }
13 %union.anon = type { %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__long" }
14 %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__long" = type { i32, i32, ptr }
15 %"class.std::__1::ios_base" = type { ptr, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, i32, i32, ptr, i32, i32, ptr, i32, i32 }
16 %"class.std::__1::basic_streambuf" = type { ptr, %"class.std::__1::locale", ptr, ptr, ptr, ptr, ptr, ptr }
17 %"class.std::__1::locale" = type { ptr }
18 %"class.std::__1::locale::__imp" = type opaque
19 %"class.std::__1::allocator" = type { i8 }
20 %"class.std::__1::ostreambuf_iterator" = type { ptr }
21 %"class.std::__1::__basic_string_common" = type { i8 }
22 %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__short" = type { %union.anon.0, [11 x i8] }
23 %union.anon.0 = type { i8 }
25 ; Function Attrs: nounwind
26 declare void @llvm.memcpy.p0.p0.i32(ptr nocapture, ptr nocapture readonly, i32, i1) #0
28 declare i32 @__gxx_personality_v0(...)
30 ; Function Attrs: nounwind
31 declare void @_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev(ptr) #1
33 define weak_odr hidden i32 @_ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_(i32 %__s.coerce, ptr %__ob, ptr %__op, ptr %__oe, ptr nonnull %__iob, i8 zeroext %__fl) #2 personality ptr @__gxx_personality_v0 {
35 %this.addr.i66 = alloca ptr, align 4
36 %__s.addr.i67 = alloca ptr, align 4
37 %__n.addr.i68 = alloca i32, align 4
38 %__p.addr.i.i = alloca ptr, align 4
39 %this.addr.i.i.i13.i.i = alloca ptr, align 4
40 %this.addr.i.i14.i.i = alloca ptr, align 4
41 %this.addr.i15.i.i = alloca ptr, align 4
42 %__x.addr.i.i.i.i.i = alloca ptr, align 4
43 %__r.addr.i.i.i.i = alloca ptr, align 4
44 %this.addr.i.i.i4.i.i = alloca ptr, align 4
45 %this.addr.i.i5.i.i = alloca ptr, align 4
46 %this.addr.i6.i.i = alloca ptr, align 4
47 %this.addr.i.i.i.i.i56 = alloca ptr, align 4
48 %this.addr.i.i.i.i57 = alloca ptr, align 4
49 %this.addr.i.i.i58 = alloca ptr, align 4
50 %this.addr.i.i59 = alloca ptr, align 4
51 %this.addr.i60 = alloca ptr, align 4
52 %this.addr.i.i.i.i.i = alloca ptr, align 4
53 %this.addr.i.i.i.i = alloca ptr, align 4
54 %this.addr.i.i.i = alloca ptr, align 4
55 %this.addr.i.i = alloca ptr, align 4
56 %__n.addr.i.i = alloca i32, align 4
57 %__c.addr.i.i = alloca i8, align 1
58 %this.addr.i53 = alloca ptr, align 4
59 %__n.addr.i54 = alloca i32, align 4
60 %__c.addr.i = alloca i8, align 1
61 %this.addr.i46 = alloca ptr, align 4
62 %__s.addr.i47 = alloca ptr, align 4
63 %__n.addr.i48 = alloca i32, align 4
64 %this.addr.i44 = alloca ptr, align 4
65 %__s.addr.i = alloca ptr, align 4
66 %__n.addr.i = alloca i32, align 4
67 %this.addr.i41 = alloca ptr, align 4
68 %__wide.addr.i = alloca i32, align 4
69 %__r.i = alloca i32, align 4
70 %this.addr.i = alloca ptr, align 4
71 %retval = alloca %"class.std::__1::ostreambuf_iterator", align 4
72 %__s = alloca %"class.std::__1::ostreambuf_iterator", align 4
73 %__ob.addr = alloca ptr, align 4
74 %__op.addr = alloca ptr, align 4
75 %__oe.addr = alloca ptr, align 4
76 %__iob.addr = alloca ptr, align 4
77 %__fl.addr = alloca i8, align 1
78 %__sz = alloca i32, align 4
79 %__ns = alloca i32, align 4
80 %__np = alloca i32, align 4
81 %__sp = alloca %"class.std::__1::basic_string", align 4
82 %exn.slot = alloca ptr
83 %ehselector.slot = alloca i32
84 %cleanup.dest.slot = alloca i32
85 %coerce.val.ip = inttoptr i32 %__s.coerce to ptr
86 store ptr %coerce.val.ip, ptr %__s
87 store ptr %__ob, ptr %__ob.addr, align 4
88 store ptr %__op, ptr %__op.addr, align 4
89 store ptr %__oe, ptr %__oe.addr, align 4
90 store ptr %__iob, ptr %__iob.addr, align 4
91 store i8 %__fl, ptr %__fl.addr, align 1
92 %0 = load ptr, ptr %__s, align 4
93 %cmp = icmp eq ptr %0, null
94 br i1 %cmp, label %if.then, label %if.end
96 if.then: ; preds = %entry
97 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %retval, ptr align 4 %__s, i32 4, i1 false)
100 if.end: ; preds = %entry
101 %1 = load ptr, ptr %__oe.addr, align 4
102 %2 = load ptr, ptr %__ob.addr, align 4
103 %sub.ptr.lhs.cast = ptrtoint ptr %1 to i32
104 %sub.ptr.rhs.cast = ptrtoint ptr %2 to i32
105 %sub.ptr.sub = sub i32 %sub.ptr.lhs.cast, %sub.ptr.rhs.cast
106 store i32 %sub.ptr.sub, ptr %__sz, align 4
107 %3 = load ptr, ptr %__iob.addr, align 4
108 store ptr %3, ptr %this.addr.i, align 4
109 %this1.i = load ptr, ptr %this.addr.i
110 %__width_.i = getelementptr inbounds %"class.std::__1::ios_base", ptr %this1.i, i32 0, i32 3
111 %4 = load i32, ptr %__width_.i, align 4
112 store i32 %4, ptr %__ns, align 4
113 %5 = load i32, ptr %__ns, align 4
114 %6 = load i32, ptr %__sz, align 4
115 %cmp1 = icmp sgt i32 %5, %6
116 br i1 %cmp1, label %if.then2, label %if.else
118 if.then2: ; preds = %if.end
119 %7 = load i32, ptr %__sz, align 4
120 %8 = load i32, ptr %__ns, align 4
121 %sub = sub nsw i32 %8, %7
122 store i32 %sub, ptr %__ns, align 4
125 if.else: ; preds = %if.end
126 store i32 0, ptr %__ns, align 4
129 if.end3: ; preds = %if.else, %if.then2
130 %9 = load ptr, ptr %__op.addr, align 4
131 %10 = load ptr, ptr %__ob.addr, align 4
132 %sub.ptr.lhs.cast4 = ptrtoint ptr %9 to i32
133 %sub.ptr.rhs.cast5 = ptrtoint ptr %10 to i32
134 %sub.ptr.sub6 = sub i32 %sub.ptr.lhs.cast4, %sub.ptr.rhs.cast5
135 store i32 %sub.ptr.sub6, ptr %__np, align 4
136 %11 = load i32, ptr %__np, align 4
137 %cmp7 = icmp sgt i32 %11, 0
138 br i1 %cmp7, label %if.then8, label %if.end15
140 if.then8: ; preds = %if.end3
141 %12 = load ptr, ptr %__s, align 4
142 %13 = load ptr, ptr %__ob.addr, align 4
143 %14 = load i32, ptr %__np, align 4
144 store ptr %12, ptr %this.addr.i46, align 4
145 store ptr %13, ptr %__s.addr.i47, align 4
146 store i32 %14, ptr %__n.addr.i48, align 4
147 %this1.i49 = load ptr, ptr %this.addr.i46
148 %vtable.i50 = load ptr, ptr %this1.i49
149 %vfn.i51 = getelementptr inbounds ptr, ptr %vtable.i50, i64 12
150 %15 = load ptr, ptr %vfn.i51
151 %16 = load ptr, ptr %__s.addr.i47, align 4
152 %17 = load i32, ptr %__n.addr.i48, align 4
153 %call.i52 = call i32 %15(ptr %this1.i49, ptr %16, i32 %17)
154 %18 = load i32, ptr %__np, align 4
155 %cmp11 = icmp ne i32 %call.i52, %18
156 br i1 %cmp11, label %if.then12, label %if.end14
158 if.then12: ; preds = %if.then8
159 store ptr null, ptr %__s, align 4
160 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %retval, ptr align 4 %__s, i32 4, i1 false)
163 if.end14: ; preds = %if.then8
166 if.end15: ; preds = %if.end14, %if.end3
167 %19 = load i32, ptr %__ns, align 4
168 %cmp16 = icmp sgt i32 %19, 0
169 br i1 %cmp16, label %if.then17, label %if.end25
171 if.then17: ; preds = %if.end15
172 %20 = load i32, ptr %__ns, align 4
173 %21 = load i8, ptr %__fl.addr, align 1
174 store ptr %__sp, ptr %this.addr.i53, align 4
175 store i32 %20, ptr %__n.addr.i54, align 4
176 store i8 %21, ptr %__c.addr.i, align 1
177 %this1.i55 = load ptr, ptr %this.addr.i53
178 %22 = load i32, ptr %__n.addr.i54, align 4
179 %23 = load i8, ptr %__c.addr.i, align 1
180 store ptr %this1.i55, ptr %this.addr.i.i, align 4
181 store i32 %22, ptr %__n.addr.i.i, align 4
182 store i8 %23, ptr %__c.addr.i.i, align 1
183 %this1.i.i = load ptr, ptr %this.addr.i.i
184 store ptr %this1.i.i, ptr %this.addr.i.i.i, align 4
185 %this1.i.i.i = load ptr, ptr %this.addr.i.i.i
186 store ptr %this1.i.i.i, ptr %this.addr.i.i.i.i, align 4
187 %this1.i.i.i.i = load ptr, ptr %this.addr.i.i.i.i
188 store ptr %this1.i.i.i.i, ptr %this.addr.i.i.i.i.i, align 4
189 %this1.i.i.i.i.i = load ptr, ptr %this.addr.i.i.i.i.i
190 %24 = load i32, ptr %__n.addr.i.i, align 4
191 %25 = load i8, ptr %__c.addr.i.i, align 1
192 call void @_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEjc(ptr %this1.i.i, i32 %24, i8 zeroext %25)
193 %26 = load ptr, ptr %__s, align 4
194 store ptr %__sp, ptr %this.addr.i60, align 4
195 %this1.i61 = load ptr, ptr %this.addr.i60
196 store ptr %this1.i61, ptr %this.addr.i.i59, align 4
197 %this1.i.i62 = load ptr, ptr %this.addr.i.i59
198 store ptr %this1.i.i62, ptr %this.addr.i.i.i58, align 4
199 %this1.i.i.i63 = load ptr, ptr %this.addr.i.i.i58
200 store ptr %this1.i.i.i63, ptr %this.addr.i.i.i.i57, align 4
201 %this1.i.i.i.i64 = load ptr, ptr %this.addr.i.i.i.i57
202 store ptr %this1.i.i.i.i64, ptr %this.addr.i.i.i.i.i56, align 4
203 %this1.i.i.i.i.i65 = load ptr, ptr %this.addr.i.i.i.i.i56
204 %27 = getelementptr inbounds %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep", ptr %this1.i.i.i.i.i65, i32 0, i32 0
205 %28 = getelementptr inbounds %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__short", ptr %27, i32 0, i32 0
206 %29 = load i8, ptr %28, align 1
207 %conv.i.i.i = zext i8 %29 to i32
208 %and.i.i.i = and i32 %conv.i.i.i, 1
209 %tobool.i.i.i = icmp ne i32 %and.i.i.i, 0
210 br i1 %tobool.i.i.i, label %cond.true.i.i, label %cond.false.i.i
212 cond.true.i.i: ; preds = %if.then17
213 store ptr %this1.i.i62, ptr %this.addr.i15.i.i, align 4
214 %this1.i16.i.i = load ptr, ptr %this.addr.i15.i.i
215 store ptr %this1.i16.i.i, ptr %this.addr.i.i14.i.i, align 4
216 %this1.i.i18.i.i = load ptr, ptr %this.addr.i.i14.i.i
217 store ptr %this1.i.i18.i.i, ptr %this.addr.i.i.i13.i.i, align 4
218 %this1.i.i.i19.i.i = load ptr, ptr %this.addr.i.i.i13.i.i
219 %30 = getelementptr inbounds %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep", ptr %this1.i.i.i19.i.i, i32 0, i32 0
220 %__data_.i21.i.i = getelementptr inbounds %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__long", ptr %30, i32 0, i32 2
221 %31 = load ptr, ptr %__data_.i21.i.i, align 4
222 br label %_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4dataEv.exit
224 cond.false.i.i: ; preds = %if.then17
225 store ptr %this1.i.i62, ptr %this.addr.i6.i.i, align 4
226 %this1.i7.i.i = load ptr, ptr %this.addr.i6.i.i
227 store ptr %this1.i7.i.i, ptr %this.addr.i.i5.i.i, align 4
228 %this1.i.i9.i.i = load ptr, ptr %this.addr.i.i5.i.i
229 store ptr %this1.i.i9.i.i, ptr %this.addr.i.i.i4.i.i, align 4
230 %this1.i.i.i10.i.i = load ptr, ptr %this.addr.i.i.i4.i.i
231 %32 = getelementptr inbounds %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep", ptr %this1.i.i.i10.i.i, i32 0, i32 0
232 %__data_.i.i.i = getelementptr inbounds %"struct.std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__short", ptr %32, i32 0, i32 1
233 store ptr %__data_.i.i.i, ptr %__r.addr.i.i.i.i, align 4
234 %33 = load ptr, ptr %__r.addr.i.i.i.i, align 4
235 store ptr %33, ptr %__x.addr.i.i.i.i.i, align 4
236 %34 = load ptr, ptr %__x.addr.i.i.i.i.i, align 4
237 br label %_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4dataEv.exit
239 _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4dataEv.exit: ; preds = %cond.false.i.i, %cond.true.i.i
240 %cond.i.i = phi ptr [ %31, %cond.true.i.i ], [ %34, %cond.false.i.i ]
241 store ptr %cond.i.i, ptr %__p.addr.i.i, align 4
242 %35 = load ptr, ptr %__p.addr.i.i, align 4
243 %36 = load i32, ptr %__ns, align 4
244 store ptr %26, ptr %this.addr.i66, align 4
245 store ptr %35, ptr %__s.addr.i67, align 4
246 store i32 %36, ptr %__n.addr.i68, align 4
247 %this1.i69 = load ptr, ptr %this.addr.i66
248 %vtable.i70 = load ptr, ptr %this1.i69
249 %vfn.i71 = getelementptr inbounds ptr, ptr %vtable.i70, i64 12
250 %37 = load ptr, ptr %vfn.i71
251 %38 = load ptr, ptr %__s.addr.i67, align 4
252 %39 = load i32, ptr %__n.addr.i68, align 4
253 %call.i7273 = invoke i32 %37(ptr %this1.i69, ptr %38, i32 %39)
254 to label %_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputnEPKci.exit unwind label %lpad
256 _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputnEPKci.exit: ; preds = %_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4dataEv.exit
257 br label %invoke.cont
259 invoke.cont: ; preds = %_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputnEPKci.exit
260 %40 = load i32, ptr %__ns, align 4
261 %cmp21 = icmp ne i32 %call.i7273, %40
262 br i1 %cmp21, label %if.then22, label %if.end24
264 if.then22: ; preds = %invoke.cont
265 store ptr null, ptr %__s, align 4
266 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %retval, ptr align 4 %__s, i32 4, i1 false)
267 store i32 1, ptr %cleanup.dest.slot
270 lpad: ; preds = %_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4dataEv.exit
271 %41 = landingpad { ptr, i32 }
273 %42 = extractvalue { ptr, i32 } %41, 0
274 store ptr %42, ptr %exn.slot
275 %43 = extractvalue { ptr, i32 } %41, 1
276 store i32 %43, ptr %ehselector.slot
277 call void @_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev(ptr %__sp) #0
280 if.end24: ; preds = %invoke.cont
281 store i32 0, ptr %cleanup.dest.slot
284 cleanup: ; preds = %if.end24, %if.then22
285 call void @_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev(ptr %__sp) #0
286 %cleanup.dest = load i32, ptr %cleanup.dest.slot
287 switch i32 %cleanup.dest, label %unreachable [
288 i32 0, label %cleanup.cont
292 cleanup.cont: ; preds = %cleanup
295 if.end25: ; preds = %cleanup.cont, %if.end15
296 %44 = load ptr, ptr %__oe.addr, align 4
297 %45 = load ptr, ptr %__op.addr, align 4
298 %sub.ptr.lhs.cast26 = ptrtoint ptr %44 to i32
299 %sub.ptr.rhs.cast27 = ptrtoint ptr %45 to i32
300 %sub.ptr.sub28 = sub i32 %sub.ptr.lhs.cast26, %sub.ptr.rhs.cast27
301 store i32 %sub.ptr.sub28, ptr %__np, align 4
302 %46 = load i32, ptr %__np, align 4
303 %cmp29 = icmp sgt i32 %46, 0
304 br i1 %cmp29, label %if.then30, label %if.end37
306 if.then30: ; preds = %if.end25
307 %47 = load ptr, ptr %__s, align 4
308 %48 = load ptr, ptr %__op.addr, align 4
309 %49 = load i32, ptr %__np, align 4
310 store ptr %47, ptr %this.addr.i44, align 4
311 store ptr %48, ptr %__s.addr.i, align 4
312 store i32 %49, ptr %__n.addr.i, align 4
313 %this1.i45 = load ptr, ptr %this.addr.i44
314 %vtable.i = load ptr, ptr %this1.i45
315 %vfn.i = getelementptr inbounds ptr, ptr %vtable.i, i64 12
316 %50 = load ptr, ptr %vfn.i
317 %51 = load ptr, ptr %__s.addr.i, align 4
318 %52 = load i32, ptr %__n.addr.i, align 4
319 %call.i = call i32 %50(ptr %this1.i45, ptr %51, i32 %52)
320 %53 = load i32, ptr %__np, align 4
321 %cmp33 = icmp ne i32 %call.i, %53
322 br i1 %cmp33, label %if.then34, label %if.end36
324 if.then34: ; preds = %if.then30
325 store ptr null, ptr %__s, align 4
326 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %retval, ptr align 4 %__s, i32 4, i1 false)
329 if.end36: ; preds = %if.then30
332 if.end37: ; preds = %if.end36, %if.end25
333 %54 = load ptr, ptr %__iob.addr, align 4
334 store ptr %54, ptr %this.addr.i41, align 4
335 store i32 0, ptr %__wide.addr.i, align 4
336 %this1.i42 = load ptr, ptr %this.addr.i41
337 %__width_.i43 = getelementptr inbounds %"class.std::__1::ios_base", ptr %this1.i42, i32 0, i32 3
338 %55 = load i32, ptr %__width_.i43, align 4
339 store i32 %55, ptr %__r.i, align 4
340 %56 = load i32, ptr %__wide.addr.i, align 4
341 %__width_2.i = getelementptr inbounds %"class.std::__1::ios_base", ptr %this1.i42, i32 0, i32 3
342 store i32 %56, ptr %__width_2.i, align 4
343 %57 = load i32, ptr %__r.i, align 4
344 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %retval, ptr align 4 %__s, i32 4, i1 false)
347 return: ; preds = %if.end37, %if.then34, %cleanup, %if.then12, %if.then
348 %58 = load ptr, ptr %retval
349 %coerce.val.pi = ptrtoint ptr %58 to i32
350 ret i32 %coerce.val.pi
352 eh.resume: ; preds = %lpad
353 %exn = load ptr, ptr %exn.slot
354 %sel = load i32, ptr %ehselector.slot
355 %lpad.val = insertvalue { ptr, i32 } undef, ptr %exn, 0
356 %lpad.val40 = insertvalue { ptr, i32 } %lpad.val, i32 %sel, 1
357 resume { ptr, i32 } %lpad.val40
359 unreachable: ; preds = %cleanup
363 declare void @_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEjc(ptr, i32, i8 zeroext) #2
365 attributes #0 = { nounwind }
366 attributes #1 = { nounwind "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
367 attributes #2 = { "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }