[llvm] r263856 - [CXX_FAST_TLS] Disable tail call when calling conventions are mismatched.
Manman Ren via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 18 16:41:51 PDT 2016
Author: mren
Date: Fri Mar 18 18:41:51 2016
New Revision: 263856
URL: http://llvm.org/viewvc/llvm-project?rev=263856&view=rev
Log:
[CXX_FAST_TLS] Disable tail call when calling conventions are mismatched.
Since CXX_FAST_TLS has a bigger set of CSRs, we don't tail call when caller
and callee have mismatched calling conventions.
Modified:
llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/AArch64/cxx-tlscc.ll
llvm/trunk/test/CodeGen/ARM/cxx-tlscc.ll
llvm/trunk/test/CodeGen/X86/cxx_tlscc64.ll
Modified: llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp?rev=263856&r1=263855&r2=263856&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp Fri Mar 18 18:41:51 2016
@@ -2817,6 +2817,13 @@ bool AArch64TargetLowering::isEligibleFo
CallingConv::ID CallerCC = CallerF->getCallingConv();
bool CCMatch = CallerCC == CalleeCC;
+ // Disable tailcall for CXX_FAST_TLS when callee and caller have different
+ // calling conventions, given that CXX_FAST_TLS has a bigger CSR set.
+ if (!CCMatch &&
+ (CallerCC == CallingConv::CXX_FAST_TLS ||
+ CalleeCC == CallingConv::CXX_FAST_TLS))
+ return false;
+
// Byval parameters hand the function a pointer directly into the stack area
// we want to reuse during a tail call. Working around this *is* possible (see
// X86) but less efficient and uglier in LowerCall.
Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=263856&r1=263855&r2=263856&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Mar 18 18:41:51 2016
@@ -2100,6 +2100,13 @@ ARMTargetLowering::IsEligibleForTailCall
CallingConv::ID CallerCC = CallerF->getCallingConv();
bool CCMatch = CallerCC == CalleeCC;
+ // Disable tailcall for CXX_FAST_TLS when callee and caller have different
+ // calling conventions, given that CXX_FAST_TLS has a bigger CSR set.
+ if (!CCMatch &&
+ (CallerCC == CallingConv::CXX_FAST_TLS ||
+ CalleeCC == CallingConv::CXX_FAST_TLS))
+ return false;
+
assert(Subtarget->supportsTailCall());
// Look for obvious safe cases to perform tail call optimization that do not
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=263856&r1=263855&r2=263856&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Mar 18 18:41:51 2016
@@ -3767,6 +3767,13 @@ bool X86TargetLowering::IsEligibleForTai
if (IsCalleeWin64 != IsCallerWin64)
return false;
+ // Disable tailcall for CXX_FAST_TLS when callee and caller have different
+ // calling conventions, given that CXX_FAST_TLS has a bigger CSR set.
+ if (!CCMatch &&
+ (CallerCC == CallingConv::CXX_FAST_TLS ||
+ CalleeCC == CallingConv::CXX_FAST_TLS))
+ return false;
+
if (DAG.getTarget().Options.GuaranteedTailCallOpt) {
if (canGuaranteeTCO(CalleeCC) && CCMatch)
return true;
Modified: llvm/trunk/test/CodeGen/AArch64/cxx-tlscc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/cxx-tlscc.ll?rev=263856&r1=263855&r2=263856&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/cxx-tlscc.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/cxx-tlscc.ll Fri Mar 18 18:41:51 2016
@@ -205,5 +205,18 @@ define cxx_fast_tlscc %class.C* @tls_tes
call cxx_fast_tlscc void @tls_helper()
ret %class.C* @tC
}
+
+; Make sure we do not allow tail call when caller and callee have different
+; calling conventions.
+declare %class.C* @_ZN1CD1Ev(%class.C* readnone returned %this)
+; CHECK-LABEL: tls_test
+; CHECK: bl __tlv_atexit
+define cxx_fast_tlscc void @__tls_test() {
+entry:
+ store i32 0, i32* getelementptr inbounds (%class.C, %class.C* @tC, i64 0, i32 0), align 4
+ %0 = tail call i32 @_tlv_atexit(void (i8*)* bitcast (%class.C* (%class.C*)* @_ZN1CD1Ev to void (i8*)*), i8* bitcast (%class.C* @tC to i8*), i8* nonnull @__dso_handle) #1
+ ret void
+}
+
attributes #0 = { nounwind "no-frame-pointer-elim"="true" }
attributes #1 = { nounwind }
Modified: llvm/trunk/test/CodeGen/ARM/cxx-tlscc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/cxx-tlscc.ll?rev=263856&r1=263855&r2=263856&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/cxx-tlscc.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/cxx-tlscc.ll Fri Mar 18 18:41:51 2016
@@ -101,5 +101,18 @@ define cxx_fast_tlscc %class.C* @tls_tes
call cxx_fast_tlscc void @tls_helper()
ret %class.C* @tC
}
+
+; Make sure we do not allow tail call when caller and callee have different
+; calling conventions.
+declare %class.C* @_ZN1CD1Ev(%class.C* readnone returned %this)
+; CHECK-LABEL: tls_test
+; CHECK: bl __tlv_atexit
+define cxx_fast_tlscc void @__tls_test() {
+entry:
+ store i32 0, i32* getelementptr inbounds (%class.C, %class.C* @tC, i64 0, i32 0), align 4
+ %0 = tail call i32 @_tlv_atexit(void (i8*)* bitcast (%class.C* (%class.C*)* @_ZN1CD1Ev to void (i8*)*), i8* bitcast (%class.C* @tC to i8*), i8* nonnull @__dso_handle) #1
+ ret void
+}
+
attributes #0 = { nounwind "no-frame-pointer-elim"="true" }
attributes #1 = { nounwind }
Modified: llvm/trunk/test/CodeGen/X86/cxx_tlscc64.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/cxx_tlscc64.ll?rev=263856&r1=263855&r2=263856&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/cxx_tlscc64.ll (original)
+++ llvm/trunk/test/CodeGen/X86/cxx_tlscc64.ll Fri Mar 18 18:41:51 2016
@@ -138,5 +138,18 @@ define cxx_fast_tlscc %class.C* @tls_tes
call cxx_fast_tlscc void @tls_helper()
ret %class.C* @tC
}
+
+; Make sure we do not allow tail call when caller and callee have different
+; calling conventions.
+declare %class.C* @_ZN1CD1Ev(%class.C* readnone returned %this)
+; CHECK-LABEL: tls_test
+; CHECK: callq {{.*}}tlv_atexit
+define cxx_fast_tlscc void @tls_test() {
+entry:
+ store i32 0, i32* getelementptr inbounds (%class.C, %class.C* @tC, i64 0, i32 0), align 4
+ %0 = tail call i32 @_tlv_atexit(void (i8*)* bitcast (%class.C* (%class.C*)* @_ZN1CD1Ev to void (i8*)*), i8* bitcast (%class.C* @tC to i8*), i8* nonnull @__dso_handle) #1
+ ret void
+}
+
attributes #0 = { nounwind "no-frame-pointer-elim"="true" }
attributes #1 = { nounwind }
More information about the llvm-commits
mailing list