[1] Added a new pass, namely, amdgpu-lower-function-local-lds.
[2] Implemented required initial plumbing work for both old and new pass managers.
[3] A flag, namely, amdgpu-enable-function-local-lds-lowering is added, which is a hidden flag and enabled by default.
The pass can be explicitly disabled by passing the option -mllvm --amdgpu-enable-function-local-lds-lowering=false.
Further, build all the required data structures which will be later used to lower function local LDS. Below are the data structures being built.
[1] Kernel Set - Holds all the kernels in the module
[2] Function Local LDS Set - Holds all the function local LDS from all functions
[3] Function Address Taken Set - Holds all the functions whose address is taken within the module
[4] LDS to Function Map - Maps each function local LDS to a function within which the LDS is defined
[5] Function to LDS Map - Reverse of above map, which maps each functon F to a SET of LDS which are defined within F
[6] Kernel to Callee Map - Maps each kernel K to a SET of functions which define LDS and there exists call graph path from K to these functions.
[7] Kernel to LDS Map - Maps each kernel K to a set of function local LDS which are supposed to be lowered w.r.t K.
Data structures [1], [2], and [3] are built by iterating over the globals and functions defined within the module.
Data structures [4] and [5] are built using BOTTOM-UP based on the use list of function local LDS.
Data structure [6] is built using TOP-DOWN via call graph traversal.
Data structure [7] is built using the result of above BOTTOM-UP and TOP-DOWN constructed data structures.