[llvm-commits] [PATCH] don't allocate useless PHI operands

Jay Foad jay.foad at gmail.com
Wed Mar 30 04:18:26 PDT 2011


PHINode::resizeOperands(0) "grows the number of ops by 1.5 times".
This sometimes allocates an odd number of operands, which is wasteful
because PHI nodes only ever use an even number of operands. The
attached patch fixes this so that we only ever allocate an even number
of operands.

The savings are pretty tiny. My test case was to compile sqlite3.c
from the LLVM testsuite with "clang -cc1 -emit-llvm-bc -O3" on
Linux/x86_64. valgrind --tool=massif shows that the peak memory usage
is 81.9 MB, of which 1.17 MB is allocated in User::allocHungoffUses().
This patch reduces those figures by 6.49 KB, about 0.008% of the total
memory usage or 0.5% of that allocated in User::allocHungoffUses().

Also tested with "make check", LLVM and Clang. OK to apply?

Thanks,
Jay.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: phi-operands.diff
Type: text/x-patch
Size: 582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110330/9bd6e4e6/attachment.bin>


More information about the llvm-commits mailing list