We probably can avoid keeping copies of "global" SPIR-V instructions in each MachineFunction, at least for some of them. For this purpose we need to implement a special cache for such "global" instructions in SPIRVGlobalRegister. For this implementation we need to find out how to
- print the instructions from the cache to represent them in MachineFunction dumps,
- what data structures should represent cached instructions (candidates so far are MCInst or new custom class),
- how safely link cached instructions with other MachineInstrs in different MachineFunctions.
I think we can do this for OpDecorate and OpName instructions, then also support Types/Consts/GVars/Funcs and others if applicable to them.