]> granicus.if.org Git - clang/commitdiff
Mark calls in thunk functions as tail-call optimization candidates
authorMichael Kuperstein <michael.m.kuperstein@intel.com>
Thu, 6 Aug 2015 11:57:15 +0000 (11:57 +0000)
committerMichael Kuperstein <michael.m.kuperstein@intel.com>
Thu, 6 Aug 2015 11:57:15 +0000 (11:57 +0000)
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@intel.com
Differential Revision: http://reviews.llvm.org/D11476

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244207 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGVTables.cpp
test/CodeGenCXX/microsoft-abi-structors.cpp

index 42cfd36e845e9aa580246238eccc883a4f06cc87..83f45b5da2c3fd85836728a39280f5fc1bbf2983 100644 (file)
@@ -312,6 +312,8 @@ void CodeGenFunction::EmitCallAndReturnForThunk(llvm::Value *Callee,
   // 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())
index 594dea473ef145b77f9d800dd6599a78e1ad8dc1..88400e7c0bdc90ade722c5b7004c3abd5796b8f5 100644 (file)
@@ -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@dtor_in_second_nvbase@@UAEPAXI@Z"
+// DTORS2:   %[[CALL:.*]] = tail call x86_thiscallcc i8* @"\01??_GC@dtor_in_second_nvbase@@UAEPAXI@Z"
 // DTORS2:   ret i8* %[[CALL]]
 
 }