brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.5 KiB · 3121b87 Raw
152 lines · plain
1; RUN: llc < %s -stop-after=virtregrewriter -o - | FileCheck %s2;3; NVPTX produces a different order of the BBs4; XFAIL: target=nvptx{{.*}}5; Both RISC-V and AMDGPU(GCN) deploy two VirtRegRewriter in their codegen6; pipeline. This test prematurely stops at the first one, which doesn't cleanup7; the virtual register map and cause an assertion failure. Ideally we can solve8; this by teaching `-stop-after` how to stop at the last instance of a Pass,9; but we're just marking XFAIL for these two targets for now.10; XFAIL: target=riscv{{.*}}11; XFAIL: target=amdgcn-{{.*}}12 13; Generated with "clang++ -g -O1 -S -emit-llvm"14;15; inline bool bar(char c) {16;   return c >= '0' && c <= '9';17; }18;19; unsigned foo(const char* data,20;              int length,21;              int* parsing_result) {22;   unsigned value = 0;23;   int result = 1;24;   bool overflow = 0;25;26;   while (bar(*data)) {27;     if (value > 1) {28;       result = 2;29;       overflow = 1;30;     }31;32;     if (!overflow)33;       value = value + 1;34;   }35;36;   if (length == 0 || value) {37;     if (!overflow)38;       result = 0;39;   } else {40;     result = 1;41;   }42; bye:43;   *parsing_result = result;44;   return result == 0 ? value : 0;45; }46;47; CHECK: {{^body:}}48; CHECK: bye.thread21:49; CHECK: DBG_LABEL !1450; CHECK: if.then5:51; CHECK: DBG_LABEL !1452; CHECK-NOT: DBG_LABEL !1453 54$_Z3barc = comdat any55 56; Function Attrs: nounwind uwtable57define dso_local i32 @_Z3fooPKciPi(ptr nocapture readonly %data, i32 %length, ptr nocapture %parsing_result) local_unnamed_addr !dbg !4 {58entry:59  %0 = load i8, ptr %data, align 160  %call23 = tail call zeroext i1 @_Z3barc(i8 signext %0), !dbg !1561  br i1 %call23, label %while.body, label %while.end62 63while.body:                                       ; preds = %entry, %while.body64  %overflow.026 = phi i8 [ %spec.select18, %while.body ], [ 0, %entry ]65  %result.025 = phi i32 [ %spec.select, %while.body ], [ 1, %entry ]66  %value.024 = phi i32 [ %value.1, %while.body ], [ 0, %entry ]67  %cmp = icmp ugt i32 %value.024, 168  %spec.select = select i1 %cmp, i32 2, i32 %result.02569  %spec.select18 = select i1 %cmp, i8 1, i8 %overflow.02670  %1 = and i8 %spec.select18, 171  %2 = xor i8 %1, 172  %3 = zext i8 %2 to i3273  %value.1 = add i32 %value.024, %374  %4 = load i8, ptr %data, align 175  %call = tail call zeroext i1 @_Z3barc(i8 signext %4), !dbg !1576  br i1 %call, label %while.body, label %while.end.loopexit77 78while.end.loopexit:                               ; preds = %while.body79  %phitmp = and i8 %spec.select18, 180  br label %while.end81 82while.end:                                        ; preds = %while.end.loopexit, %entry83  %value.0.lcssa = phi i32 [ 0, %entry ], [ %value.1, %while.end.loopexit ]84  %result.0.lcssa = phi i32 [ 1, %entry ], [ %spec.select, %while.end.loopexit ]85  %overflow.0.lcssa = phi i8 [ 0, %entry ], [ %phitmp, %while.end.loopexit ]86  %cmp3 = icmp eq i32 %length, 087  %tobool4 = icmp ne i32 %value.0.lcssa, 088  %or.cond = or i1 %cmp3, %tobool489  br i1 %or.cond, label %if.then5, label %bye.thread2190 91bye.thread21:                                     ; preds = %while.end92  call void @llvm.dbg.label(metadata !14), !dbg !1693  store i32 1, ptr %parsing_result, align 494  br label %695 96if.then5:                                         ; preds = %while.end97  %tobool6 = icmp eq i8 %overflow.0.lcssa, 098  call void @llvm.dbg.label(metadata !14), !dbg !1699  call void @llvm.dbg.label(metadata !14), !dbg !16100  br i1 %tobool6, label %bye.thread, label %bye101 102bye.thread:                                       ; preds = %if.then5103  store i32 0, ptr %parsing_result, align 4104  br label %5105 106bye:                                              ; preds = %if.then5107  store i32 %result.0.lcssa, ptr %parsing_result, align 4108  %cmp10 = icmp eq i32 %result.0.lcssa, 0109  br i1 %cmp10, label %5, label %6110 111; <label>:5:                                      ; preds = %bye.thread, %bye112  br label %6113 114; <label>:6:                                      ; preds = %bye.thread21, %bye, %5115  %7 = phi i32 [ %value.0.lcssa, %5 ], [ 0, %bye ], [ 0, %bye.thread21 ]116  ret i32 %7117}118 119; Function Attrs: inlinehint nounwind uwtable120define linkonce_odr dso_local zeroext i1 @_Z3barc(i8 signext %c) local_unnamed_addr comdat {121entry:122  %c.off = add i8 %c, -48123  %0 = icmp ult i8 %c.off, 10124  ret i1 %0125}126 127; Function Attrs: nounwind readnone speculatable128declare void @llvm.dbg.label(metadata) #0129 130attributes #0 = { nounwind readnone speculatable }131 132!llvm.dbg.cu = !{!0}133!llvm.module.flags = !{!3}134 135!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)136!1 = !DIFile(filename: "live-debug-label.cc", directory: ".")137!2 = !{}138!3 = !{i32 2, !"Debug Info Version", i32 3}139!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)140!5 = !DISubroutineType(types: !6)141!6 = !{!7, !8, !11, !12}142!7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)143!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)144!9 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !10)145!10 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)146!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)147!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)148!13 = !{!14}149!14 = !DILabel(scope: !4, name: "bye", file: !1, line: 28)150!15 = !DILocation(line: 12, column: 10, scope: !4)151!16 = !DILocation(line: 28, column: 1, scope: !4)152