Home | History | Annotate | Download | only in Inline
      1 ; RUN: opt < %s -inline -scalarrepl -S | FileCheck %s
      2 target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
      3 
      4 define i32 @test1f(i32 %i) {
      5         ret i32 %i
      6 }
      7 
      8 define i32 @test1(i32 %W) {
      9         %X = call i32 @test1f(i32 7)
     10         %Y = add i32 %X, %W
     11         ret i32 %Y
     12 ; CHECK: @test1(
     13 ; CHECK-NEXT: %Y = add i32 7, %W
     14 ; CHECK-NEXT: ret i32 %Y
     15 }
     16 
     17 
     18 
     19 ; rdar://7339069
     20 
     21 %T = type { i32, i32 }
     22 
     23 ; CHECK-NOT: @test2f
     24 define internal %T* @test2f(i1 %cond, %T* %P) {
     25   br i1 %cond, label %T, label %F
     26   
     27 T:
     28   %A = getelementptr %T* %P, i32 0, i32 0
     29   store i32 42, i32* %A
     30   ret %T* %P
     31   
     32 F:
     33   ret %T* %P
     34 }
     35 
     36 define i32 @test2(i1 %cond) {
     37   %A = alloca %T
     38   
     39   %B = call %T* @test2f(i1 %cond, %T* %A)
     40   %C = getelementptr %T* %B, i32 0, i32 0
     41   %D = load i32* %C
     42   ret i32 %D
     43   
     44 ; CHECK: @test2(
     45 ; CHECK-NOT: = alloca
     46 ; CHECK: ret i32
     47 }
     48 
     49 declare void @barrier() noduplicate
     50 
     51 define internal i32 @f() {
     52   call void @barrier() noduplicate
     53   ret i32 1
     54 }
     55 
     56 define i32 @g() {
     57   call void @barrier() noduplicate
     58   ret i32 2
     59 }
     60 
     61 define internal i32 @h() {
     62   call void @barrier() noduplicate
     63   ret i32 3
     64 }
     65 
     66 define i32 @test3() {
     67   %b = call i32 @f()
     68   ret i32 %b
     69 }
     70 
     71 ; The call to @f cannot be inlined as there is another callsite
     72 ; calling @f, and @f contains a noduplicate call.
     73 ;
     74 ; The call to @g cannot be inlined as it has external linkage.
     75 ;
     76 ; The call to @h *can* be inlined.
     77 
     78 ; CHECK: @test
     79 define i32 @test() {
     80 ; CHECK: call i32 @f()
     81   %a = call i32 @f()
     82 ; CHECK: call i32 @g()
     83   %b = call i32 @g()
     84 ; CHECK-NOT: call i32 @h()
     85   %c = call i32 @h()
     86 
     87   %d = add i32 %a, %b
     88   %e = add i32 %d, %c
     89 
     90   ret i32 %e
     91 ; CHECK: }
     92 }
     93