This is an archive of the discontinued LLVM Phabricator instance.

MachineModuleInfo: Remove UsesMorestackAddr
ClosedPublic

Authored by arsenm on Apr 18 2022, 7:08 AM.

Details

Summary

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.

Diff Detail

Event Timeline

arsenm created this revision.Apr 18 2022, 7:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2022, 7:08 AM
arsenm requested review of this revision.Apr 18 2022, 7:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2022, 7:08 AM
Herald added a subscriber: wdng. · View Herald Transcript
rnk accepted this revision.Apr 18 2022, 11:57 AM

lgtm

llvm/lib/Target/X86/X86AsmPrinter.cpp
832

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".

This revision is now accepted and ready to land.Apr 18 2022, 11:57 AM
arsenm added inline comments.Apr 18 2022, 11:58 AM
llvm/lib/Target/X86/X86AsmPrinter.cpp
832

This is in module level code. There's not supposed to be a subtarget

rnk added inline comments.Apr 18 2022, 12:45 PM
llvm/lib/Target/X86/X86AsmPrinter.cpp
832

Got it, sounds fine then. I only got as far as confirming that X86AsmPrinter::getSubtarget exists. I never liked the TT.is64BitArch() predicates, those always seemed silly.

arsenm added inline comments.Apr 20 2022, 8:00 AM
llvm/lib/Target/X86/X86AsmPrinter.cpp
832

The short version is it does exist, but it shouldn't.

I've never understood why x86 has these predicates on the subtarget