Home | History | Annotate | Download | only in AArch64
      1 # RUN: llc -mtriple=aarch64-apple-darwin -run-pass=prologepilog \
      2 # RUN: -run-pass=machine-outliner -verify-machineinstrs %s -o - | FileCheck %s
      3 # Check that we save LR to a callee-saved register when possible.
      4 # foo() should use a callee-saved register. However, bar() should not.
      5 --- |  
      6   
      7   define void @foo() #0 {
      8     ret void
      9   }
     10 
     11   define void @bar() #0 {
     12     ret void
     13   }
     14 
     15   attributes #0 = { minsize noinline noredzone "no-frame-pointer-elim"="true" }
     16 ...
     17 ---
     18 # Make sure that when we outline and a register is available, we
     19 # use it to save + restore LR instead of SP.
     20 # CHECK: name:            foo
     21 # CHECK-DAG: bb.0
     22 # CHECK-DAG: $x[[REG:[0-9]+]] = ORRXrs $xzr, $lr, 0
     23 # CHECK-NEXT: BL
     24 # CHECK-NEXT: $lr = ORRXrs $xzr, $x[[REG]], 0
     25 # CHECK-DAG: bb.1
     26 # CHECK-DAG: $x[[REG]] = ORRXrs $xzr, $lr, 0
     27 # CHECK-NEXT: BL
     28 # CHECK-NEXT: $lr = ORRXrs $xzr, $x[[REG]], 0
     29 # CHECK-DAG: bb.2
     30 # CHECK-DAG: $x[[REG]] = ORRXrs $xzr, $lr, 0
     31 # CHECK-NEXT: BL
     32 # CHECK-NEXT: $lr = ORRXrs $xzr, $x[[REG]], 0
     33 name:            foo
     34 tracksRegLiveness: true
     35 fixedStack:      
     36 body:             |
     37   bb.0:
     38     liveins: $lr, $w9
     39     $x25 = ORRXri $xzr, 1
     40     $w9 = ORRWri $wzr, 1
     41     $w9 = ORRWri $wzr, 1
     42     $w9 = ORRWri $wzr, 1
     43     $w9 = ORRWri $wzr, 1
     44     $w9 = ORRWri $wzr, 1
     45     $w9 = ORRWri $wzr, 2
     46   bb.1:
     47     liveins: $lr, $w9
     48     $w9 = ORRWri $wzr, 1
     49     $w9 = ORRWri $wzr, 1
     50     $w9 = ORRWri $wzr, 1
     51     $w9 = ORRWri $wzr, 1
     52     $w9 = ORRWri $wzr, 1
     53     $w9 = ORRWri $wzr, 2
     54   bb.2:
     55     liveins: $lr, $w9
     56     $w9 = ORRWri $wzr, 1
     57     $w9 = ORRWri $wzr, 1
     58     $w9 = ORRWri $wzr, 1
     59     $w9 = ORRWri $wzr, 1
     60     $w9 = ORRWri $wzr, 1
     61     $w9 = ORRWri $wzr, 2
     62     RET undef $lr
     63 
     64 ...
     65 ---
     66 # Convoluted case that shows that we'll still save to the stack when there are
     67 # no approprate registers available.
     68 # The live-in lists do not contain x16 or x17 since including them would cause
     69 # nothing to be outlined.
     70 # They also deliberately don't contain x18 to show that on Darwin we won't store
     71 # to that.
     72 # CHECK-LABEL: name:            bar
     73 # CHECK: early-clobber $sp = STRXpre $lr, $sp, -16
     74 # CHECK-NEXT: BL
     75 # CHECK-DAG: early-clobber $sp, $lr = LDRXpost $sp, 16
     76 # CHECK: early-clobber $sp = STRXpre $lr, $sp, -16
     77 # CHECK-NEXT: BL
     78 # CHECK-DAG: early-clobber $sp, $lr = LDRXpost $sp, 16
     79 # CHECK: early-clobber $sp = STRXpre $lr, $sp, -16
     80 # CHECK-NEXT: BL
     81 # CHECK-NEXT: early-clobber $sp, $lr = LDRXpost $sp, 16
     82 name:            bar
     83 tracksRegLiveness: true
     84 body:             |
     85   bb.0:
     86     liveins: $lr, $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x19, $x20, $x21, $x22, $x23, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27, $x28
     87     $w10 = ORRWri $wzr, 1
     88     $w10 = ORRWri $wzr, 1
     89     $w10 = ORRWri $wzr, 1
     90     $w10 = ORRWri $wzr, 1
     91     $w10 = ORRWri $wzr, 1
     92     $w12 = ORRWri $wzr, 2
     93   bb.1:
     94     liveins: $lr, $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x19, $x20, $x21, $x22, $x23, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27, $x28
     95     $w10 = ORRWri $wzr, 1
     96     $w10 = ORRWri $wzr, 1
     97     $w10 = ORRWri $wzr, 1
     98     $w10 = ORRWri $wzr, 1
     99     $w10 = ORRWri $wzr, 1
    100     $w12 = ORRWri $wzr, 2
    101   bb.2:
    102     liveins: $lr, $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x19, $x20, $x21, $x22, $x23, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27, $x28
    103     $w10 = ORRWri $wzr, 1
    104     $w10 = ORRWri $wzr, 1
    105     $w10 = ORRWri $wzr, 1
    106     $w10 = ORRWri $wzr, 1
    107     $w10 = ORRWri $wzr, 1
    108     $w12 = ORRWri $wzr, 2
    109   bb.3:
    110     liveins: $lr, $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x19, $x20, $x21, $x22, $x23, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27, $x28
    111     RET undef $lr
    112 
    113