mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
Teach fast isel about thiscall (and callee-pop) calls.
http://reviews.llvm.org/D22315 llvm-svn: 275360
This commit is contained in:
parent
eabbdab4f5
commit
d4fcb8d00e
@ -2983,7 +2983,7 @@ bool X86FastISel::fastLowerArguments() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned computeBytesPoppedByCallee(const X86Subtarget *Subtarget,
|
static unsigned computeBytesPoppedByCalleeForSRet(const X86Subtarget *Subtarget,
|
||||||
CallingConv::ID CC,
|
CallingConv::ID CC,
|
||||||
ImmutableCallSite *CS) {
|
ImmutableCallSite *CS) {
|
||||||
if (Subtarget->is64Bit())
|
if (Subtarget->is64Bit())
|
||||||
@ -3025,6 +3025,7 @@ bool X86FastISel::fastLowerCall(CallLoweringInfo &CLI) {
|
|||||||
case CallingConv::WebKit_JS:
|
case CallingConv::WebKit_JS:
|
||||||
case CallingConv::Swift:
|
case CallingConv::Swift:
|
||||||
case CallingConv::X86_FastCall:
|
case CallingConv::X86_FastCall:
|
||||||
|
case CallingConv::X86_ThisCall:
|
||||||
case CallingConv::X86_64_Win64:
|
case CallingConv::X86_64_Win64:
|
||||||
case CallingConv::X86_64_SysV:
|
case CallingConv::X86_64_SysV:
|
||||||
break;
|
break;
|
||||||
@ -3052,11 +3053,6 @@ bool X86FastISel::fastLowerCall(CallLoweringInfo &CLI) {
|
|||||||
if (Flag.isSwiftError())
|
if (Flag.isSwiftError())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Fast-isel doesn't know about callee-pop yet.
|
|
||||||
if (X86::isCalleePop(CC, Subtarget->is64Bit(), IsVarArg,
|
|
||||||
TM.Options.GuaranteedTailCallOpt))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
SmallVector<MVT, 16> OutVTs;
|
SmallVector<MVT, 16> OutVTs;
|
||||||
SmallVector<unsigned, 16> ArgRegs;
|
SmallVector<unsigned, 16> ArgRegs;
|
||||||
|
|
||||||
@ -3336,7 +3332,10 @@ bool X86FastISel::fastLowerCall(CallLoweringInfo &CLI) {
|
|||||||
|
|
||||||
// Issue CALLSEQ_END
|
// Issue CALLSEQ_END
|
||||||
unsigned NumBytesForCalleeToPop =
|
unsigned NumBytesForCalleeToPop =
|
||||||
computeBytesPoppedByCallee(Subtarget, CC, CLI.CS);
|
X86::isCalleePop(CC, Subtarget->is64Bit(), IsVarArg,
|
||||||
|
TM.Options.GuaranteedTailCallOpt)
|
||||||
|
? NumBytes // Callee pops everything.
|
||||||
|
: computeBytesPoppedByCalleeForSRet(Subtarget, CC, CLI.CS);
|
||||||
unsigned AdjStackUp = TII.getCallFrameDestroyOpcode();
|
unsigned AdjStackUp = TII.getCallFrameDestroyOpcode();
|
||||||
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AdjStackUp))
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AdjStackUp))
|
||||||
.addImm(NumBytes).addImm(NumBytesForCalleeToPop);
|
.addImm(NumBytes).addImm(NumBytesForCalleeToPop);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
; RUN: llc < %s -O0 -fast-isel-abort=1 -march=x86 -mtriple=i686-apple-darwin8 | FileCheck %s
|
; RUN: llc < %s -O0 -fast-isel-abort=1 -march=x86 -mtriple=i686-apple-darwin8 2>/dev/null | FileCheck %s
|
||||||
|
; RUN: llc < %s -O0 -fast-isel-abort=1 -march=x86 -mtriple=i686-apple-darwin8 2>&1 >/dev/null | FileCheck -check-prefix=STDERR -allow-empty %s
|
||||||
|
|
||||||
%struct.s = type {i32, i32, i32}
|
%struct.s = type {i32, i32, i32}
|
||||||
|
|
||||||
@ -53,3 +54,19 @@ define void @test4(i8* %a, i8* %b) {
|
|||||||
; CHECK: movl $100, 8(%esp)
|
; CHECK: movl $100, 8(%esp)
|
||||||
; CHECK: calll {{.*}}memcpy
|
; CHECK: calll {{.*}}memcpy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; STDERR-NOT: FastISel missed call: call x86_thiscallcc void @thiscallfun
|
||||||
|
%struct.S = type { i8 }
|
||||||
|
define void @test5() #0 {
|
||||||
|
entry:
|
||||||
|
%s = alloca %struct.S, align 1
|
||||||
|
; CHECK-LABEL: test5:
|
||||||
|
; CHECK: subl $12, %esp
|
||||||
|
; CHECK: leal 8(%esp), %ecx
|
||||||
|
; CHECK: movl $43, (%esp)
|
||||||
|
; CHECK: calll {{.*}}thiscallfun
|
||||||
|
; CHECK: addl $8, %esp
|
||||||
|
call x86_thiscallcc void @thiscallfun(%struct.S* %s, i32 43)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
declare x86_thiscallcc void @thiscallfun(%struct.S*, i32) #1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user