The pass - "Lower Module LDS" supports use of LDS globals within non-kernel
functions by lowering LDS globals as follows. It packs within non-kernel used
LDS globals into a struct type, and creates an instance of that struct type
within every kernel at "address zero".
However, the pass - "Lower Module LDS" sometime wastes LDS memory depending
on the pattern of LDS globals use within the module.
Hence the current pass makes an attempt to aid the pass - "Lower Module LDS"
for efficient LDS memory usage. The idea behind current pass is as follows:
- Instead of directly packing LDS globals into the struct as struct members, create global LDS pointers correspoding those LDS globals.
- Initialize those global LDS pointers with their respective LDS globals.
- Replace all the non-kernel function scope use of those original LDS globals by their respective pointer counter-parts.
- Then the pass "Lower Module LDS" by the virtue of its implementation idea, lands-up packing only LDS pointers as struct members, which substentially reduces unnecessary LDS memory usage.