OSDN Git Service

Subzero: Improve performance of liveness analysis and live range construction.
authorJim Stichnoth <stichnot@chromium.org>
Tue, 14 Oct 2014 00:15:08 +0000 (17:15 -0700)
committerJim Stichnoth <stichnot@chromium.org>
Tue, 14 Oct 2014 00:15:08 +0000 (17:15 -0700)
commit4775255d4244c3425da0a7afd5f2c1ccb3a7dca9
tree1eb74541cfceae38bc322f3d74fd3f230ec81987
parente22f823680ec21304509c1ebcee119cb843f5e76
Subzero: Improve performance of liveness analysis and live range construction.

The key performance problem was that the per-block LiveBegin and LiveEnd vectors were dense with respect to the multi-block "global" variables, even though very few of the global variables are ever live within the block.  This led to large vectors needlessly initialized and iterated over.

The new approach is to accumulate two small vectors of <variable,instruction_number> tuples (LiveBegin and LiveEnd) as each block is processed, then sort the vectors and iterate over them in parallel to construct the live ranges.

Some of the anomalies in the original liveness analysis code have been straightened out:

1. Variables have an IgnoreLiveness attribute to suppress analysis.  This is currently used only on the esp register.

2. Instructions have a DestNonKillable attribute which causes the Dest variable not to be marked as starting a new live range at that instruction.  This is used when a variable is non-SSA and has more than one assignment within a block, but we want to treat it as a single live range.  This lets the variable have zero or one live range begins or ends within a block.  DestNonKillable is derived automatically for two-address instructions, and annotated manually in a few other cases.

This is tested by comparing the O2 asm output in each Spec2K component.  In theory, the output should be the same except for some differences in pseudo-instructions output as comments.  However, some actual differences showed up, related to the i64 shl instruction followed by trunc to i32.  This turned out to be a liveness bug that was accidentally fixed.

BUG= none
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/652633002
16 files changed:
src/IceCfg.cpp
src/IceCfg.h
src/IceCfgNode.cpp
src/IceCfgNode.h
src/IceDefs.h
src/IceInst.cpp
src/IceInst.h
src/IceLiveness.cpp
src/IceLiveness.h
src/IceOperand.cpp
src/IceOperand.h
src/IceTargetLoweringX8632.cpp
src/IceTargetLoweringX8632.h
src/IceTimerTree.cpp
src/IceTimerTree.def
tests_lit/llvm2ice_tests/64bit.pnacl.ll