3
如何从GCC / c装配件输出中消除“噪音”?
我想检查boost::variant在我的代码中应用的程序集输出,以查看优化了哪些中间调用。 当我编译以下示例(使用的GCC 5.3 g++ -O3 -std=c++14 -S)时,似乎编译器优化了所有内容并直接返回100: (...) main: .LFB9320: .cfi_startproc movl $100, %eax ret .cfi_endproc (...) #include <boost/variant.hpp> struct Foo { int get() { return 100; } }; struct Bar { int get() { return 999; } }; using Variant = boost::variant<Foo, Bar>; int run(Variant v) { return boost::apply_visitor([](auto& …