From 8215de3621ddaaf742df4ca47c4578b3c74a8623 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 30 Jun 2020 15:36:19 -0400 Subject: [PATCH] PPC: Don't store function in PPCFunctionInfo Continue migrating targets from depending on the MachineFunction during the initial construction. --- lib/Target/PowerPC/PPCAsmPrinter.cpp | 14 +++++++------- lib/Target/PowerPC/PPCMachineFunctionInfo.cpp | 12 ++++++------ lib/Target/PowerPC/PPCMachineFunctionInfo.h | 13 +++++-------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index 7aa4165e90c..b6c3086169e 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -631,7 +631,7 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr *MI) { return; } else { MCSymbol *PICOffset = - MF->getInfo()->getPICOffsetSymbol(); + MF->getInfo()->getPICOffsetSymbol(*MF); TmpInst.setOpcode(PPC::LWZ); const MCExpr *Exp = MCSymbolRefExpr::create(PICOffset, MCSymbolRefExpr::VK_None, OutContext); @@ -1341,7 +1341,7 @@ void PPCLinuxAsmPrinter::emitFunctionEntryLabel() { if (!Subtarget->isPPC64()) { const PPCFunctionInfo *PPCFI = MF->getInfo(); if (PPCFI->usesPICBase() && !Subtarget->isSecurePlt()) { - MCSymbol *RelocSymbol = PPCFI->getPICOffsetSymbol(); + MCSymbol *RelocSymbol = PPCFI->getPICOffsetSymbol(*MF); MCSymbol *PICBase = MF->getPICBaseSymbol(); OutStreamer->emitLabel(RelocSymbol); @@ -1369,14 +1369,14 @@ void PPCLinuxAsmPrinter::emitFunctionEntryLabel() { const PPCFunctionInfo *PPCFI = MF->getInfo(); MCSymbol *TOCSymbol = OutContext.getOrCreateSymbol(StringRef(".TOC.")); - MCSymbol *GlobalEPSymbol = PPCFI->getGlobalEPSymbol(); + MCSymbol *GlobalEPSymbol = PPCFI->getGlobalEPSymbol(*MF); const MCExpr *TOCDeltaExpr = MCBinaryExpr::createSub(MCSymbolRefExpr::create(TOCSymbol, OutContext), MCSymbolRefExpr::create(GlobalEPSymbol, OutContext), OutContext); - OutStreamer->emitLabel(PPCFI->getTOCOffsetSymbol()); + OutStreamer->emitLabel(PPCFI->getTOCOffsetSymbol(*MF)); OutStreamer->emitValue(TOCDeltaExpr, 8); } return AsmPrinter::emitFunctionEntryLabel(); @@ -1483,7 +1483,7 @@ void PPCLinuxAsmPrinter::emitFunctionBodyStart() { // Note: The logic here must be synchronized with the code in the // branch-selection pass which sets the offset of the first block in the // function. This matters because it affects the alignment. - MCSymbol *GlobalEntryLabel = PPCFI->getGlobalEPSymbol(); + MCSymbol *GlobalEntryLabel = PPCFI->getGlobalEPSymbol(*MF); OutStreamer->emitLabel(GlobalEntryLabel); const MCSymbolRefExpr *GlobalEntryLabelExp = MCSymbolRefExpr::create(GlobalEntryLabel, OutContext); @@ -1506,7 +1506,7 @@ void PPCLinuxAsmPrinter::emitFunctionBodyStart() { .addReg(PPC::X2) .addExpr(TOCDeltaLo)); } else { - MCSymbol *TOCOffset = PPCFI->getTOCOffsetSymbol(); + MCSymbol *TOCOffset = PPCFI->getTOCOffsetSymbol(*MF); const MCExpr *TOCOffsetDeltaExpr = MCBinaryExpr::createSub(MCSymbolRefExpr::create(TOCOffset, OutContext), GlobalEntryLabelExp, OutContext); @@ -1521,7 +1521,7 @@ void PPCLinuxAsmPrinter::emitFunctionBodyStart() { .addReg(PPC::X12)); } - MCSymbol *LocalEntryLabel = PPCFI->getLocalEPSymbol(); + MCSymbol *LocalEntryLabel = PPCFI->getLocalEPSymbol(*MF); OutStreamer->emitLabel(LocalEntryLabel); const MCSymbolRefExpr *LocalEntryLabelExp = MCSymbolRefExpr::create(LocalEntryLabel, OutContext); diff --git a/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp b/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp index 1a9b50cb945..daf88589bb5 100644 --- a/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp +++ b/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp @@ -19,31 +19,31 @@ static cl::opt PPCDisableNonVolatileCR( cl::init(false), cl::Hidden); void PPCFunctionInfo::anchor() {} -PPCFunctionInfo::PPCFunctionInfo(MachineFunction &MF) - : DisableNonVolatileCR(PPCDisableNonVolatileCR), MF(MF) {} +PPCFunctionInfo::PPCFunctionInfo(const MachineFunction &MF) + : DisableNonVolatileCR(PPCDisableNonVolatileCR) {} -MCSymbol *PPCFunctionInfo::getPICOffsetSymbol() const { +MCSymbol *PPCFunctionInfo::getPICOffsetSymbol(MachineFunction &MF) const { const DataLayout &DL = MF.getDataLayout(); return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + Twine(MF.getFunctionNumber()) + "$poff"); } -MCSymbol *PPCFunctionInfo::getGlobalEPSymbol() const { +MCSymbol *PPCFunctionInfo::getGlobalEPSymbol(MachineFunction &MF) const { const DataLayout &DL = MF.getDataLayout(); return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + "func_gep" + Twine(MF.getFunctionNumber())); } -MCSymbol *PPCFunctionInfo::getLocalEPSymbol() const { +MCSymbol *PPCFunctionInfo::getLocalEPSymbol(MachineFunction &MF) const { const DataLayout &DL = MF.getDataLayout(); return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + "func_lep" + Twine(MF.getFunctionNumber())); } -MCSymbol *PPCFunctionInfo::getTOCOffsetSymbol() const { +MCSymbol *PPCFunctionInfo::getTOCOffsetSymbol(MachineFunction &MF) const { const DataLayout &DL = MF.getDataLayout(); return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + "func_toc" + diff --git a/lib/Target/PowerPC/PPCMachineFunctionInfo.h b/lib/Target/PowerPC/PPCMachineFunctionInfo.h index 3bbac5316ef..29ca53e273d 100644 --- a/lib/Target/PowerPC/PPCMachineFunctionInfo.h +++ b/lib/Target/PowerPC/PPCMachineFunctionInfo.h @@ -118,9 +118,6 @@ class PPCFunctionInfo : public MachineFunctionInfo { /// 64-bit SVR4 ABI. SmallVector MustSaveCRs; - /// Hold onto our MachineFunction context. - MachineFunction &MF; - /// Whether this uses the PIC Base register or not. bool UsesPICBase = false; @@ -129,7 +126,7 @@ class PPCFunctionInfo : public MachineFunctionInfo { std::vector> LiveInAttrs; public: - explicit PPCFunctionInfo(MachineFunction &MF); + explicit PPCFunctionInfo(const MachineFunction &MF); int getFramePointerSaveIndex() const { return FramePointerSaveIndex; } void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; } @@ -225,11 +222,11 @@ public: void setUsesPICBase(bool uses) { UsesPICBase = uses; } bool usesPICBase() const { return UsesPICBase; } - MCSymbol *getPICOffsetSymbol() const; + MCSymbol *getPICOffsetSymbol(MachineFunction &MF) const; - MCSymbol *getGlobalEPSymbol() const; - MCSymbol *getLocalEPSymbol() const; - MCSymbol *getTOCOffsetSymbol() const; + MCSymbol *getGlobalEPSymbol(MachineFunction &MF) const; + MCSymbol *getLocalEPSymbol(MachineFunction &MF) const; + MCSymbol *getTOCOffsetSymbol(MachineFunction &MF) const; }; } // end namespace llvm