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