xref: /llvm-project/llvm/test/Transforms/GVNHoist/pr29034.ll (revision 055fb7795aa219a3d274d280ec9129784f169f56)
1; RUN: opt -S -passes=gvn-hoist < %s | FileCheck %s
2
3; Check that the stores are not hoisted: it is invalid to hoist stores if they
4; are not executed on all paths. In this testcase, there are paths in the loop
5; that do not execute the stores.
6
7; CHECK-LABEL: define void @music_task
8; CHECK: store
9; CHECK: store
10; CHECK: store
11
12
13%struct._MUSIC_OP_API_ = type { ptr, ptr }
14%struct._FILE_OPERATE_ = type { ptr, ptr }
15%struct._FILE_OPERATE_INIT_ = type { i32, i32, i32, i32, ptr, ptr, i32 }
16%struct._lg_dev_info_ = type { %struct.os_event, i32, i32, ptr, i8, i8, i8, i8, i8 }
17%struct.os_event = type { i8, i32, ptr, %union.anon }
18%union.anon = type { %struct.event_cnt }
19%struct.event_cnt = type { i16 }
20%struct._lg_dev_hdl_ = type { ptr, ptr, ptr, ptr, ptr }
21%struct.__MUSIC_API = type <{ ptr, ptr, i32, %struct._DEC_API, ptr, ptr }>
22%struct._DEC_API = type { ptr, ptr, ptr, ptr, ptr, ptr, %struct._AAC_DEFAULT_SETTING, i32, i32, ptr, ptr, i32, i8, ptr, i8, ptr }
23%struct._DEC_PHY = type { ptr, ptr, ptr, %struct.if_decoder_io, ptr, ptr, ptr, i32, i8, %struct.__FF_FR }
24%struct.__audio_decoder_ops = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
25%struct.if_decoder_io = type { ptr, ptr, ptr, ptr, ptr, ptr }
26%struct.if_dec_file = type { ptr, ptr }
27%struct.__FF_FR = type { i32, i32, i8, i8, i8 }
28%struct._AAC_DEFAULT_SETTING = type { i32, i32, i32 }
29%struct.decoder_inf = type { i16, i16, i32, i32 }
30%struct._DEC_API_IO = type { ptr, ptr, ptr, ptr, ptr, %struct.__OP_IO, i32, i32 }
31%struct.__OP_IO = type { ptr, ptr }
32%struct._FS_BRK_POINT = type { %struct._FS_BRK_INFO, i32, i32 }
33%struct._FS_BRK_INFO = type { i32, i32, [8 x i8], i8, i8, i16 }
34
35@.str = external hidden unnamed_addr constant [10 x i8], align 1
36
37define void @music_task(ptr nocapture readnone %p) local_unnamed_addr {
38entry:
39  %mapi = alloca ptr, align 8
40  call void @llvm.lifetime.start.p0(i64 8, ptr %mapi)
41  store ptr null, ptr %mapi, align 8, !tbaa !1
42  %call = call i32 @music_decoder_init(ptr nonnull %mapi)
43  br label %while.cond
44
45while.cond.loopexit:                              ; preds = %while.cond2
46  br label %while.cond
47
48while.cond:                                       ; preds = %while.cond.loopexit, %entry
49  %0 = load ptr, ptr %mapi, align 8, !tbaa !1
50  %dop_api = getelementptr inbounds %struct._MUSIC_OP_API_, ptr %0, i64 0, i32 1
51  %1 = load ptr, ptr %dop_api, align 8, !tbaa !5
52  %file_num = getelementptr inbounds %struct.__MUSIC_API, ptr %1, i64 0, i32 2
53  %call1 = call i32 @music_play_api(ptr %0, i32 33, i32 0, i32 28, ptr %file_num)
54  br label %while.cond2
55
56while.cond2:                                      ; preds = %while.cond2.backedge, %while.cond
57  %err.0 = phi i32 [ %call1, %while.cond ], [ %err.0.be, %while.cond2.backedge ]
58  switch i32 %err.0, label %sw.default [
59    i32 0, label %while.cond.loopexit
60    i32 35, label %sw.bb
61    i32 11, label %sw.bb7
62    i32 12, label %sw.bb13
63  ]
64
65sw.bb:                                            ; preds = %while.cond2
66  %2 = load ptr, ptr %mapi, align 8, !tbaa !1
67  %dop_api4 = getelementptr inbounds %struct._MUSIC_OP_API_, ptr %2, i64 0, i32 1
68  %3 = load ptr, ptr %dop_api4, align 8, !tbaa !5
69  %file_num5 = getelementptr inbounds %struct.__MUSIC_API, ptr %3, i64 0, i32 2
70  %4 = load i32, ptr %file_num5, align 1, !tbaa !7
71  %call6 = call i32 (ptr, ...) @printf(ptr @.str, i32 %4)
72  br label %while.cond2.backedge
73
74sw.bb7:                                           ; preds = %while.cond2
75  %5 = load ptr, ptr %mapi, align 8, !tbaa !1
76  %dop_api8 = getelementptr inbounds %struct._MUSIC_OP_API_, ptr %5, i64 0, i32 1
77  %6 = load ptr, ptr %dop_api8, align 8, !tbaa !5
78  %file_num9 = getelementptr inbounds %struct.__MUSIC_API, ptr %6, i64 0, i32 2
79  store i32 1, ptr %file_num9, align 1, !tbaa !7
80  %call12 = call i32 @music_play_api(ptr %5, i32 34, i32 0, i32 24, ptr %file_num9)
81  br label %while.cond2.backedge
82
83sw.bb13:                                          ; preds = %while.cond2
84  %7 = load ptr, ptr %mapi, align 8, !tbaa !1
85  %dop_api14 = getelementptr inbounds %struct._MUSIC_OP_API_, ptr %7, i64 0, i32 1
86  %8 = load ptr, ptr %dop_api14, align 8, !tbaa !5
87  %file_num15 = getelementptr inbounds %struct.__MUSIC_API, ptr %8, i64 0, i32 2
88  store i32 1, ptr %file_num15, align 1, !tbaa !7
89  %call18 = call i32 @music_play_api(ptr %7, i32 35, i32 0, i32 26, ptr %file_num15)
90  br label %while.cond2.backedge
91
92sw.default:                                       ; preds = %while.cond2
93  %9 = load ptr, ptr %mapi, align 8, !tbaa !1
94  %call19 = call i32 @music_play_api(ptr %9, i32 33, i32 0, i32 22, ptr null)
95  br label %while.cond2.backedge
96
97while.cond2.backedge:                             ; preds = %sw.default, %sw.bb13, %sw.bb7, %sw.bb
98  %err.0.be = phi i32 [ %call19, %sw.default ], [ %call18, %sw.bb13 ], [ %call12, %sw.bb7 ], [ 0, %sw.bb ]
99  br label %while.cond2
100}
101
102declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
103declare i32 @music_decoder_init(ptr)
104declare i32 @music_play_api(ptr, i32, i32, i32, ptr)
105declare i32 @printf(ptr nocapture readonly, ...)
106
107!0 = !{!"clang version 4.0.0 "}
108!1 = !{!2, !2, i64 0}
109!2 = !{!"any pointer", !3, i64 0}
110!3 = !{!"omnipotent char", !4, i64 0}
111!4 = !{!"Simple C/C++ TBAA"}
112!5 = !{!6, !2, i64 8}
113!6 = !{!"_MUSIC_OP_API_", !2, i64 0, !2, i64 8}
114!7 = !{!8, !9, i64 16}
115!8 = !{!"__MUSIC_API", !2, i64 0, !2, i64 8, !9, i64 16, !10, i64 20, !2, i64 140, !2, i64 148}
116!9 = !{!"int", !3, i64 0}
117!10 = !{!"_DEC_API", !2, i64 0, !2, i64 8, !2, i64 16, !2, i64 24, !2, i64 32, !2, i64 40, !11, i64 48, !9, i64 60, !9, i64 64, !2, i64 72, !2, i64 80, !9, i64 88, !3, i64 92, !2, i64 96, !3, i64 104, !2, i64 112}
118!11 = !{!"_AAC_DEFAULT_SETTING", !9, i64 0, !9, i64 4, !9, i64 8}
119