[llvm-commits] Avoid O(#registers*#basicblocks) memory use in LiveVariables

Jeffrey Yasskin jyasskin at google.com
Fri May 22 15:41:07 PDT 2009


LiveVariables::VarInfo contains two BitVectors, AliveBlocks and
UsedBlocks, which have as many entries as there are basic blocks in
the function. I believe LiveVariables::getVarInfo creates a VarInfo
struct for every register in the function, leading to quadratic space
use. On a particular function with approximately 30k basic blocks and
280k instructions, which I've uploaded to
http://jeffrey.yasskin.info/dump/big_module.bc.bz2, this took
approximately 1.6GB of memory to codegen. The attached patch changes
these two variables to SparseBitVectors, which makes the memory use go
down to ~420MB (on Mac; llc on linux goes from 1.6GB->~900MB).

It's possible that this patch merely trades quadratic space on rare
large functions for larger space and quadratic time on more common
small functions, but I don't know enough about how LiveVariables works
to know.

This passes LLVM's `make check`, except for the Frontend tests that
never pass for me.

Jeffrey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smaller_livevars.patch
Type: application/octet-stream
Size: 6974 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090522/90693987/attachment.obj>


More information about the llvm-commits mailing list