我的问题类似于这一个,但是不同,因为我不问EditAndContinue。
我已经意识到一个热门的重新编译存在。我是说,例如,我们有这样的代码
if (a > 0 && b >0 && c > 0 && d > 0)
我们假设我们有一个监视可执行文件并启动JIT的环境(例如CLR)。因此,这个环境看到条件d > 0
很少见(我们在编译时不知道a b c
或d
的实际值,只能在运行时收集一些统计信息)。所以它可以像这样重新编译它
if (d > 0 && a > 0 && b >0 && c > 0)
所以我们得到了一个优化,因为最不可能的条件,首先检查。那么,这个热重编译实际上是如何命名的呢?它是如何在哪里起作用的?
发布于 2013-12-17 04:54:33
可以叫做分支重排。
GCC似乎也支持类似的分支分析选项,这可能会帮助你找到真名。
-fbranch-probabilities
After running a program compiled with -fprofile-arcs
(see Options for Debugging Your Program or gcc), you can compile it a second
time using -fbranch-probabilities, to improve optimizations based on the number
of times each branch was taken. When a program compiled with -fprofile-arcs
exits, it saves arc execution counts to a file called sourcename.gcda for each
source file. The information in this data file is very dependent on the
structure of the generated code, so you must use the same source code and the
same optimization options for both compilations.
With -fbranch-probabilities, GCC puts a ‘REG_BR_PROB’ note on each ‘JUMP_INSN’
and ‘CALL_INSN’. These can be used to improve optimization. Currently, they are
only used in one place: in reorg.c, instead of guessing which path a branch is
most likely to take, the ‘REG_BR_PROB’ values are used to exactly determine
which path is taken more often.
https://stackoverflow.com/questions/18559702
复制相似问题