This is x86 specific, and adds statefulness to
MachineModuleInfo. Instead of explicitly tracking this, infer if we
need to declare the symbol based on the reference previously inserted.
This produces a small change in the output due to the move from
AsmPrinter::doFinalization to X86's emitEndOfAsmFile. This will now be
moved relative to other end of file fields, which I'm assuming doesn't
matter (e.g. the __morestack_addr declaration is now after the
.note.GNU-split-stack part)
This also produces another small change in code if the module happened
to define/declare __morestack_addr, but I assume that's invalid and
doesn't really matter.
I suggest getSubtarget().is64Bit() instead of TT.getArch() == ...x86_64, it's marginally more explicit. My first (silly) thought was "why are we checking if we're targetting x86, we are already in the x86 backend... oh right, we don't do this for 32-bit".