• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -stop-after=virtregrewriter -o - | FileCheck %s
2;
3; Generated with "clang++ -g -O1 -S -emit-llvm"
4;
5; inline bool bar(char c) {
6;   return c >= '0' && c <= '9';
7; }
8;
9; unsigned foo(const char* data,
10;              int length,
11;              int* parsing_result) {
12;   unsigned value = 0;
13;   int result = 1;
14;   bool overflow = 0;
15;
16;   while (bar(*data)) {
17;     if (value > 1) {
18;       result = 2;
19;       overflow = 1;
20;     }
21;
22;     if (!overflow)
23;       value = value + 1;
24;   }
25;
26;   if (length == 0 || value) {
27;     if (!overflow)
28;       result = 0;
29;   } else {
30;     result = 1;
31;   }
32; bye:
33;   *parsing_result = result;
34;   return result == 0 ? value : 0;
35; }
36;
37; CHECK: {{^body:}}
38; CHECK: bye.thread21:
39; CHECK: DBG_LABEL !14
40; CHECK: if.then5:
41; CHECK: DBG_LABEL !14
42; CHECK-NOT: DBG_LABEL !14
43
44$_Z3barc = comdat any
45
46; Function Attrs: nounwind uwtable
47define dso_local i32 @_Z3fooPKciPi(i8* nocapture readonly %data, i32 %length, i32* nocapture %parsing_result) local_unnamed_addr !dbg !4 {
48entry:
49  %0 = load i8, i8* %data, align 1
50  %call23 = tail call zeroext i1 @_Z3barc(i8 signext %0), !dbg !15
51  br i1 %call23, label %while.body, label %while.end
52
53while.body:                                       ; preds = %entry, %while.body
54  %overflow.026 = phi i8 [ %spec.select18, %while.body ], [ 0, %entry ]
55  %result.025 = phi i32 [ %spec.select, %while.body ], [ 1, %entry ]
56  %value.024 = phi i32 [ %value.1, %while.body ], [ 0, %entry ]
57  %cmp = icmp ugt i32 %value.024, 1
58  %spec.select = select i1 %cmp, i32 2, i32 %result.025
59  %spec.select18 = select i1 %cmp, i8 1, i8 %overflow.026
60  %1 = and i8 %spec.select18, 1
61  %2 = xor i8 %1, 1
62  %3 = zext i8 %2 to i32
63  %value.1 = add i32 %value.024, %3
64  %4 = load i8, i8* %data, align 1
65  %call = tail call zeroext i1 @_Z3barc(i8 signext %4), !dbg !15
66  br i1 %call, label %while.body, label %while.end.loopexit
67
68while.end.loopexit:                               ; preds = %while.body
69  %phitmp = and i8 %spec.select18, 1
70  br label %while.end
71
72while.end:                                        ; preds = %while.end.loopexit, %entry
73  %value.0.lcssa = phi i32 [ 0, %entry ], [ %value.1, %while.end.loopexit ]
74  %result.0.lcssa = phi i32 [ 1, %entry ], [ %spec.select, %while.end.loopexit ]
75  %overflow.0.lcssa = phi i8 [ 0, %entry ], [ %phitmp, %while.end.loopexit ]
76  %cmp3 = icmp eq i32 %length, 0
77  %tobool4 = icmp ne i32 %value.0.lcssa, 0
78  %or.cond = or i1 %cmp3, %tobool4
79  br i1 %or.cond, label %if.then5, label %bye.thread21
80
81bye.thread21:                                     ; preds = %while.end
82  call void @llvm.dbg.label(metadata !14), !dbg !16
83  store i32 1, i32* %parsing_result, align 4
84  br label %6
85
86if.then5:                                         ; preds = %while.end
87  %tobool6 = icmp eq i8 %overflow.0.lcssa, 0
88  call void @llvm.dbg.label(metadata !14), !dbg !16
89  call void @llvm.dbg.label(metadata !14), !dbg !16
90  br i1 %tobool6, label %bye.thread, label %bye
91
92bye.thread:                                       ; preds = %if.then5
93  store i32 0, i32* %parsing_result, align 4
94  br label %5
95
96bye:                                              ; preds = %if.then5
97  store i32 %result.0.lcssa, i32* %parsing_result, align 4
98  %cmp10 = icmp eq i32 %result.0.lcssa, 0
99  br i1 %cmp10, label %5, label %6
100
101; <label>:5:                                      ; preds = %bye.thread, %bye
102  br label %6
103
104; <label>:6:                                      ; preds = %bye.thread21, %bye, %5
105  %7 = phi i32 [ %value.0.lcssa, %5 ], [ 0, %bye ], [ 0, %bye.thread21 ]
106  ret i32 %7
107}
108
109; Function Attrs: inlinehint nounwind uwtable
110define linkonce_odr dso_local zeroext i1 @_Z3barc(i8 signext %c) local_unnamed_addr comdat {
111entry:
112  %c.off = add i8 %c, -48
113  %0 = icmp ult i8 %c.off, 10
114  ret i1 %0
115}
116
117; Function Attrs: nounwind readnone speculatable
118declare void @llvm.dbg.label(metadata) #0
119
120attributes #0 = { nounwind readnone speculatable }
121
122!llvm.dbg.cu = !{!0}
123!llvm.module.flags = !{!3}
124
125!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
126!1 = !DIFile(filename: "live-debug-label.cc", directory: ".")
127!2 = !{}
128!3 = !{i32 2, !"Debug Info Version", i32 3}
129!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooPKciPi", scope: !1, file: !1, line: 5, type: !5, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !13)
130!5 = !DISubroutineType(types: !6)
131!6 = !{!7, !8, !11, !12}
132!7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
133!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)
134!9 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !10)
135!10 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
136!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
137!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)
138!13 = !{!14}
139!14 = !DILabel(scope: !4, name: "bye", file: !1, line: 28)
140!15 = !DILocation(line: 12, column: 10, scope: !4)
141!16 = !DILocation(line: 28, column: 1, scope: !4)
142