[PATCH] D29916: [CGP] Split some critical edges coming out of indirect branches

Michael Kuperstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 13 15:25:44 PST 2017


mkuper created this revision.
Herald added a subscriber: mehdi_amini.

Split critical edges coming out of indirect branches, when it is easy to do: we match a "jump table" pattern where the jump table has local linkage, is used by exactly one indirectbr, and has no other uses.

Having a critical edge survive until MI means that when we go out of SSA, we have to define all the live-ins of a destination block within the origin block. Normally, MachineSink tries to split critical edges and sink these definitions into the destination block, but teaching it to split indirect edges on the MI level in a generic way looks problematic. So, instead, this tries to split these edges in IR.

This is motivated by the use of computed gotos in python 2.7 - PyEval_EvalFrame() ends up using an indirect branch with ~100 successors, and passing a constant to each of those. This causes us to emit about ~100 defs of registers containing constants, which we then fail to sink because the edge is critical (destination block has incoming edges from both the indirectbr and from a switch). So, at each goto, we "spill" about a hundred constants.
That end result is that a clang-compiled python interpreter is about ~2.5 (!) slower on a simple python reduction loop than a gcc-compiled interpreter.


https://reviews.llvm.org/D29916

Files:
  lib/CodeGen/CodeGenPrepare.cpp
  lib/Transforms/Utils/BreakCriticalEdges.cpp
  test/CodeGen/MSP430/indirectbr2.ll
  test/Transforms/CodeGenPrepare/computedgoto.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29916.88265.patch
Type: text/x-patch
Size: 20909 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170213/a55ca6e6/attachment.bin>


More information about the llvm-commits mailing list