Home | History | Annotate | Download | only in PowerPC
      1 ; RUN: llc < %s -march=ppc64 | FileCheck %s
      2 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-v128:128:128-n32:64"
      3 target triple = "powerpc64-unknown-linux-gnu"
      4 
      5 define void @foo() nounwind readnone noinline {
      6   ret void
      7 }
      8 
      9 define weak void @foo_weak() nounwind {
     10   ret void
     11 }
     12 
     13 ; Calls to local function does not require the TOC restore 'nop'
     14 define void @test_direct() nounwind readnone {
     15 ; CHECK-LABEL: test_direct:
     16   tail call void @foo() nounwind
     17 ; CHECK: bl foo
     18 ; CHECK-NOT: nop
     19   ret void
     20 }
     21 
     22 ; Calls to weak function requires a TOC restore 'nop' because they
     23 ; may be overridden in a different module.
     24 define void @test_weak() nounwind readnone {
     25 ; CHECK-LABEL: test_weak:
     26   tail call void @foo_weak() nounwind
     27 ; CHECK: bl foo
     28 ; CHECK-NEXT: nop
     29   ret void
     30 }
     31 
     32 ; Indirect calls requires a full stub creation
     33 define void @test_indirect(void ()* nocapture %fp) nounwind {
     34 ; CHECK-LABEL: test_indirect:
     35   tail call void %fp() nounwind
     36 ; CHECK: ld [[FP:[0-9]+]], 0(3)
     37 ; CHECK: ld 11, 16(3)
     38 ; CHECK: ld 2, 8(3)
     39 ; CHECK-NEXT: mtctr [[FP]]
     40 ; CHECK-NEXT: bctrl
     41 ; CHECK-NEXT: ld 2, 40(1)
     42   ret void
     43 }
     44 
     45 ; Absolute vales should be have the TOC restore 'nop'
     46 define void @test_abs() nounwind {
     47 ; CHECK-LABEL: test_abs:
     48   tail call void inttoptr (i64 1024 to void ()*)() nounwind
     49 ; CHECK: bla 1024
     50 ; CHECK-NEXT: nop
     51   ret void
     52 }
     53 
     54 declare double @sin(double) nounwind
     55 
     56 ; External functions call should also have a 'nop'
     57 define double @test_external(double %x) nounwind {
     58 ; CHECK-LABEL: test_external:
     59   %call = tail call double @sin(double %x) nounwind
     60 ; CHECK: bl sin
     61 ; CHECK-NEXT: nop
     62   ret double %call
     63 }
     64