• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -verify-machineinstrs -mtriple=i686-linux < %s | FileCheck --implicit-check-not="jmp.*\*" --implicit-check-not="call.*\*" %s
2
3; Test 32-bit retpoline when -mregparm=3 is used. This case is interesting
4; because there are no available scratch registers.  The Linux kernel builds
5; with -mregparm=3, so we need to support it.  TCO should fail because we need
6; to restore EDI.
7
8define void @call_edi(void (i32, i32, i32)* %fp) #0 {
9entry:
10  tail call void %fp(i32 inreg 0, i32 inreg 0, i32 inreg 0)
11  ret void
12}
13
14; CHECK-LABEL: call_edi:
15;     EDI is used, so it must be saved.
16; CHECK: pushl %edi
17; CHECK-DAG: xorl %eax, %eax
18; CHECK-DAG: xorl %edx, %edx
19; CHECK-DAG: xorl %ecx, %ecx
20; CHECK-DAG: movl {{.*}}, %edi
21; CHECK: calll __llvm_retpoline_edi
22; CHECK: popl %edi
23; CHECK: retl
24
25define void @edi_external(void (i32, i32, i32)* %fp) #1 {
26entry:
27  tail call void %fp(i32 inreg 0, i32 inreg 0, i32 inreg 0)
28  ret void
29}
30
31; CHECK-LABEL: edi_external:
32; CHECK: pushl %edi
33; CHECK-DAG: xorl %eax, %eax
34; CHECK-DAG: xorl %edx, %edx
35; CHECK-DAG: xorl %ecx, %ecx
36; CHECK-DAG: movl {{.*}}, %edi
37; CHECK: calll __x86_indirect_thunk_edi
38; CHECK: popl %edi
39; CHECK: retl
40
41attributes #0 = { "target-features"="+retpoline-indirect-calls" }
42attributes #1 = { "target-features"="+retpoline-indirect-calls,+retpoline-external-thunk" }
43