Jonas Devlieghere | 42243df | 2018-08-07 12:14:01 +0000 | [diff] [blame] | 1 | ; RUN: opt -codegenprepare -S < %s | FileCheck %s |
| 2 | ; RUN: opt -strip-debug -codegenprepare -S < %s | FileCheck %s |
| 3 | ; REQUIRES: x86-registered-target |
| 4 | |
| 5 | ; In its current state, CodeGenPrepare should not optimize empty blocks after a switch |
| 6 | ; (See CodeGenPrepare::isMergingEmptyBlockProfitable) |
| 7 | ; This should also be the case when they contain debug information. (sw.bb block) |
| 8 | ; Check this by verifying that the switch labels remain the same |
| 9 | |
| 10 | ; CHECK: while.cond: |
| 11 | ; CHECK-NEXT: switch i32 undef, label %sw.default [ |
| 12 | ; CHECK-NEXT: i32 45, label %sw.bb |
| 13 | ; CHECK-NEXT: i32 104, label %while.cond.lbl_crit_edge |
| 14 | ; CHECK-NEXT: i32 122, label %while.cond.lbl_crit_edge |
| 15 | ; CHECK-NEXT: i32 115, label %while.cond134.preheader |
| 16 | ; CHECK-NEXT: i32 100, label %sw.bb29 |
| 17 | ; CHECK-NEXT: i32 105, label %sw.bb29 |
| 18 | ; CHECK-NEXT: ] |
| 19 | |
| 20 | ; ModuleID = 'bugpoint-reduced-instructions.bc' |
| 21 | source_filename = "foobar.c" |
| 22 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 23 | target triple = "x86_64-unknown-linux-gnu" |
| 24 | |
| 25 | ; Function Attrs: nounwind readnone speculatable |
| 26 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 |
| 27 | |
| 28 | ; Function Attrs: nounwind readnone speculatable |
| 29 | declare void @llvm.dbg.value(metadata, metadata, metadata) #0 |
| 30 | |
| 31 | ; Function Attrs: noinline nounwind uwtable |
| 32 | define dso_local void @foobar(i32* nocapture %arg0) local_unnamed_addr #0 { |
| 33 | entry: |
| 34 | br label %while.cond |
| 35 | |
| 36 | while.cond: ; preds = %entry |
| 37 | switch i32 undef, label %sw.default [ |
| 38 | i32 45, label %sw.bb |
| 39 | i32 104, label %while.cond.lbl_crit_edge |
| 40 | i32 122, label %while.cond.lbl_crit_edge |
| 41 | i32 115, label %while.cond134.preheader |
| 42 | i32 100, label %sw.bb29 |
| 43 | i32 105, label %sw.bb29 |
| 44 | ] |
| 45 | |
| 46 | while.cond.lbl_crit_edge: ; preds = %while.cond, %while.cond |
| 47 | br label %lbl |
| 48 | |
| 49 | while.cond134.preheader: ; preds = %while.cond |
| 50 | unreachable |
| 51 | |
| 52 | sw.bb: ; preds = %while.cond |
| 53 | call void @llvm.dbg.value(metadata i32 3, metadata !11, metadata !DIExpression()), !dbg !15 |
| 54 | br label %lbl |
| 55 | |
| 56 | sw.bb29: ; preds = %while.cond, %while.cond |
| 57 | unreachable |
| 58 | |
| 59 | sw.default: ; preds = %while.cond |
| 60 | unreachable |
| 61 | |
| 62 | lbl: ; preds = %sw.bb, %while.cond.lbl_crit_edge |
| 63 | %var03.1 = phi i32 [ 0, %while.cond.lbl_crit_edge ], [ 3, %sw.bb ] |
| 64 | unreachable |
| 65 | } |
| 66 | |
| 67 | attributes #0 = { nounwind readnone speculatable } |
| 68 | |
| 69 | !llvm.dbg.cu = !{!0} |
| 70 | !llvm.module.flags = !{!9, !10} |
| 71 | |
| 72 | !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version XXX ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, globals: !2) |
| 73 | !1 = !DIFile(filename: "foobar.c", directory: "./") |
| 74 | !2 = !{} |
| 75 | !3 = !{!4, !5} |
| 76 | !4 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 77 | !5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64) |
| 78 | !6 = !DISubroutineType(types: !7) |
| 79 | !7 = !{!4, !4, !8} |
| 80 | !8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) |
| 81 | !9 = !{i32 2, !"Debug Info Version", i32 3} |
| 82 | !10 = !{i32 1, !"wchar_size", i32 4} |
| 83 | !11 = !DILocalVariable(name: "var03", scope: !12, file: !1, line: 3, type: !4) |
| 84 | !12 = distinct !DISubprogram(name: "foobar", scope: !1, file: !1, line: 2, type: !13, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) |
| 85 | !13 = !DISubroutineType(types: !14) |
| 86 | !14 = !{null, !5, !8} |
| 87 | !15 = !DILocation(line: 4, column: 16, scope: !12) |