[PATCH] D51664: [IR] Lazily number instructions for local dominance queries

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 4 16:45:53 PDT 2018


rnk created this revision.
rnk added reviewers: efriedma, dberlin, gbiv.
Herald added subscribers: george.burgess.iv, JDevlieghere, hiraditya, aprantl, mgorny.
Herald added a reviewer: george.burgess.iv.

Essentially, fold OrderedBasicBlock into BasicBlock, and make it
auto-invalidate the instruction ordering when new instructions are
added. Notably, we don't need to invalidate it when removing
instructions, which is helpful when a pass mostly delete dead
instructions rather than transforming them.

This dramatically speeds up clang compiling clang with debug info.
Compiling SemaChecking.cpp on my computer previously took 121s, and now
it takes 74s, for a 63% speedup.

The downside is that Instruction grows from 56 bytes to 64 bytes, and I
don't have a good way to measure what that costs in practice. As the one
who removed the vtable from Value, I will say that this is how I would
like to spend the 8 bytes that I saved a year ago in r303362.

The resulting LLVM code is substantially simpler and automatically
handles invalidation, which makes me think that this is the right speed
and size tradeoff. There's more low-hanging fruit in MemorySSA and DSE,
which maintain their own instruction orderings today.

The code isn't completely polished, I just wanted to post some numbers
and show people what this looks like. The important change is in
SymbolTableTraitsImpl.h, where the numbering is invalidated. Everything
else should be straightforward.

We could implement a fancier re-numbering scheme, but I think we should
wait and profile and see if we really need that complexity. If we do,
the APIs will stay the same anyway, so this is a good first step.

Fixes PR38829.


https://reviews.llvm.org/D51664

Files:
  llvm/include/llvm/Analysis/AliasAnalysis.h
  llvm/include/llvm/Analysis/CaptureTracking.h
  llvm/include/llvm/Analysis/OrderedBasicBlock.h
  llvm/include/llvm/Analysis/OrderedInstructions.h
  llvm/include/llvm/IR/BasicBlock.h
  llvm/include/llvm/IR/Instruction.h
  llvm/include/llvm/IR/SymbolTableListTraits.h
  llvm/lib/Analysis/AliasAnalysis.cpp
  llvm/lib/Analysis/CMakeLists.txt
  llvm/lib/Analysis/CaptureTracking.cpp
  llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
  llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
  llvm/lib/Analysis/OrderedBasicBlock.cpp
  llvm/lib/Analysis/OrderedInstructions.cpp
  llvm/lib/IR/BasicBlock.cpp
  llvm/lib/IR/Instruction.cpp
  llvm/lib/IR/SymbolTableListTraitsImpl.h
  llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
  llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
  llvm/unittests/Analysis/CMakeLists.txt
  llvm/unittests/Analysis/OrderedBasicBlockTest.cpp
  llvm/unittests/IR/BasicBlockTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51664.163948.patch
Type: text/x-patch
Size: 35238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180904/285f81f7/attachment.bin>


More information about the llvm-commits mailing list