Home | History | Annotate | Download | only in PowerPC
      1 ; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 | FileCheck %s
      2 ; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=a2 | FileCheck -check-prefix=CHECK-NOAV %s
      3 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
      4 target triple = "powerpc64-unknown-linux-gnu"
      5 
      6 %struct.__jmp_buf_tag = type { [64 x i64], i32, %struct.__sigset_t, [8 x i8] }
      7 %struct.__sigset_t = type { [16 x i64] }
      8 
      9 @env_sigill = internal global [1 x %struct.__jmp_buf_tag] zeroinitializer, align 16
     10 
     11 define void @foo() #0 {
     12 entry:
     13   call void @llvm.eh.sjlj.longjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*))
     14   unreachable
     15 
     16 ; CHECK: @foo
     17 ; CHECK: addis [[REG:[0-9]+]], 2, env_sigill@toc@ha
     18 ; CHECK: addi [[REG]], [[REG]], env_sigill@toc@l
     19 ; CHECK: ld 31, 0([[REG]])
     20 ; CHECK: ld [[REG2:[0-9]+]], 8([[REG]])
     21 ; CHECK: ld 1, 16([[REG]])
     22 ; CHECK: mtctr [[REG2]]
     23 ; CHECK: ld 30, 32([[REG]])
     24 ; CHECK: ld 2, 24([[REG]])
     25 ; CHECK: bctr
     26 
     27 return:                                           ; No predecessors!
     28   ret void
     29 }
     30 
     31 declare void @llvm.eh.sjlj.longjmp(i8*) #1
     32 
     33 define signext i32 @main() #0 {
     34 entry:
     35   %retval = alloca i32, align 4
     36   store i32 0, i32* %retval
     37   %0 = call i8* @llvm.frameaddress(i32 0)
     38   store i8* %0, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**)
     39   %1 = call i8* @llvm.stacksave()
     40   store i8* %1, i8** getelementptr (i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**), i32 2)
     41   %2 = call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*))
     42   %tobool = icmp ne i32 %2, 0
     43   br i1 %tobool, label %if.then, label %if.else
     44 
     45 if.then:                                          ; preds = %entry
     46   store i32 1, i32* %retval
     47   br label %return
     48 
     49 if.else:                                          ; preds = %entry
     50   call void @foo()
     51   br label %if.end
     52 
     53 if.end:                                           ; preds = %if.else
     54   store i32 0, i32* %retval
     55   br label %return
     56 
     57 return:                                           ; preds = %if.end, %if.then
     58   %3 = load i32* %retval
     59   ret i32 %3
     60 
     61 ; FIXME: We should be saving VRSAVE on Darwin, but we're not!
     62 
     63 ; CHECK: @main
     64 ; CHECK: std
     65 ; Make sure that we're not saving VRSAVE on non-Darwin:
     66 ; CHECK-NOT: mfspr
     67 ; CHECK: stfd
     68 ; CHECK: stvx
     69 
     70 ; CHECK: addis [[REG:[0-9]+]], 2, env_sigill@toc@ha
     71 ; CHECK: std 31, env_sigill@toc@l([[REG]])
     72 ; CHECK: addi [[REG]], [[REG]], env_sigill@toc@l
     73 ; CHECK: std [[REG]], [[OFF:[0-9]+]](31)                  # 8-byte Folded Spill
     74 ; CHECK: std 1, 16([[REG]])
     75 ; CHECK: std 2, 24([[REG]])
     76 ; CHECK: bcl 20, 31, .LBB1_1
     77 ; CHECK: li 3, 1
     78 ; CHECK: #EH_SjLj_Setup	.LBB1_1
     79 ; CHECK: b .LBB1_2
     80 
     81 ; CHECK: .LBB1_1:
     82 ; CHECK: mflr [[REGL:[0-9]+]]
     83 ; CHECK: ld [[REG2:[0-9]+]], [[OFF]](31)                   # 8-byte Folded Reload
     84 ; CHECK: std [[REGL]], 8([[REG2]])
     85 ; CHECK: li 3, 0
     86 
     87 ; CHECK: .LBB1_2:
     88 
     89 ; CHECK: lfd
     90 ; CHECK: lvx
     91 ; CHECK: ld
     92 ; CHECK: blr
     93 
     94 ; CHECK-NOAV: @main
     95 ; CHECK-NOAV-NOT: stvx
     96 ; CHECK-NOAV: bcl
     97 ; CHECK-NOAV: mflr
     98 ; CHECK-NOAV: bl foo
     99 ; CHECK-NOAV-NOT: lvx
    100 ; CHECK-NOAV: blr
    101 }
    102 
    103 define signext i32 @main2() #0 {
    104 entry:
    105   %a = alloca i8, align 64
    106   call void @bar(i8* %a)
    107   %retval = alloca i32, align 4
    108   store i32 0, i32* %retval
    109   %0 = call i8* @llvm.frameaddress(i32 0)
    110   store i8* %0, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**)
    111   %1 = call i8* @llvm.stacksave()
    112   store i8* %1, i8** getelementptr (i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**), i32 2)
    113   %2 = call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*))
    114   %tobool = icmp ne i32 %2, 0
    115   br i1 %tobool, label %if.then, label %if.else
    116 
    117 if.then:                                          ; preds = %entry
    118   store i32 1, i32* %retval
    119   br label %return
    120 
    121 if.else:                                          ; preds = %entry
    122   call void @foo()
    123   br label %if.end
    124 
    125 if.end:                                           ; preds = %if.else
    126   store i32 0, i32* %retval
    127   br label %return
    128 
    129 return:                                           ; preds = %if.end, %if.then
    130   %3 = load i32* %retval
    131   ret i32 %3
    132 
    133 ; CHECK: @main2
    134 
    135 ; CHECK: addis [[REG:[0-9]+]], 2, env_sigill@toc@ha
    136 ; CHECK: std 31, env_sigill@toc@l([[REG]])
    137 ; CHECK: addi [[REG]], [[REG]], env_sigill@toc@l
    138 ; CHECK: std [[REG]], [[OFF:[0-9]+]](31)                  # 8-byte Folded Spill
    139 ; CHECK: std 1, 16([[REG]])
    140 ; CHECK: std 2, 24([[REG]])
    141 ; CHECK: std 30, 32([[REG]])
    142 ; CHECK: bcl 20, 31,
    143 
    144 ; CHECK: blr
    145 }
    146 
    147 declare void @bar(i8*) #3
    148 
    149 declare i8* @llvm.frameaddress(i32) #2
    150 
    151 declare i8* @llvm.stacksave() #3
    152 
    153 declare i32 @llvm.eh.sjlj.setjmp(i8*) #3
    154 
    155 attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
    156 attributes #1 = { noreturn nounwind }
    157 attributes #2 = { nounwind readnone }
    158 attributes #3 = { nounwind }
    159 
    160