简体   繁体   English

我可以制作模板 function noinline 还是强制它出现在分析器中?

[英]Can I make a template function noinline or else force it to appear in the profiler?

I'm trying to profile with perf on Ubuntu 20.04, but the problem is that many functions do not appear in it (likely because they are inlined), or only their addresses appear (without names etc.).我正在尝试在 Ubuntu 20.04 上使用perf进行分析,但问题是其中没有出现许多函数(可能是因为它们是内联的),或者只出现了它们的地址(没有名称等)。 I'm using CMake's RelWithDebInfo build.我正在使用 CMake 的RelWithDebInfo构建。 But there are some template functions that I don't know how to bring to the profiler results.但是有一些模板函数我不知道如何将它们带到分析器结果中。 I think marking them noinline may help if this is legal in C++ for template functions, but this screws up the codebase and needs to be done per-function.我认为如果这在 C++ 中对于模板函数是合法的,那么将它们标记为noinline可能会有所帮助,但这会破坏代码库并且需要按函数完成。 Any suggestions how to make all functions noinline at once?有什么建议可以立即使所有函数noinline吗?

You could add -fno-inline to CMAKE_CXX_FLAGS .您可以将-fno-inline添加到CMAKE_CXX_FLAGS

From GCC man page :GCC 手册页

 -fno-inline Do not expand any functions inline apart from those marked with the "always_inline" attribute. This is the default when not optimizing. Single functions can be exempted from inlining by marking them with the "noinline" attribute.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使模板函数成为另一个模板函数的参数? - How can I make a template function an argument to another template function? 如何制作指向模板函数的指针? - How can i make pointer to a template function? 模板类中的lambda函数的__declspec(noinline)会在VS2017中引发语法错误 - __declspec(noinline) on lambda function inside template class throws syntax error in VS2017 我可以对类模板的函数模板成员进行单独定义吗? - Can I make separate definitions of function template members of a class template? 如何使用 member-Function 制作模板代码 - How can I make template codes using member-Function 我可以强制初始化枚举类类/函数模板的所有可能的枚举值吗? - Can I force initialization for all possible enum values of an enum class class/function template? 虚拟成员函数定义可以出现在类模板之外吗? - Can a virtual member function definition appear outside the class template? 如何为模板 function 创建 typedef 或别名,也可以在朋友 function 声明中使用? - How can I make a typedef or alias for a template function that can also be used in friend function declarations? 我不能在 else if 语句中调用 function - I can't call a function in else if statement 如何让朋友 function 模板的 class 模板在命名空间 scope 中可见? - How can I make friend function template of a class template visible in the namespace scope?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM