Home | History | Annotate | Download | only in Other
      1 ; Test that patterns of transformations which disconnect a region of the call
      2 ; graph mid-traversal and then invalidate it function correctly.
      3 ;
      4 ; RUN: opt -S -passes='cgscc(inline,function(simplify-cfg))' < %s | FileCheck %s
      5 
      6 define internal void @test_scc_internal(i1 %flag) {
      7 ; CHECK-NOT: @test_scc_internal
      8 entry:
      9   br i1 %flag, label %then, label %else
     10 
     11 then:
     12   call void @test_scc_internal(i1 false)
     13   call void @test_scc_external()
     14   br label %else
     15 
     16 else:
     17   ret void
     18 }
     19 
     20 define void @test_scc_external() {
     21 ; CHECK-LABEL: define void @test_scc_external()
     22 entry:
     23   call void @test_scc_internal(i1 false)
     24   ret void
     25 }
     26 
     27 define internal void @test_refscc_internal(i1 %flag, i8* %ptr) {
     28 ; CHECK-NOT: @test_refscc_internal
     29 entry:
     30   br i1 %flag, label %then, label %else
     31 
     32 then:
     33   call void @test_refscc_internal(i1 false, i8* bitcast (i8* ()* @test_refscc_external to i8*))
     34   br label %else
     35 
     36 else:
     37   ret void
     38 }
     39 
     40 define i8* @test_refscc_external() {
     41 ; CHECK-LABEL: define i8* @test_refscc_external()
     42 entry:
     43   br i1 true, label %then, label %else
     44 ; CHECK-NEXT:  entry:
     45 ; CHECK-NEXT:    ret i8* null
     46 ; CHECK-NEXT:  }
     47 ; CHECK-NOT: @test_refscc_internal
     48 
     49 then:
     50   ret i8* null
     51 
     52 else:
     53   ret i8* bitcast (void (i1, i8*)* @test_refscc_internal to i8*)
     54 }
     55