[llvm-commits] [PATCH 0/5] Reduce memory usage for phi operands
Jay Foad
jay.foad at gmail.com
Thu Jun 16 04:09:21 PDT 2011
Currently, a PHINode has 2 * n operands laid out like this:
VAL0, BB0, VAL1, BB1, ..., VALn-1, BBn-1
Chris suggested to me that the BBn operands don't need to be full-blown Uses; they can just be pointers to the BasicBlock. This should be a win because:
- Uses are bulky and slow to access
- This keeps phi nodes off BasicBlocks' use lists, which should make it faster to enumerate a BasicBlock's predecessors.
The following patches implement this suggestion. PHINodes now have n operands, immediately followed in memory by n pointers to basic blocks, like this:
VAL0, VAL1, ..., VALn-1; bb0, bb1, ..., bbn-1
I used "valgrind --tool=massif --peak-inaccuracy=0" to measure peak heap memory usage before and after my changes, for the following commands (using source from MultiSource/Applications/sqlite3/):
$ clang -cc1 -emit-llvm-bc -o /dev/null sqlite3.c -O3
before 87475624
after 87164488 (down by 0.36%)
$ llvm-ld sqlite3.o shell.o
before 40417072
after 40101936 (down by 0.78%)
Here is the elapsed run time in seconds for 5 runs of the following command:
$ clang -cc1 -emit-llvm-bc -o /dev/null sqlite3.c -O3
before 5.816 5.842 5.836 5.828 5.840
after 5.729 5.735 5.735 5.738 5.723 (down by 1.7% on average)
Tested with:
- make all check-all, LLVM and Clang
- nightly test suite with llvm-gcc-4.2
- nightly test suite with dragonegg
- nightly test suite with Clang
OK to commit?
Jay Foad (5):
Remove the AugmentedUse struct.
Make better use of the PHINode API.
Change how PHINodes store their operands.
Extend replaceAllUsesWith() on a BasicBlock.
Test case.
include/llvm/BasicBlock.h | 6 +-
include/llvm/Instructions.h | 81 ++++++++++++-------
include/llvm/Support/CFG.h | 2 +-
include/llvm/Use.h | 19 ++---
lib/Bitcode/Writer/BitcodeWriter.cpp | 12 ++-
lib/Target/CppBackend/CPPBackend.cpp | 5 +-
lib/Transforms/Scalar/GVN.cpp | 13 ++-
lib/Transforms/Scalar/LoopRotation.cpp | 2 +-
lib/Transforms/Scalar/LoopUnswitch.cpp | 8 +-
lib/Transforms/Utils/BasicBlockUtils.cpp | 6 +-
lib/Transforms/Utils/BreakCriticalEdges.cpp | 54 ++++---------
lib/Transforms/Utils/CloneFunction.cpp | 6 +-
lib/Transforms/Utils/InlineFunction.cpp | 10 +-
lib/Transforms/Utils/Local.cpp | 17 +++--
lib/Transforms/Utils/LoopUnroll.cpp | 71 +++++++++--------
lib/Transforms/Utils/ValueMapper.cpp | 14 +++
lib/VMCore/AsmWriter.cpp | 8 +-
lib/VMCore/BasicBlock.cpp | 20 ++++-
lib/VMCore/Instructions.cpp | 54 +++++++------
lib/VMCore/Use.cpp | 8 +-
lib/VMCore/User.cpp | 12 +--
lib/VMCore/Value.cpp | 3 +
lib/VMCore/Verifier.cpp | 14 ++--
test/Transforms/GVN/2011-04-27-phioperands.ll | 106 +++++++++++++++++++++++++
24 files changed, 357 insertions(+), 194 deletions(-)
create mode 100644 test/Transforms/GVN/2011-04-27-phioperands.ll
--
1.7.4.1
More information about the llvm-commits
mailing list