Home | History | Annotate | Download | only in X86
      1 ; RUN: llc -enable-machine-outliner -mtriple=x86_64-apple-darwin < %s | FileCheck %s
      2 
      3 @x = global i32 0, align 4
      4 
      5 define i32 @check_boundaries() #0 {
      6   ; CHECK-LABEL: _check_boundaries:
      7   %1 = alloca i32, align 4
      8   %2 = alloca i32, align 4
      9   %3 = alloca i32, align 4
     10   %4 = alloca i32, align 4
     11   %5 = alloca i32, align 4
     12   store i32 0, i32* %1, align 4
     13   store i32 0, i32* %2, align 4
     14   %6 = load i32, i32* %2, align 4
     15   %7 = icmp ne i32 %6, 0
     16   br i1 %7, label %9, label %8
     17 
     18   ; CHECK: callq 
     19   ; CHECK-SAME: [[OFUNC1:OUTLINED_FUNCTION_[0-9]+]]
     20   ; CHECK: cmpl  $0, -{{[0-9]+}}(%rbp)
     21   store i32 1, i32* %2, align 4
     22   store i32 2, i32* %3, align 4
     23   store i32 3, i32* %4, align 4
     24   store i32 4, i32* %5, align 4
     25   br label %10
     26 
     27   store i32 1, i32* %4, align 4
     28   br label %10
     29 
     30   %11 = load i32, i32* %2, align 4
     31   %12 = icmp ne i32 %11, 0
     32   br i1 %12, label %14, label %13
     33 
     34   ; CHECK: callq
     35   ; CHECK-SAME: [[OFUNC1]]
     36   store i32 1, i32* %2, align 4
     37   store i32 2, i32* %3, align 4
     38   store i32 3, i32* %4, align 4
     39   store i32 4, i32* %5, align 4
     40   br label %15
     41 
     42   store i32 1, i32* %4, align 4
     43   br label %15
     44 
     45   ret i32 0
     46 }
     47 
     48 define i32 @empty_1() #0 {
     49   ; CHECK-LABEL: _empty_1:
     50   ; CHECK-NOT: OUTLINED_FUNCTION
     51   ret i32 1
     52 }
     53 
     54 define i32 @empty_2() #0 {
     55   ; CHECK-LABEL: _empty_2
     56   ; CHECK-NOT: OUTLINED_FUNCTION
     57   ret i32 1
     58 }
     59 
     60 define i32 @no_empty_outlining() #0 {
     61   ; CHECK-LABEL: _no_empty_outlining:
     62   %1 = alloca i32, align 4
     63   store i32 0, i32* %1, align 4
     64   ; CHECK-NOT: OUTLINED_FUNCTION
     65   %2 = call i32 @empty_1() #1
     66   %3 = call i32 @empty_2() #1
     67   %4 = call i32 @empty_1() #1
     68   %5 = call i32 @empty_2() #1
     69   %6 = call i32 @empty_1() #1
     70   %7 = call i32 @empty_2() #1
     71   ret i32 0
     72 }
     73 
     74 define i32 @main() #0 {
     75   ; CHECK-LABEL: _main:
     76   %1 = alloca i32, align 4
     77   %2 = alloca i32, align 4
     78   %3 = alloca i32, align 4
     79   %4 = alloca i32, align 4
     80   %5 = alloca i32, align 4
     81 
     82   store i32 0, i32* %1, align 4
     83   store i32 0, i32* @x, align 4
     84   ; CHECK: callq
     85   ; CHECK-SAME: [[OFUNC2:OUTLINED_FUNCTION_[0-9]+]]
     86   store i32 1, i32* %2, align 4
     87   store i32 2, i32* %3, align 4
     88   store i32 3, i32* %4, align 4
     89   store i32 4, i32* %5, align 4
     90   store i32 1, i32* @x, align 4
     91   call void asm sideeffect "", "~{memory},~{dirflag},~{fpsr},~{flags}"()
     92   ; CHECK: callq
     93   ; CHECK-SAME: [[OFUNC2]]
     94   store i32 1, i32* %2, align 4
     95   store i32 2, i32* %3, align 4
     96   store i32 3, i32* %4, align 4
     97   store i32 4, i32* %5, align 4
     98   ret i32 0
     99 }
    100 
    101 attributes #0 = { noredzone nounwind ssp uwtable "no-frame-pointer-elim"="true" }
    102 
    103 ; CHECK: OUTLINED_FUNCTION_{{[0-9]+}}:
    104 ; CHECK-DAG:      movl  $1, -{{[0-9]+}}(%rbp)
    105 ; CHECK-NEXT: movl  $2, -{{[0-9]+}}(%rbp)
    106 ; CHECK-NEXT: movl  $3, -{{[0-9]+}}(%rbp)
    107 ; CHECK-NEXT: movl  $4, -{{[0-9]+}}(%rbp)
    108 ; CHECK-NEXT: retq
    109 
    110 ; CHECK: OUTLINED_FUNCTION_{{[0-9]+}}:
    111 ; CHECK-DAG:      movl  $1, -{{[0-9]+}}(%rbp)
    112 ; CHECK-NEXT: movl  $2, -{{[0-9]+}}(%rbp)
    113 ; CHECK-NEXT: movl  $3, -{{[0-9]+}}(%rbp)
    114 ; CHECK-NEXT: movl  $4, -{{[0-9]+}}(%rbp)
    115 ; CHECK-NEXT: retq
    116