Cache the results from getMachineBasicBlocks in LexicalScopes to speed
up UserValueScopes::dominates queries. This replaces the caching done
in UserValueScopes. Compared to the old caching method, this reduces
memory traffic when a VarLoc is copied (e.g. when a VarLocMap grows),
and enables caching across basic blocks.
When compiling sqlite 3.5.7 (CTMark version), this patch reduces the
number of calls to getMachineBasicBlocks from 10,207 to 1,093. I also
measured a small compile-time reduction (~ 0.1% of total wall time, on
average, on my machine).
As a drive-by, I made the DebugLoc in UserValueScopes a const reference
to cut down on MetadataTracking traffic.
I'm not familiar with the extent of the usage of LexicalScopes throughout llvm, so I wonder if there's ever a case where we don't want the caching behaviour. i.e. is it conceivable that the result of dominates should change for the same inputs between calls?
Given this unfamiliarity I probably shouldn't be the one to give the final LGTM on this.