NCG: slight waste of time and space for inter-module data references (Darwin/PIC)
In GHC.CmmToAsm.PIC there is the following code:
howToAccessLabel config arch OSDarwin DataReference lbl
-- data access to a dynamic library goes via a symbol pointer
| labelDynamic config lbl
= AccessViaSymbolPtr
-- when generating PIC code, all cross-module data references must
-- must go via a symbol pointer, too, because the assembler
-- cannot generate code for a label difference where one
-- label is undefined. Doesn't apply t x86_64.
-- Unfortunately, we don't know whether it's cross-module,
-- so we do it for all externally visible labels.
-- This is a slight waste of time and space, but otherwise
-- we'd need to pass the current Module all the way in to
-- this function.
| arch /= ArchX86_64
, ncgPIC config && externallyVisibleCLabel lbl
= AccessViaSymbolPtr
According to the comment, we could do better codegen if we had the current module. But we do! (in ncgThisModule config
)