brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 2c2743f Raw
96 lines · plain
1; RUN: llc -relocation-model=static -verify-machineinstrs < %s -mcpu=pwr7 | FileCheck %s2; RUN: llc -relocation-model=static -verify-machineinstrs < %s -code-model=small -mcpu=pwr7 | FileCheck %s -check-prefix=SCM3 4target 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"5target triple = "powerpc64-unknown-linux-gnu"6 7 8define dso_local void @foo() nounwind noinline {9  ret void10}11 12define weak void @foo_weak() nounwind {13  ret void14}15 16; Calls to local function does not require the TOC restore 'nop'17define dso_local void @test_direct() nounwind readnone {18; CHECK-LABEL: test_direct:19  tail call void @foo() nounwind20; Because of tail call optimization, it can be 'b' instruction.21; CHECK: [[BR:b[l]?]] foo22; CHECK-NOT: nop23  ret void24}25 26; Calls to weak function requires a TOC restore 'nop' with all code models27; because the definition that gets choosen at link time may come from a28; different compilation unit that was compiled with PC Relative and has no TOC.29define dso_local void @test_weak() nounwind readnone {30  tail call void @foo_weak() nounwind31; CHECK-LABEL: test_weak:32; CHECK:       bl foo_weak33; CHECK-NEXT:  nop34 35; SCM-LABEL: test_weak:36; SCM:       bl foo_weak37; SCM-NEXT:  nop38  ret void39}40 41; Indirect calls requires a full stub creation42define dso_local void @test_indirect(ptr nocapture %fp) nounwind {43; CHECK-LABEL: test_indirect:44  tail call void %fp() nounwind45; CHECK: ld 2, 8(3)46; CHECK: ld 11, 16(3)47; CHECK: ld [[FP:[0-9]+]], 0(3)48; CHECK-NEXT: mtctr [[FP]]49; CHECK-NEXT: bctrl50; CHECK-NEXT: ld 2, 40(1)51  ret void52}53 54; Absolute values must use the regular indirect call sequence55; The main purpose of this test is to ensure that BLA is not56; used on 64-bit SVR4 (as e.g. on Darwin).57define dso_local void @test_abs() nounwind {58; CHECK-LABEL: test_abs:59  tail call void inttoptr (i64 1024 to ptr)() nounwind60; CHECK: ld [[FP:[0-9]+]], 1024(0)61; CHECK: ld 11, 1040(0)62; CHECK-NEXT: mtctr [[FP]]63; CHECK: ld 2, 1032(0)64; CHECK-NEXT: bctrl65; CHECK-NEXT: ld 2, 40(1)66  ret void67}68 69declare double @sin(double) nounwind70 71; External functions call should also have a 'nop'72define double @test_external(double %x) nounwind {73; CHECK-LABEL: test_external:74  %call = tail call double @sin(double %x) nounwind75; CHECK: bl sin76; CHECK-NEXT: nop77  ret double %call78}79 80; The 'ld 2, 40(1)' really must always come directly after the bctrl to make81; the unwinding code in libgcc happy.82@g = external global ptr83declare void @h(i64)84define dso_local void @test_indir_toc_reload(i64 %x) {85  %1 = load ptr, ptr @g86  call void %1()87  call void @h(i64 %x)88  ret void89 90; CHECK-LABEL: @test_indir_toc_reload91; CHECK: bctrl92; CHECK-NEXT: ld 2, 40(1)93; CHECK: blr94}95 96