• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -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 { %struct._FILE_OPERATE_*, %struct.__MUSIC_API* }
14%struct._FILE_OPERATE_ = type { %struct._FILE_OPERATE_INIT_*, %struct._lg_dev_info_* }
15%struct._FILE_OPERATE_INIT_ = type { i32, i32, i32, i32, i32*, i8*, i32 }
16%struct._lg_dev_info_ = type { %struct.os_event, i32, i32, %struct._lg_dev_hdl_*, i8, i8, i8, i8, i8 }
17%struct.os_event = type { i8, i32, i8*, %union.anon }
18%union.anon = type { %struct.event_cnt }
19%struct.event_cnt = type { i16 }
20%struct._lg_dev_hdl_ = type { i8*, i8*, i8*, i8*, i8* }
21%struct.__MUSIC_API = type <{ i8*, i8*, i32, %struct._DEC_API, %struct._DEC_API_IO*, %struct._FS_BRK_POINT* }>
22%struct._DEC_API = type { %struct._DEC_PHY*, i8*, i8*, i8* (i8*)*, i32* (i8*)*, i8*, %struct._AAC_DEFAULT_SETTING, i32, i32, i8*, %struct.decoder_inf*, i32, i8, i8*, i8, i8* }
23%struct._DEC_PHY = type { i8*, %struct.__audio_decoder_ops*, i8*, %struct.if_decoder_io, %struct.if_dec_file*, i8*, i32 (i8*)*, i32, i8, %struct.__FF_FR }
24%struct.__audio_decoder_ops = type { i8*, i32 (i8*, %struct.if_decoder_io*, i8*)*, i32 (i8*)*, i32 (i8*, i32)*, %struct.decoder_inf* (i8*)*, i32 (i8*)*, i32 (i8*)*, i32 (...)*, i32 (...)*, i32 (...)*, void (i8*, i32)*, void (i8*, i32, i8*, i32)*, i32 (i8*, i32, i8*)* }
25%struct.if_decoder_io = type { i8*, i32 (i8*, i32, i8*, i32, i8)*, i32 (i8*, i32, i8*)*, void (i8*, i8*, i32)*, i32 (i8*)*, i32 (i8*, i32, i32)* }
26%struct.if_dec_file = type { i32 (i8*, i8*, i32)*, i32 (i8*, i32, i32)* }
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 { i8*, i8*, i16 (i8*, i8*, i16)*, i32 (i8*, i8, i32)*, i32 (%struct.decoder_inf*, i32)*, %struct.__OP_IO, i32, i32 }
31%struct.__OP_IO = type { i8*, i8* (i8*, i8*, i32)* }
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(i8* nocapture readnone %p) local_unnamed_addr {
38entry:
39  %mapi = alloca %struct._MUSIC_OP_API_*, align 8
40  %0 = bitcast %struct._MUSIC_OP_API_** %mapi to i8*
41  call void @llvm.lifetime.start.p0i8(i64 8, i8* %0)
42  store %struct._MUSIC_OP_API_* null, %struct._MUSIC_OP_API_** %mapi, align 8, !tbaa !1
43  %call = call i32 @music_decoder_init(%struct._MUSIC_OP_API_** nonnull %mapi)
44  br label %while.cond
45
46while.cond.loopexit:                              ; preds = %while.cond2
47  br label %while.cond
48
49while.cond:                                       ; preds = %while.cond.loopexit, %entry
50  %1 = load %struct._MUSIC_OP_API_*, %struct._MUSIC_OP_API_** %mapi, align 8, !tbaa !1
51  %dop_api = getelementptr inbounds %struct._MUSIC_OP_API_, %struct._MUSIC_OP_API_* %1, i64 0, i32 1
52  %2 = load %struct.__MUSIC_API*, %struct.__MUSIC_API** %dop_api, align 8, !tbaa !5
53  %file_num = getelementptr inbounds %struct.__MUSIC_API, %struct.__MUSIC_API* %2, i64 0, i32 2
54  %3 = bitcast i32* %file_num to i8*
55  %call1 = call i32 @music_play_api(%struct._MUSIC_OP_API_* %1, i32 33, i32 0, i32 28, i8* %3)
56  br label %while.cond2
57
58while.cond2:                                      ; preds = %while.cond2.backedge, %while.cond
59  %err.0 = phi i32 [ %call1, %while.cond ], [ %err.0.be, %while.cond2.backedge ]
60  switch i32 %err.0, label %sw.default [
61    i32 0, label %while.cond.loopexit
62    i32 35, label %sw.bb
63    i32 11, label %sw.bb7
64    i32 12, label %sw.bb13
65  ]
66
67sw.bb:                                            ; preds = %while.cond2
68  %4 = load %struct._MUSIC_OP_API_*, %struct._MUSIC_OP_API_** %mapi, align 8, !tbaa !1
69  %dop_api4 = getelementptr inbounds %struct._MUSIC_OP_API_, %struct._MUSIC_OP_API_* %4, i64 0, i32 1
70  %5 = load %struct.__MUSIC_API*, %struct.__MUSIC_API** %dop_api4, align 8, !tbaa !5
71  %file_num5 = getelementptr inbounds %struct.__MUSIC_API, %struct.__MUSIC_API* %5, i64 0, i32 2
72  %6 = load i32, i32* %file_num5, align 1, !tbaa !7
73  %call6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %6)
74  br label %while.cond2.backedge
75
76sw.bb7:                                           ; preds = %while.cond2
77  %7 = load %struct._MUSIC_OP_API_*, %struct._MUSIC_OP_API_** %mapi, align 8, !tbaa !1
78  %dop_api8 = getelementptr inbounds %struct._MUSIC_OP_API_, %struct._MUSIC_OP_API_* %7, i64 0, i32 1
79  %8 = load %struct.__MUSIC_API*, %struct.__MUSIC_API** %dop_api8, align 8, !tbaa !5
80  %file_num9 = getelementptr inbounds %struct.__MUSIC_API, %struct.__MUSIC_API* %8, i64 0, i32 2
81  store i32 1, i32* %file_num9, align 1, !tbaa !7
82  %9 = bitcast i32* %file_num9 to i8*
83  %call12 = call i32 @music_play_api(%struct._MUSIC_OP_API_* %7, i32 34, i32 0, i32 24, i8* %9)
84  br label %while.cond2.backedge
85
86sw.bb13:                                          ; preds = %while.cond2
87  %10 = load %struct._MUSIC_OP_API_*, %struct._MUSIC_OP_API_** %mapi, align 8, !tbaa !1
88  %dop_api14 = getelementptr inbounds %struct._MUSIC_OP_API_, %struct._MUSIC_OP_API_* %10, i64 0, i32 1
89  %11 = load %struct.__MUSIC_API*, %struct.__MUSIC_API** %dop_api14, align 8, !tbaa !5
90  %file_num15 = getelementptr inbounds %struct.__MUSIC_API, %struct.__MUSIC_API* %11, i64 0, i32 2
91  store i32 1, i32* %file_num15, align 1, !tbaa !7
92  %12 = bitcast i32* %file_num15 to i8*
93  %call18 = call i32 @music_play_api(%struct._MUSIC_OP_API_* %10, i32 35, i32 0, i32 26, i8* %12)
94  br label %while.cond2.backedge
95
96sw.default:                                       ; preds = %while.cond2
97  %13 = load %struct._MUSIC_OP_API_*, %struct._MUSIC_OP_API_** %mapi, align 8, !tbaa !1
98  %call19 = call i32 @music_play_api(%struct._MUSIC_OP_API_* %13, i32 33, i32 0, i32 22, i8* null)
99  br label %while.cond2.backedge
100
101while.cond2.backedge:                             ; preds = %sw.default, %sw.bb13, %sw.bb7, %sw.bb
102  %err.0.be = phi i32 [ %call19, %sw.default ], [ %call18, %sw.bb13 ], [ %call12, %sw.bb7 ], [ 0, %sw.bb ]
103  br label %while.cond2
104}
105
106declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
107declare i32 @music_decoder_init(%struct._MUSIC_OP_API_**)
108declare i32 @music_play_api(%struct._MUSIC_OP_API_*, i32, i32, i32, i8*)
109declare i32 @printf(i8* nocapture readonly, ...)
110
111!0 = !{!"clang version 4.0.0 "}
112!1 = !{!2, !2, i64 0}
113!2 = !{!"any pointer", !3, i64 0}
114!3 = !{!"omnipotent char", !4, i64 0}
115!4 = !{!"Simple C/C++ TBAA"}
116!5 = !{!6, !2, i64 8}
117!6 = !{!"_MUSIC_OP_API_", !2, i64 0, !2, i64 8}
118!7 = !{!8, !9, i64 16}
119!8 = !{!"__MUSIC_API", !2, i64 0, !2, i64 8, !9, i64 16, !10, i64 20, !2, i64 140, !2, i64 148}
120!9 = !{!"int", !3, i64 0}
121!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}
122!11 = !{!"_AAC_DEFAULT_SETTING", !9, i64 0, !9, i64 4, !9, i64 8}
123