[PATCH] [-cxx-abi microsoft] Emit thunks for pointers to virtual member functions

Timur Iskhodzhanov timurrrr at google.com
Mon Nov 11 08:14:09 PST 2013


  A short version of review given that you're likely to change the structure after discussing the move to MsCXXABI with Reid.


================
Comment at: lib/CodeGen/CGVTables.cpp:361
@@ +360,3 @@
+
+  CurGD = MD;
+
----------------
Looks like you wanted to add two assertions, but only added one?

================
Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1384
@@ +1383,3 @@
+                                    .VBase) {
+    CGM.ErrorUnsupported(MD, "pointer to virtual member function overriding "
+                             "member function in virtual base class");
----------------
Are you sure overriding is required in order to get a "complex" vmemfun ptr?

================
Comment at: lib/CodeGen/CGVTables.cpp:359
@@ +358,3 @@
+  CGM.SetLLVMFunctionAttributes(MD, FnInfo, ThunkFn);
+  CGM.SetLLVMFunctionAttributesForDefinition(MD, ThunkFn);
+
----------------
Can the preparation / finalization stuff be shared with GenerateThunk and friends?

================
Comment at: lib/CodeGen/CodeGenFunction.h:1161
@@ +1160,3 @@
+  /// \brief Generate a thunk for calling virtual member function MD, which
+  /// is at position VTableIndex in the vtable.
+  llvm::Function *GenerateVirtualMemPtrThunk(const CXXMethodDecl *MD,
----------------
Needs updating

================
Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1373
@@ -1372,5 +1372,3 @@
   llvm::Constant *FirstField;
-  if (MD->isVirtual()) {
-    // FIXME: We have to instantiate a thunk that loads the vftable and jumps to
-    // the right offset.
-    CGM.ErrorUnsupported(MD, "pointer to virtual member function");
+  if (MD->isVirtual() && MD->isVariadic()) {
+    CGM.ErrorUnsupported(MD, "pointer to variadic virtual member function");
----------------
How about

  if (!isVirtual) {
  } else if (virtual-subcase-1) {
  } else if (virtual-subcase-2) {
  } ...

?

================
Comment at: test/CodeGenCXX/microsoft-abi-virtual-member-pointers.cpp:26
@@ +25,3 @@
+// CHECK32-LABEL: define void @"\01?f@@YAXXZ"()
+// CHECK32: store i8* bitcast (void (%struct.C*)* @"\01??_9C@@$BA at AE" to i8*), i8** %ptr
+// CHECK32: store i8* bitcast (i32 (%struct.C*, i32, double)* @"\01??_9C@@$B3AE" to i8*), i8** %ptr2
----------------
Please try to run this both with Release and Debug builds.
I'm pretty sure you'll need to replace all %xyz with %{{.*}} or %[[VARNAME:.*]]


http://llvm-reviews.chandlerc.com/D2104



More information about the cfe-commits mailing list