1 ; RUN: llc -march=hexagon -mtriple=hexagon-unknown-linux-musl < %s | FileCheck %s
3 ; Check that we update the stack pointer before we do allocframe, so that
4 ; the LR/FP are stored in the location required by the Linux ABI.
5 ; CHECK: r29 = add(r29,#-24)
8 target triple = "hexagon-unknown-linux"
10 %s.0 = type { ptr, ptr, ptr }
12 define dso_local i32 @f0(i32 %a0, ...) local_unnamed_addr #0 {
14 %v0 = alloca [1 x %s.0], align 8
15 call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %v0) #2
16 call void @llvm.va_start(ptr nonnull %v0)
17 %v3 = load ptr, ptr %v0, align 8
18 %v4 = getelementptr inbounds [1 x %s.0], ptr %v0, i32 0, i32 0, i32 1
19 %v5 = load ptr, ptr %v4, align 4
20 %v6 = getelementptr i8, ptr %v3, i32 4
21 %v7 = icmp sgt ptr %v6, %v5
22 br i1 %v7, label %b1, label %b2
25 %v8 = getelementptr inbounds [1 x %s.0], ptr %v0, i32 0, i32 0, i32 2
26 %v9 = load ptr, ptr %v8, align 8
27 %v10 = getelementptr i8, ptr %v9, i32 4
28 store ptr %v10, ptr %v8, align 8
31 b2: ; preds = %b1, %b0
32 %v11 = phi ptr [ %v10, %b1 ], [ %v6, %b0 ]
33 %v12 = phi ptr [ %v9, %b1 ], [ %v3, %b0 ]
34 store ptr %v11, ptr %v0, align 8
35 %v14 = load i32, ptr %v12, align 4
36 %v15 = icmp eq i32 %v14, 0
37 br i1 %v15, label %b7, label %b3
40 %v16 = getelementptr inbounds [1 x %s.0], ptr %v0, i32 0, i32 0, i32 2
43 b4: ; preds = %b6, %b3
44 %v17 = phi i32 [ %v14, %b3 ], [ %v28, %b6 ]
45 %v18 = phi i32 [ %a0, %b3 ], [ %v20, %b6 ]
46 %v19 = phi ptr [ %v11, %b3 ], [ %v25, %b6 ]
47 %v20 = add nsw i32 %v17, %v18
48 %v21 = getelementptr i8, ptr %v19, i32 4
49 %v22 = icmp sgt ptr %v21, %v5
50 br i1 %v22, label %b5, label %b6
53 %v23 = load ptr, ptr %v16, align 8
54 %v24 = getelementptr i8, ptr %v23, i32 4
55 store ptr %v24, ptr %v16, align 8
58 b6: ; preds = %b5, %b4
59 %v25 = phi ptr [ %v24, %b5 ], [ %v21, %b4 ]
60 %v26 = phi ptr [ %v23, %b5 ], [ %v19, %b4 ]
61 store ptr %v25, ptr %v0, align 8
62 %v28 = load i32, ptr %v26, align 4
63 %v29 = icmp eq i32 %v28, 0
64 br i1 %v29, label %b7, label %b4
66 b7: ; preds = %b6, %b2
67 %v30 = phi i32 [ %a0, %b2 ], [ %v20, %b6 ]
68 call void @llvm.va_end(ptr nonnull %v0)
69 call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %v0) #2
73 ; Function Attrs: argmemonly nounwind
74 declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #1
76 ; Function Attrs: nounwind
77 declare void @llvm.va_start(ptr) #2
79 ; Function Attrs: nounwind
80 declare void @llvm.va_end(ptr) #2
82 ; Function Attrs: argmemonly nounwind
83 declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #1
85 attributes #0 = { argmemonly nounwind "frame-pointer"="all" }
87 !llvm.module.flags = !{!0}
89 !0 = !{i32 1, !"wchar_size", i32 4}