[PATCH] D22900: Revert r244207 - Mark calls in thunk functions as tail-call optimization

Gerolf Hoflehner via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 28 20:52:49 PDT 2016


Gerolf updated this revision to Diff 66075.
Gerolf added a comment.

Reduced test case.


https://reviews.llvm.org/D22900

Files:
  lib/CodeGen/CGVTables.cpp
  test/CodeGenCXX/microsoft-abi-structors.cpp
  test/CodeGenCXX/tail-byval.cpp

Index: test/CodeGenCXX/tail-byval.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/tail-byval.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 %s -I%S -isystem %S/Inputs -emit-llvm -triple i386-apple-darwin9 -Wno-incompatible-ms-struct -o - -Os | opt - -dse -S -o - | FileCheck %s
+#pragma ms_struct on
+
+#include <stdint.h>
+
+extern "C" int rand();
+
+typedef union _LARGE {
+  struct {
+    uint32_t Low;
+    int32_t High;
+  } u;
+  int64_t Quad;
+} LARGE;
+
+class CRepro {
+protected:
+  CRepro();
+  virtual ~CRepro() {}
+};
+
+class I {
+public:
+  virtual uint32_t Seek(LARGE L) = 0;
+};
+
+class CBase : public CRepro {
+protected:
+  CBase();
+  virtual ~CBase() {};
+};
+
+class C : public CBase, public I {
+public:
+  __attribute__((noinline))
+      uint32_t Seek(LARGE L);
+
+private:
+  C();
+  ~C() {};
+};
+
+uint32_t C::Seek(LARGE L) {
+  return L.u.Low + L.u.High;
+}
+// CHECK: define i32 @_ZThn4_N1C4SeekE6_LARGE
+// CHECK: store i64
+// CHECK-NOT: tail call
+// CHECK: ret
Index: test/CodeGenCXX/microsoft-abi-structors.cpp
===================================================================
--- test/CodeGenCXX/microsoft-abi-structors.cpp
+++ test/CodeGenCXX/microsoft-abi-structors.cpp
@@ -177,9 +177,8 @@
 //      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:.*]] = tail call x86_thiscallcc i8* @"\01??_GC at dtor_in_second_nvbase@@UAEPAXI at Z"
+// DTORS2:   %[[CALL:.*]] = call x86_thiscallcc i8* @"\01??_GC at dtor_in_second_nvbase@@UAEPAXI at Z"
 // DTORS2:   ret i8* %[[CALL]]
-
 }
 
 namespace test2 {
Index: lib/CodeGen/CGVTables.cpp
===================================================================
--- lib/CodeGen/CGVTables.cpp
+++ lib/CodeGen/CGVTables.cpp
@@ -322,8 +322,6 @@
   // 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())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22900.66075.patch
Type: text/x-patch
Size: 2253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160729/ed721359/attachment.bin>


More information about the cfe-commits mailing list