1 ; RUN: opt -codegenprepare -S < %s | FileCheck %s
2 ; RUN: opt -strip-debug -codegenprepare -S < %s | FileCheck %s
3 ; REQUIRES: x86-registered-target
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
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
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"
25 ; Function Attrs: nounwind readnone speculatable
26 declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
28 ; Function Attrs: nounwind readnone speculatable
29 declare void @llvm.dbg.value(metadata, metadata, metadata) #0
31 ; Function Attrs: noinline nounwind uwtable
32 define dso_local void @foobar(i32* nocapture %arg0) local_unnamed_addr #0 {
36 while.cond: ; preds = %entry
37 switch i32 undef, label %sw.default [
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
46 while.cond.lbl_crit_edge: ; preds = %while.cond, %while.cond
49 while.cond134.preheader: ; preds = %while.cond
52 sw.bb: ; preds = %while.cond
53 call void @llvm.dbg.value(metadata i32 3, metadata !11, metadata !DIExpression()), !dbg !15
56 sw.bb29: ; preds = %while.cond, %while.cond
59 sw.default: ; preds = %while.cond
62 lbl: ; preds = %sw.bb, %while.cond.lbl_crit_edge
63 %var03.1 = phi i32 [ 0, %while.cond.lbl_crit_edge ], [ 3, %sw.bb ]
67 attributes #0 = { nounwind readnone speculatable }
70 !llvm.module.flags = !{!9, !10}
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: "./")
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)
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)
87 !15 = !DILocation(line: 4, column: 16, scope: !12)