[PATCH] D22315: Teach fast isel about thiscall (and callee-pop) calls.
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 13 14:05:23 PDT 2016
thakis created this revision.
thakis added a reviewer: rnk.
thakis added a subscriber: llvm-commits.
Herald added a subscriber: aemerson.
Testing for this is a bit ugly: -fast-isel-abort=1 doesn't abort on calls, and -fast-isel-abort=2 aborts both on calls and on parameters (which fail to be lowered), so it can't be used. Instead, look at the output of -fast-isel-verbose.
Depends on http://reviews.llvm.org/D22314, else test/CodeGen/X86/win32_sret.ll fails due to (harmless) changes in the generated code.
http://reviews.llvm.org/D22315
Files:
lib/Target/X86/X86FastISel.cpp
test/CodeGen/X86/fast-isel-call.ll
Index: test/CodeGen/X86/fast-isel-call.ll
===================================================================
--- test/CodeGen/X86/fast-isel-call.ll
+++ test/CodeGen/X86/fast-isel-call.ll
@@ -1,4 +1,5 @@
-; RUN: llc < %s -O0 -fast-isel-abort=1 -march=x86 | FileCheck %s
+; RUN: llc < %s -O0 -fast-isel-abort=1 -march=x86 2>/dev/null | FileCheck %s
+; RUN: llc < %s -O0 -fast-isel-abort=1 -march=x86 2>&1 >/dev/null | FileCheck -check-prefix=STDERR -allow-empty %s
%struct.s = type {i32, i32, i32}
@@ -53,3 +54,14 @@
; CHECK: movl $100, 8(%esp)
; CHECK: calll {{.*}}memcpy
}
+
+; STDERR-NOT: FastISel missed call: call x86_thiscallcc void @thiscallfun
+; CHECK: test5:
+%struct.S = type { i8 }
+define void @test5() #0 {
+entry:
+ %s = alloca %struct.S, align 1
+ call x86_thiscallcc void @thiscallfun(%struct.S* %s, i32 43)
+ ret void
+}
+declare x86_thiscallcc void @thiscallfun(%struct.S*, i32) #1
Index: lib/Target/X86/X86FastISel.cpp
===================================================================
--- lib/Target/X86/X86FastISel.cpp
+++ lib/Target/X86/X86FastISel.cpp
@@ -3025,6 +3025,7 @@
case CallingConv::WebKit_JS:
case CallingConv::Swift:
case CallingConv::X86_FastCall:
+ case CallingConv::X86_ThisCall:
case CallingConv::X86_64_Win64:
case CallingConv::X86_64_SysV:
break;
@@ -3052,11 +3053,6 @@
if (Flag.isSwiftError())
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<unsigned, 16> ArgRegs;
@@ -3336,7 +3332,10 @@
// Issue CALLSEQ_END
unsigned NumBytesForCalleeToPop =
- computeBytesPoppedByCallee(Subtarget, CC, CLI.CS);
+ X86::isCalleePop(CC, Subtarget->is64Bit(), IsVarArg,
+ TM.Options.GuaranteedTailCallOpt)
+ ? NumBytes // Callee pops everything.
+ : computeBytesPoppedByCallee(Subtarget, CC, CLI.CS);
unsigned AdjStackUp = TII.getCallFrameDestroyOpcode();
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AdjStackUp))
.addImm(NumBytes).addImm(NumBytesForCalleeToPop);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22315.63857.patch
Type: text/x-patch
Size: 2225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160713/c708a003/attachment.bin>
More information about the llvm-commits
mailing list