[英]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.