Index: include/llvm/CodeGen/AsmPrinter.h =================================================================== --- include/llvm/CodeGen/AsmPrinter.h +++ include/llvm/CodeGen/AsmPrinter.h @@ -20,6 +20,7 @@ #include "llvm/ADT/Twine.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/DwarfStringPoolEntry.h" +#include "llvm/CodeGen/StackMaps.h" #include "llvm/IR/InlineAsm.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/ErrorHandling.h" @@ -107,6 +108,9 @@ typedef std::pair GOTEquivUsePair; MapVector GlobalGOTEquivs; + /// This holds stackmap, patchpoint, or statepoint data that are lowered. + StackMaps SM; + private: MCSymbol *CurrentFnBegin; MCSymbol *CurrentFnEnd; Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp =================================================================== --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -102,7 +102,7 @@ AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr Streamer) : MachineFunctionPass(ID), TM(tm), MAI(tm.getMCAsmInfo()), OutContext(Streamer->getContext()), OutStreamer(std::move(Streamer)), - LastMI(nullptr), LastFn(0), Counter(~0U) { + LastMI(nullptr), LastFn(0), Counter(~0U), SM(*this) { DD = nullptr; MMI = nullptr; LI = nullptr; Index: lib/Target/AArch64/AArch64AsmPrinter.cpp =================================================================== --- lib/Target/AArch64/AArch64AsmPrinter.cpp +++ lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -48,12 +48,11 @@ class AArch64AsmPrinter : public AsmPrinter { AArch64MCInstLower MCInstLowering; - StackMaps SM; public: AArch64AsmPrinter(TargetMachine &TM, std::unique_ptr Streamer) : AsmPrinter(TM, std::move(Streamer)), MCInstLowering(OutContext, *this), - SM(*this), AArch64FI(nullptr) {} + AArch64FI(nullptr) {} const char *getPassName() const override { return "AArch64 Assembly Printer"; @@ -65,10 +64,8 @@ return MCInstLowering.lowerOperand(MO, MCOp); } - void LowerSTACKMAP(MCStreamer &OutStreamer, StackMaps &SM, - const MachineInstr &MI); - void LowerPATCHPOINT(MCStreamer &OutStreamer, StackMaps &SM, - const MachineInstr &MI); + void LowerSTACKMAP(MCStreamer &OutStreamer, const MachineInstr &MI); + void LowerPATCHPOINT(MCStreamer &OutStreamer, const MachineInstr &MI); /// \brief tblgen'erated driver function for lowering simple MI->MC /// pseudo instructions. bool emitPseudoExpansionLowering(MCStreamer &OutStreamer, @@ -362,7 +359,7 @@ printOperand(MI, NOps - 2, OS); } -void AArch64AsmPrinter::LowerSTACKMAP(MCStreamer &OutStreamer, StackMaps &SM, +void AArch64AsmPrinter::LowerSTACKMAP(MCStreamer &OutStreamer, const MachineInstr &MI) { unsigned NumNOPBytes = MI.getOperand(1).getImm(); @@ -390,7 +387,7 @@ // Lower a patchpoint of the form: // [], , , , -void AArch64AsmPrinter::LowerPATCHPOINT(MCStreamer &OutStreamer, StackMaps &SM, +void AArch64AsmPrinter::LowerPATCHPOINT(MCStreamer &OutStreamer, const MachineInstr &MI) { SM.recordPatchPoint(MI); @@ -536,10 +533,10 @@ } case TargetOpcode::STACKMAP: - return LowerSTACKMAP(*OutStreamer, SM, *MI); + return LowerSTACKMAP(*OutStreamer, *MI); case TargetOpcode::PATCHPOINT: - return LowerPATCHPOINT(*OutStreamer, SM, *MI); + return LowerPATCHPOINT(*OutStreamer, *MI); } // Finally, do the automated lowerings for everything else. Index: lib/Target/PowerPC/PPCAsmPrinter.cpp =================================================================== --- lib/Target/PowerPC/PPCAsmPrinter.cpp +++ lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -69,11 +69,10 @@ protected: MapVector TOC; const PPCSubtarget *Subtarget; - StackMaps SM; public: explicit PPCAsmPrinter(TargetMachine &TM, std::unique_ptr Streamer) - : AsmPrinter(TM, std::move(Streamer)), SM(*this) {} + : AsmPrinter(TM, std::move(Streamer)) {} const char *getPassName() const override { return "PowerPC Assembly Printer"; @@ -94,10 +93,8 @@ void EmitEndOfAsmFile(Module &M) override; - void LowerSTACKMAP(MCStreamer &OutStreamer, StackMaps &SM, - const MachineInstr &MI); - void LowerPATCHPOINT(MCStreamer &OutStreamer, StackMaps &SM, - const MachineInstr &MI); + void LowerSTACKMAP(MCStreamer &OutStreamer, const MachineInstr &MI); + void LowerPATCHPOINT(MCStreamer &OutStreamer, const MachineInstr &MI); void EmitTlsCall(const MachineInstr *MI, MCSymbolRefExpr::VariantKind VK); bool runOnMachineFunction(MachineFunction &MF) override { Subtarget = &MF.getSubtarget(); @@ -330,7 +327,7 @@ SM.serializeToStackMapSection(); } -void PPCAsmPrinter::LowerSTACKMAP(MCStreamer &OutStreamer, StackMaps &SM, +void PPCAsmPrinter::LowerSTACKMAP(MCStreamer &OutStreamer, const MachineInstr &MI) { unsigned NumNOPBytes = MI.getOperand(1).getImm(); @@ -358,7 +355,7 @@ // Lower a patchpoint of the form: // [], , , , -void PPCAsmPrinter::LowerPATCHPOINT(MCStreamer &OutStreamer, StackMaps &SM, +void PPCAsmPrinter::LowerPATCHPOINT(MCStreamer &OutStreamer, const MachineInstr &MI) { SM.recordPatchPoint(MI); PatchPointOpers Opers(&MI); @@ -506,9 +503,9 @@ case TargetOpcode::DBG_VALUE: llvm_unreachable("Should be handled target independently"); case TargetOpcode::STACKMAP: - return LowerSTACKMAP(*OutStreamer, SM, *MI); + return LowerSTACKMAP(*OutStreamer, *MI); case TargetOpcode::PATCHPOINT: - return LowerPATCHPOINT(*OutStreamer, SM, *MI); + return LowerPATCHPOINT(*OutStreamer, *MI); case PPC::MoveGOTtoLR: { // Transform %LR = MoveGOTtoLR Index: lib/Target/X86/X86AsmPrinter.h =================================================================== --- lib/Target/X86/X86AsmPrinter.h +++ lib/Target/X86/X86AsmPrinter.h @@ -27,7 +27,6 @@ class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public AsmPrinter { const X86Subtarget *Subtarget; - StackMaps SM; FaultMaps FM; // This utility class tracks the length of a stackmap instruction's 'shadow'. @@ -90,8 +89,7 @@ public: explicit X86AsmPrinter(TargetMachine &TM, std::unique_ptr Streamer) - : AsmPrinter(TM, std::move(Streamer)), SM(*this), FM(*this), - SMShadowTracker(TM) {} + : AsmPrinter(TM, std::move(Streamer)), FM(*this), SMShadowTracker(TM) {} const char *getPassName() const override { return "X86 Assembly / Object Emitter";