1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
; RUN: llc -verify-machineinstrs < %s -mtriple=i686-win32 | FileCheck %s
; RUN: llc -verify-machineinstrs < %s -mtriple=i686-win32 -O0 | FileCheck %s
; IR simplified from the following C++ snippet compiled for i686-windows-msvc:
; struct A { A(); ~A(); int a; };
;
; struct B {
; virtual int f(int);
; virtual int g(A, int, A);
; virtual void h(A, int, A);
; virtual A i(A, int, A);
; virtual A j(int);
; };
;
; int (B::*mp_f)(int) = &B::f;
; int (B::*mp_g)(A, int, A) = &B::g;
; void (B::*mp_h)(A, int, A) = &B::h;
; A (B::*mp_i)(A, int, A) = &B::i;
; A (B::*mp_j)(int) = &B::j;
; Each member pointer creates a thunk. The ones with inalloca are required to
; tail calls by the ABI, even at O0.
%struct.B = type { ptr }
%struct.A = type { i32 }
; CHECK-LABEL: f_thunk:
; CHECK: jmpl
; CHECK-NOT: ret
define x86_thiscallcc i32 @f_thunk(ptr %this, i32) {
entry:
%vtable = load ptr, ptr %this
%1 = load ptr, ptr %vtable
%2 = musttail call x86_thiscallcc i32 %1(ptr %this, i32 %0)
ret i32 %2
}
; Inalloca thunks shouldn't require any stores to the stack.
; CHECK-LABEL: g_thunk:
; CHECK-NOT: mov %{{.*}}, {{.*(.*esp.*)}}
; CHECK: jmpl
; CHECK-NOT: ret
define x86_thiscallcc i32 @g_thunk(ptr %this, ptr inalloca(<{ %struct.A, i32, %struct.A }>)) {
entry:
%vtable = load ptr, ptr %this
%vfn = getelementptr inbounds ptr, ptr %vtable, i32 1
%1 = load ptr, ptr %vfn
%2 = musttail call x86_thiscallcc i32 %1(ptr %this, ptr inalloca(<{ %struct.A, i32, %struct.A }>) %0)
ret i32 %2
}
; Preallocated thunks shouldn't require any stores to the stack.
; CHECK-LABEL: g_thunk_preallocated:
; CHECK-NOT: mov %{{.*}}, {{.*(.*esp.*)}}
; CHECK: jmpl
; CHECK-NOT: ret
define x86_thiscallcc i32 @g_thunk_preallocated(ptr %this, ptr preallocated(<{ %struct.A, i32, %struct.A }>)) {
entry:
%vtable = load ptr, ptr %this
%vfn = getelementptr inbounds ptr, ptr %vtable, i32 1
%1 = load ptr, ptr %vfn
%2 = musttail call x86_thiscallcc i32 %1(ptr %this, ptr preallocated(<{ %struct.A, i32, %struct.A }>) %0)
ret i32 %2
}
; CHECK-LABEL: h_thunk:
; CHECK: jmpl
; CHECK-NOT: mov %{{.*}}, {{.*(.*esp.*)}}
; CHECK-NOT: ret
define x86_thiscallcc void @h_thunk(ptr %this, ptr inalloca(<{ %struct.A, i32, %struct.A }>)) {
entry:
%vtable = load ptr, ptr %this
%vfn = getelementptr inbounds ptr, ptr %vtable, i32 2
%1 = load ptr, ptr %vfn
musttail call x86_thiscallcc void %1(ptr %this, ptr inalloca(<{ %struct.A, i32, %struct.A }>) %0)
ret void
}
; CHECK-LABEL: h_thunk_preallocated:
; CHECK: jmpl
; CHECK-NOT: mov %{{.*}}, {{.*(.*esp.*)}}
; CHECK-NOT: ret
define x86_thiscallcc void @h_thunk_preallocated(ptr %this, ptr preallocated(<{ %struct.A, i32, %struct.A }>)) {
entry:
%vtable = load ptr, ptr %this
%vfn = getelementptr inbounds ptr, ptr %vtable, i32 2
%1 = load ptr, ptr %vfn
musttail call x86_thiscallcc void %1(ptr %this, ptr preallocated(<{ %struct.A, i32, %struct.A }>) %0)
ret void
}
; CHECK-LABEL: i_thunk:
; CHECK-NOT: mov %{{.*}}, {{.*(.*esp.*)}}
; CHECK: jmpl
; CHECK-NOT: ret
define x86_thiscallcc ptr @i_thunk(ptr %this, ptr inalloca(<{ ptr, %struct.A, i32, %struct.A }>)) {
entry:
%vtable = load ptr, ptr %this
%vfn = getelementptr inbounds ptr, ptr %vtable, i32 3
%1 = load ptr, ptr %vfn
%2 = musttail call x86_thiscallcc ptr %1(ptr %this, ptr inalloca(<{ ptr, %struct.A, i32, %struct.A }>) %0)
ret ptr %2
}
; CHECK-LABEL: i_thunk_preallocated:
; CHECK-NOT: mov %{{.*}}, {{.*(.*esp.*)}}
; CHECK: jmpl
; CHECK-NOT: ret
define x86_thiscallcc ptr @i_thunk_preallocated(ptr %this, ptr preallocated(<{ ptr, %struct.A, i32, %struct.A }>)) {
entry:
%vtable = load ptr, ptr %this
%vfn = getelementptr inbounds ptr, ptr %vtable, i32 3
%1 = load ptr, ptr %vfn
%2 = musttail call x86_thiscallcc ptr %1(ptr %this, ptr preallocated(<{ ptr, %struct.A, i32, %struct.A }>) %0)
ret ptr %2
}
; CHECK-LABEL: j_thunk:
; CHECK: jmpl
; CHECK-NOT: ret
define x86_thiscallcc void @j_thunk(ptr noalias sret(%struct.A) %agg.result, ptr %this, i32) {
entry:
%vtable = load ptr, ptr %this
%vfn = getelementptr inbounds ptr, ptr %vtable, i32 4
%1 = load ptr, ptr %vfn
musttail call x86_thiscallcc void %1(ptr sret(%struct.A) %agg.result, ptr %this, i32 %0)
ret void
}
; CHECK-LABEL: _stdcall_thunk@8:
; CHECK-NOT: mov %{{.*}}, {{.*(.*esp.*)}}
; CHECK: jmpl
; CHECK-NOT: ret
define x86_stdcallcc i32 @stdcall_thunk(ptr inalloca(<{ ptr, %struct.A }>)) {
entry:
%this_ptr = getelementptr inbounds <{ ptr, %struct.A }>, ptr %0, i32 0, i32 0
%this = load ptr, ptr %this_ptr
%vtable = load ptr, ptr %this
%vfn = getelementptr inbounds ptr, ptr %vtable, i32 1
%1 = load ptr, ptr %vfn
%2 = musttail call x86_stdcallcc i32 %1(ptr inalloca(<{ ptr, %struct.A }>) %0)
ret i32 %2
}
; CHECK-LABEL: _stdcall_thunk_preallocated@8:
; CHECK-NOT: mov %{{.*}}, {{.*(.*esp.*)}}
; CHECK: jmpl
; CHECK-NOT: ret
define x86_stdcallcc i32 @stdcall_thunk_preallocated(ptr preallocated(<{ ptr, %struct.A }>)) {
entry:
%this_ptr = getelementptr inbounds <{ ptr, %struct.A }>, ptr %0, i32 0, i32 0
%this = load ptr, ptr %this_ptr
%vtable = load ptr, ptr %this
%vfn = getelementptr inbounds ptr, ptr %vtable, i32 1
%1 = load ptr, ptr %vfn
%2 = musttail call x86_stdcallcc i32 %1(ptr preallocated(<{ ptr, %struct.A }>) %0)
ret i32 %2
}
; CHECK-LABEL: @fastcall_thunk@8:
; CHECK-NOT: mov %{{.*}}, {{.*(.*esp.*)}}
; CHECK: jmpl
; CHECK-NOT: ret
define x86_fastcallcc i32 @fastcall_thunk(ptr inreg %this, ptr inalloca(<{ %struct.A }>)) {
entry:
%vtable = load ptr, ptr %this
%vfn = getelementptr inbounds ptr, ptr %vtable, i32 1
%1 = load ptr, ptr %vfn
%2 = musttail call x86_fastcallcc i32 %1(ptr inreg %this, ptr inalloca(<{ %struct.A }>) %0)
ret i32 %2
}
; CHECK-LABEL: @fastcall_thunk_preallocated@8:
; CHECK-NOT: mov %{{.*}}, {{.*(.*esp.*)}}
; CHECK: jmpl
; CHECK-NOT: ret
define x86_fastcallcc i32 @fastcall_thunk_preallocated(ptr inreg %this, ptr preallocated(<{ %struct.A }>)) {
entry:
%vtable = load ptr, ptr %this
%vfn = getelementptr inbounds ptr, ptr %vtable, i32 1
%1 = load ptr, ptr %vfn
%2 = musttail call x86_fastcallcc i32 %1(ptr inreg %this, ptr preallocated(<{ %struct.A }>) %0)
ret i32 %2
}
|