[PATCH] Always emit function declaration when generating profile instrumentation

Reid Kleckner rnk at google.com
Wed May 28 12:23:03 PDT 2014


Can you explain why this works at all?  Why aren't the counters emitted as
linkonce_odr globals?


On Tue, May 27, 2014 at 4:39 PM, Alex L <arphaman at gmail.com> wrote:

> 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;
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140528/9e950d1e/attachment.html>


More information about the cfe-commits mailing list