On AIX -bcdtors:csect linker option requires ".ref" pseudo-op to indicate the connection among static variables (static global variable, static class member etc.) and static init/term functions, so that linker can generate the correct output.
Here in IR we borrow ‘associated’ metadata to indicate the relationship for ".ref". There are three types of association need be addressed:
(1) variable to init/term functions (required to add functions to _cdtors array if the variable is included in linker output)
(2) dtor function to term function (required to correctly handle atexit/unatexit registration/unregistration)
(3) program code csect to internal variable classified as Data or ThreadData
This is the first half change to support -bcdtors:csect linker option, it adds ".ref" in case (3), and emit ".ref" in assembly output. The other two items will be handled in clang.
Can we only use one parameter const MCSymbol *Symbol for this function? And update other callers accordingly. These two parameters are kind of duplicate.