glsl: Rebuild the symbol table without unreachable symbols
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 14 Jul 2014 22:48:34 +0000 (15:48 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 4 Aug 2014 22:48:09 +0000 (15:48 -0700)
commit7b1898314709e3e70571c491f7f62745c05e13e1
tree6c0256572d9bb20d98a69aea1b11eb9b9c83e724
parent3d051772c8ef0f14f5ab3ccd954b5b3bb65e6ba7
glsl: Rebuild the symbol table without unreachable symbols

Previously we had to keep unreachable global symbols in the symbol table
because the symbol table is used during linking.  Having the symbol
table retain pointers to freed memory... what could possibly go wrong?
At the same time, this meant that we kept live references to tons of
memory that was no longer needed.

New strategy:  destroy the old symbol table, and make a new one from the
reachable symbols.

Valgrind massif results for a trimmed apitrace of dota2:

                  n        time(i)         total(B)   useful-heap(B) extra-heap(B)    stacks(B)
Before (32-bit): 59 40,642,425,451       76,337,968       69,720,886     6,617,082            0
After  (32-bit): 46 40,661,487,174       75,116,800       68,854,065     6,262,735            0

Before (64-bit): 79 37,179,441,771      106,986,512       98,112,095     8,874,417            0
After  (64-bit): 64 37,200,329,700      104,872,672       96,514,546     8,358,126            0

A real savings of 846KiB on 32-bit and 1.5MiB on 64-bit.

v2: (by Kenneth Graunke) Just add the ir_function from the IR stream,
    rather than looking it up in the symbol table; they're now
    identical.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/glsl_parser_extras.cpp