[PATCH] [ms-cxxabi] Add CGCXXABI::NeedsBodylessEmission function.

Peter Collingbourne peter at pcc.me.uk
Sun May 19 15:25:06 PDT 2013


Hi timurrrr,

This function returns true if the ABI requires that we emit a
definition for a given function, given that we don't have a body
for it in the TU.

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

Files:
  lib/CodeGen/CGCXXABI.cpp
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CodeGenModule.cpp

Index: lib/CodeGen/CGCXXABI.cpp
===================================================================
--- lib/CodeGen/CGCXXABI.cpp
+++ lib/CodeGen/CGCXXABI.cpp
@@ -292,3 +292,7 @@
   ErrorUnsupportedABI(CGF, "odr-use of thread_local global");
   return LValue();
 }
+
+bool CGCXXABI::NeedsBodylessEmission(GlobalDecl GD) {
+  return false;
+}
Index: lib/CodeGen/CGCXXABI.h
===================================================================
--- lib/CodeGen/CGCXXABI.h
+++ lib/CodeGen/CGCXXABI.h
@@ -318,6 +318,10 @@
                                QualType ElementType, llvm::Value *&NumElements,
                                llvm::Value *&AllocPtr, CharUnits &CookieSize);
 
+  /// Returns true if the ABI requires that we emit a definition for this
+  /// function, given that we don't have a definition for it in the TU.
+  virtual bool NeedsBodylessEmission(GlobalDecl GD);
+
 protected:
   /// Returns the extra size required in order to store the array
   /// cookie for the given type.  Assumes that an array cookie is
Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -1380,7 +1380,8 @@
           assert(FD->isUsed() && "Sema didn't mark implicit function as used!");
           DeferredDeclsToEmit.push_back(D.getWithDecl(FD));
           break;
-        } else if (FD->doesThisDeclarationHaveABody()) {
+        } else if (FD->doesThisDeclarationHaveABody() ||
+                   getCXXABI().NeedsBodylessEmission(D)) {
           DeferredDeclsToEmit.push_back(D.getWithDecl(FD));
           break;
         }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D820.1.patch
Type: text/x-patch
Size: 1649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130519/faca102f/attachment.bin>


More information about the cfe-commits mailing list