[PATCH] D111627: [DebugInfo][InstrRef] Recover some performance by calculating IDF for register units instead of all their alises

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 12 03:23:40 PDT 2021


jmorse created this revision.
jmorse added reviewers: StephenTozer, Orlando, TWeaver.
Herald added a subscriber: hiraditya.
jmorse requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In D110173 <https://reviews.llvm.org/D110173> we start using the existing LLVM IDF calculator to place PHIs as we reconstruct an SSA form of machine-code program. Sadly that's slower than the old (but broken) way, this patch attempts to recover some of that performance.

The key observation: every time we def a register, we also have to def it's register units. A refresher on units is here [0]. If we def'd $rax, in the current implementation we independently calculate PHI locations for {al, ah, ax, eax, hax, rax}, and they will all have the same PHI positions. Instead of doing that, we can calculate the PHI positions for {al, ah} and place PHIs for any aliasing registers in the same positions. Any def of a super-register has to def the unit, and vice versa, so this is sound. It cuts down the SSA placement we need to do significantly.

There are a few escape hatches: stack slots don't have subregisters (yet), so they have to be handled independently. There are also scenarios where we only ever read from registers (such as arguments), and so never track their sub-registers or register units. In both of these cases, this patch just falls back to placing PHIs "normally". There's also a small amount of juggling to do with the stack pointer: we ignore defs of the stack pointer at calls, so register masks and SP defs get ignored. Now that we're placing PHIs for register units on top of the super-registers they alias, we need to be careful to not def the stack pointer register units either. Thus, there's now a collection of "aliases of the stack pointer" in MLocTracker that shouldn't be def'd by calls either.

Testing: because this is performance related, no tests, but this builds clang-3.4 with identical object files after being applied (save for the object file with the date/time in it).

[0] https://lists.llvm.org/pipermail/llvm-dev/2012-May/050177.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111627

Files:
  llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
  llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111627.378944.patch
Type: text/x-patch
Size: 9212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211012/c3ab7327/attachment.bin>


More information about the llvm-commits mailing list