r244207 - Mark calls in thunk functions as tail-call optimization candidates
Michael Kuperstein via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 6 04:57:15 PDT 2015
Author: mkuper
Date: Thu Aug 6 06:57:15 2015
New Revision: 244207
URL: http://llvm.org/viewvc/llvm-project?rev=244207&view=rev
Log:
Mark calls in thunk functions as tail-call optimization candidates
When a thunk is generated with a call to the original adjusted function,
the thunk appears in the debugger call stack. We want the backend to perform
tail-call optimization on the call, to make it invisible to the debugger.
This fixes PR24235
Patch by: amjad.aboud at intel.com
Differential Revision: http://reviews.llvm.org/D11476
Modified:
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp
Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=244207&r1=244206&r2=244207&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Thu Aug 6 06:57:15 2015
@@ -312,6 +312,8 @@ void CodeGenFunction::EmitCallAndReturnF
// Consider return adjustment if we have ThunkInfo.
if (Thunk && !Thunk->Return.isEmpty())
RV = PerformReturnAdjustment(*this, ResultType, RV, *Thunk);
+ else if (llvm::CallInst* Call = dyn_cast<llvm::CallInst>(CallOrInvoke))
+ Call->setTailCallKind(llvm::CallInst::TCK_Tail);
// Emit return.
if (!ResultType->isVoidType() && Slot.isNull())
Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp?rev=244207&r1=244206&r2=244207&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp Thu Aug 6 06:57:15 2015
@@ -176,7 +176,7 @@ void foo() {
// Do an adjustment from B* to C*.
// DTORS2: getelementptr i8, i8* %{{.*}}, i32 -4
// DTORS2: bitcast i8* %{{.*}} to %"struct.dtor_in_second_nvbase::C"*
-// DTORS2: %[[CALL:.*]] = call x86_thiscallcc i8* @"\01??_GC at dtor_in_second_nvbase@@UAEPAXI at Z"
+// DTORS2: %[[CALL:.*]] = tail call x86_thiscallcc i8* @"\01??_GC at dtor_in_second_nvbase@@UAEPAXI at Z"
// DTORS2: ret i8* %[[CALL]]
}
More information about the cfe-commits
mailing list