Home | History | Annotate | Download | only in SimplifyCFG
      1 ; Test CFG simplify removal of branch instructions.
      2 ;
      3 ; RUN: opt < %s -simplifycfg -S | FileCheck %s
      4 ; RUN: opt < %s -passes=simplify-cfg -S | FileCheck %s
      5 
      6 define void @test1() {
      7         br label %1
      8         ret void
      9 ; CHECK-LABEL: @test1(
     10 ; CHECK-NEXT: ret void
     11 }
     12 
     13 define void @test2() {
     14         ret void
     15         ret void
     16 ; CHECK-LABEL: @test2(
     17 ; CHECK-NEXT: ret void
     18 ; CHECK-NEXT: }
     19 }
     20 
     21 define void @test3(i1 %T) {
     22         br i1 %T, label %1, label %1
     23         ret void
     24 ; CHECK-LABEL: @test3(
     25 ; CHECK-NEXT: ret void
     26 }
     27 
     28 
     29 ; PR5795
     30 define void @test5(i32 %A) {
     31   switch i32 %A, label %return [
     32     i32 2, label %1
     33     i32 10, label %2
     34   ]
     35 
     36   ret void
     37 
     38   ret void
     39 
     40 return:                                           ; preds = %entry
     41   ret void
     42 ; CHECK-LABEL: @test5(
     43 ; CHECK-NEXT: ret void
     44 }
     45 
     46 
     47 ; PR14893
     48 define i8 @test6f() {
     49 ; CHECK-LABEL: @test6f
     50 ; CHECK: alloca i8, align 1
     51 ; CHECK-NEXT: call i8 @test6g
     52 ; CHECK-NEXT: icmp eq i8 %tmp, 0
     53 ; CHECK-NEXT: load i8, i8* %r, align 1, !dbg !{{[0-9]+$}}
     54 
     55 bb0:
     56   %r = alloca i8, align 1
     57   %tmp = call i8 @test6g(i8* %r)
     58   %tmp1 = icmp eq i8 %tmp, 0
     59   br i1 %tmp1, label %bb2, label %bb1
     60 bb1:
     61   %tmp3 = load i8, i8* %r, align 1, !range !2, !tbaa !1, !dbg !5
     62   %tmp4 = icmp eq i8 %tmp3, 1
     63   br i1 %tmp4, label %bb2, label %bb3
     64 bb2:
     65   br label %bb3
     66 bb3:
     67   %tmp6 = phi i8 [ 0, %bb2 ], [ 1, %bb1 ]
     68   ret i8 %tmp6
     69 }
     70 declare i8 @test6g(i8*)
     71 
     72 !llvm.dbg.cu = !{!3}
     73 !llvm.module.flags = !{!8, !9}
     74 
     75 !0 = !{!1, !1, i64 0}
     76 !1 = !{!"foo"}
     77 !2 = !{i8 0, i8 2}
     78 !3 = distinct !DICompileUnit(language: DW_LANG_C99, file: !7, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !4, subprograms: !4, globals: !4)
     79 !4 = !{}
     80 !5 = !DILocation(line: 23, scope: !6)
     81 !6 = distinct !DISubprogram(name: "foo", scope: !3, file: !7, line: 1, type: !DISubroutineType(types: !4), isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, variables: !4)
     82 !7 = !DIFile(filename: "foo.c", directory: "/")
     83 !8 = !{i32 2, !"Dwarf Version", i32 2}
     84 !9 = !{i32 2, !"Debug Info Version", i32 3}
     85