[PATCH] Always emit function declaration when generating profile instrumentation

Alex L arphaman at gmail.com
Tue May 27 16:39:34 PDT 2014


This is needed to ensure that the profile counters are emitted
for all functions and methods.


-------------- next part --------------
Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp	(revision 209698)
+++ lib/CodeGen/CodeGenModule.cpp	(working copy)
@@ -1073,6 +1073,8 @@
   if (LangOpts.EmitAllDecls)
     return false;

+  if(CodeGenOpts.ProfileInstrGenerate && isa<FunctionDecl>(Global))
+    return false;
   return !getContext().DeclMustBeEmitted(Global);
 }

@@ -3028,6 +3030,16 @@
     break;

   // C++ Decls
+  case Decl::CXXRecord: {
+    if(!CodeGenOpts.ProfileInstrGenerate)
+      break;
+    CXXRecordDecl *Record = cast<CXXRecordDecl>(D);
+    for(CXXRecordDecl::method_iterator I = Record->method_begin(); I
!= Record->method_end(); ++I) {
+      if(I->hasBody())
+        EmitTopLevelDecl(*I);
+    }
+    break;
+  }
   case Decl::Namespace:
     EmitNamespace(cast<NamespaceDecl>(D));
     break;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140527/a3bd0a03/attachment.html>


More information about the cfe-commits mailing list