当我执行PGO优化步骤(使用LINK.EXE /LTCG:PGU
)时,Visual Studio 2010链接器会抱怨:
Merging foo!1.pgc
'FOO_EDGE::get_input': Arc 2 --> 4 has negative count (-414343)
Expectation failed: f line 4241
'FOO_DELAY::set_delay': Block 18 outgoing counts differ from block count (-9 diff)
Expectation failed: f line 4261
Expectation failed: f line 4211
'FOO_DELAY::set_delay': Arc 12 --> 23 has negative count (-3)
Expectation failed: f line 4220
Generating code
907 of 4948 ( 18.33%) profiled functions will be compiled for speed
4948 of 4948 functions (100.0%) were optimized using profile data
42912225037 of 42912225037 instructions (100.0%) were optimized using profile data
导致这些“预期失败”的原因是什么?我该如何解决这些问题?似乎PGO仍然在优化代码,但是我对这些消息存在时优化的质量/完整性有点怀疑。
答案 0 :(得分:0)
执行PGO检测的多线程应用程序运行时,似乎会出现这些错误。可以通过编译(而非链接)与x64上的/PogoSafeMode
标志来避免它们。
我没有发现MSDN documentation on this flag特别清楚;在多线程代码上执行PGO的正确过程是:
cl.exe /PogoSafeMode
link.exe /LTCG:PGI
link.exe /LTCG:PGO