diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/llvm12/lib/CodeGen/MachineBasicBlock.cpp | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r-- | contrib/libs/llvm12/lib/CodeGen/MachineBasicBlock.cpp | 338 |
1 files changed, 169 insertions, 169 deletions
diff --git a/contrib/libs/llvm12/lib/CodeGen/MachineBasicBlock.cpp b/contrib/libs/llvm12/lib/CodeGen/MachineBasicBlock.cpp index b4187af029..5b96150b8e 100644 --- a/contrib/libs/llvm12/lib/CodeGen/MachineBasicBlock.cpp +++ b/contrib/libs/llvm12/lib/CodeGen/MachineBasicBlock.cpp @@ -61,24 +61,24 @@ MCSymbol *MachineBasicBlock::getSymbol() const { const MachineFunction *MF = getParent(); MCContext &Ctx = MF->getContext(); - // We emit a non-temporary symbol -- with a descriptive name -- if it begins - // a section (with basic block sections). Otherwise we fall back to use temp - // label. - if (MF->hasBBSections() && isBeginSection()) { + // We emit a non-temporary symbol -- with a descriptive name -- if it begins + // a section (with basic block sections). Otherwise we fall back to use temp + // label. + if (MF->hasBBSections() && isBeginSection()) { SmallString<5> Suffix; if (SectionID == MBBSectionID::ColdSectionID) { Suffix += ".cold"; } else if (SectionID == MBBSectionID::ExceptionSectionID) { Suffix += ".eh"; } else { - // For symbols that represent basic block sections, we add ".__part." to - // allow tools like symbolizers to know that this represents a part of - // the original function. - Suffix = (Suffix + Twine(".__part.") + Twine(SectionID.Number)).str(); + // For symbols that represent basic block sections, we add ".__part." to + // allow tools like symbolizers to know that this represents a part of + // the original function. + Suffix = (Suffix + Twine(".__part.") + Twine(SectionID.Number)).str(); } CachedMCSymbol = Ctx.getOrCreateSymbol(MF->getName() + Suffix); } else { - const StringRef Prefix = Ctx.getAsmInfo()->getPrivateLabelPrefix(); + const StringRef Prefix = Ctx.getAsmInfo()->getPrivateLabelPrefix(); CachedMCSymbol = Ctx.getOrCreateSymbol(Twine(Prefix) + "BB" + Twine(MF->getFunctionNumber()) + "_" + Twine(getNumber())); @@ -87,17 +87,17 @@ MCSymbol *MachineBasicBlock::getSymbol() const { return CachedMCSymbol; } -MCSymbol *MachineBasicBlock::getEndSymbol() const { - if (!CachedEndMCSymbol) { - const MachineFunction *MF = getParent(); - MCContext &Ctx = MF->getContext(); - auto Prefix = Ctx.getAsmInfo()->getPrivateLabelPrefix(); - CachedEndMCSymbol = Ctx.getOrCreateSymbol(Twine(Prefix) + "BB_END" + - Twine(MF->getFunctionNumber()) + - "_" + Twine(getNumber())); - } - return CachedEndMCSymbol; -} +MCSymbol *MachineBasicBlock::getEndSymbol() const { + if (!CachedEndMCSymbol) { + const MachineFunction *MF = getParent(); + MCContext &Ctx = MF->getContext(); + auto Prefix = Ctx.getAsmInfo()->getPrivateLabelPrefix(); + CachedEndMCSymbol = Ctx.getOrCreateSymbol(Twine(Prefix) + "BB_END" + + Twine(MF->getFunctionNumber()) + + "_" + Twine(getNumber())); + } + return CachedEndMCSymbol; +} raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineBasicBlock &MBB) { MBB.print(OS); @@ -269,10 +269,10 @@ bool MachineBasicBlock::hasEHPadSuccessor() const { return false; } -bool MachineBasicBlock::isEntryBlock() const { - return getParent()->begin() == getIterator(); -} - +bool MachineBasicBlock::isEntryBlock() const { + return getParent()->begin() == getIterator(); +} + #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void MachineBasicBlock::dump() const { print(dbgs()); @@ -340,7 +340,7 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST, if (Indexes && PrintSlotIndexes) OS << Indexes->getMBBStartIdx(this) << '\t'; - printName(OS, PrintNameIr | PrintNameAttributes, &MST); + printName(OS, PrintNameIr | PrintNameAttributes, &MST); OS << ":\n"; const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo(); @@ -353,9 +353,9 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST, if (Indexes) OS << '\t'; // Don't indent(2), align with previous line attributes. OS << "; predecessors: "; - ListSeparator LS; - for (auto *Pred : predecessors()) - OS << LS << printMBBReference(*Pred); + ListSeparator LS; + for (auto *Pred : predecessors()) + OS << LS << printMBBReference(*Pred); OS << '\n'; HasLineAttributes = true; } @@ -364,9 +364,9 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST, if (Indexes) OS << '\t'; // Print the successors OS.indent(2) << "successors: "; - ListSeparator LS; + ListSeparator LS; for (auto I = succ_begin(), E = succ_end(); I != E; ++I) { - OS << LS << printMBBReference(**I); + OS << LS << printMBBReference(**I); if (!Probs.empty()) OS << '(' << format("0x%08" PRIx32, getSuccProbability(I).getNumerator()) @@ -375,10 +375,10 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST, if (!Probs.empty() && IsStandalone) { // Print human readable probabilities as comments. OS << "; "; - ListSeparator LS; + ListSeparator LS; for (auto I = succ_begin(), E = succ_end(); I != E; ++I) { const BranchProbability &BP = getSuccProbability(I); - OS << LS << printMBBReference(**I) << '(' + OS << LS << printMBBReference(**I) << '(' << format("%.2f%%", rint(((double)BP.getNumerator() / BP.getDenominator()) * 100.0 * 100.0) / @@ -395,9 +395,9 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST, if (Indexes) OS << '\t'; OS.indent(2) << "liveins: "; - ListSeparator LS; + ListSeparator LS; for (const auto &LI : liveins()) { - OS << LS << printReg(LI.PhysReg, TRI); + OS << LS << printReg(LI.PhysReg, TRI); if (!LI.LaneMask.all()) OS << ":0x" << PrintLaneMask(LI.LaneMask); } @@ -441,99 +441,99 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST, } } -/// Print the basic block's name as: -/// -/// bb.{number}[.{ir-name}] [(attributes...)] -/// -/// The {ir-name} is only printed when the \ref PrintNameIr flag is passed -/// (which is the default). If the IR block has no name, it is identified -/// numerically using the attribute syntax as "(%ir-block.{ir-slot})". -/// -/// When the \ref PrintNameAttributes flag is passed, additional attributes -/// of the block are printed when set. -/// -/// \param printNameFlags Combination of \ref PrintNameFlag flags indicating -/// the parts to print. -/// \param moduleSlotTracker Optional ModuleSlotTracker. This method will -/// incorporate its own tracker when necessary to -/// determine the block's IR name. -void MachineBasicBlock::printName(raw_ostream &os, unsigned printNameFlags, - ModuleSlotTracker *moduleSlotTracker) const { - os << "bb." << getNumber(); - bool hasAttributes = false; - - if (printNameFlags & PrintNameIr) { - if (const auto *bb = getBasicBlock()) { - if (bb->hasName()) { - os << '.' << bb->getName(); - } else { - hasAttributes = true; - os << " ("; - - int slot = -1; - - if (moduleSlotTracker) { - slot = moduleSlotTracker->getLocalSlot(bb); - } else if (bb->getParent()) { - ModuleSlotTracker tmpTracker(bb->getModule(), false); - tmpTracker.incorporateFunction(*bb->getParent()); - slot = tmpTracker.getLocalSlot(bb); - } - - if (slot == -1) - os << "<ir-block badref>"; - else - os << (Twine("%ir-block.") + Twine(slot)).str(); - } - } - } - - if (printNameFlags & PrintNameAttributes) { - if (hasAddressTaken()) { - os << (hasAttributes ? ", " : " ("); - os << "address-taken"; - hasAttributes = true; - } - if (isEHPad()) { - os << (hasAttributes ? ", " : " ("); - os << "landing-pad"; - hasAttributes = true; - } - if (isEHFuncletEntry()) { - os << (hasAttributes ? ", " : " ("); - os << "ehfunclet-entry"; - hasAttributes = true; - } - if (getAlignment() != Align(1)) { - os << (hasAttributes ? ", " : " ("); - os << "align " << getAlignment().value(); - hasAttributes = true; - } - if (getSectionID() != MBBSectionID(0)) { - os << (hasAttributes ? ", " : " ("); - os << "bbsections "; - switch (getSectionID().Type) { - case MBBSectionID::SectionType::Exception: - os << "Exception"; - break; - case MBBSectionID::SectionType::Cold: - os << "Cold"; - break; - default: - os << getSectionID().Number; - } - hasAttributes = true; - } - } - - if (hasAttributes) - os << ')'; -} - +/// Print the basic block's name as: +/// +/// bb.{number}[.{ir-name}] [(attributes...)] +/// +/// The {ir-name} is only printed when the \ref PrintNameIr flag is passed +/// (which is the default). If the IR block has no name, it is identified +/// numerically using the attribute syntax as "(%ir-block.{ir-slot})". +/// +/// When the \ref PrintNameAttributes flag is passed, additional attributes +/// of the block are printed when set. +/// +/// \param printNameFlags Combination of \ref PrintNameFlag flags indicating +/// the parts to print. +/// \param moduleSlotTracker Optional ModuleSlotTracker. This method will +/// incorporate its own tracker when necessary to +/// determine the block's IR name. +void MachineBasicBlock::printName(raw_ostream &os, unsigned printNameFlags, + ModuleSlotTracker *moduleSlotTracker) const { + os << "bb." << getNumber(); + bool hasAttributes = false; + + if (printNameFlags & PrintNameIr) { + if (const auto *bb = getBasicBlock()) { + if (bb->hasName()) { + os << '.' << bb->getName(); + } else { + hasAttributes = true; + os << " ("; + + int slot = -1; + + if (moduleSlotTracker) { + slot = moduleSlotTracker->getLocalSlot(bb); + } else if (bb->getParent()) { + ModuleSlotTracker tmpTracker(bb->getModule(), false); + tmpTracker.incorporateFunction(*bb->getParent()); + slot = tmpTracker.getLocalSlot(bb); + } + + if (slot == -1) + os << "<ir-block badref>"; + else + os << (Twine("%ir-block.") + Twine(slot)).str(); + } + } + } + + if (printNameFlags & PrintNameAttributes) { + if (hasAddressTaken()) { + os << (hasAttributes ? ", " : " ("); + os << "address-taken"; + hasAttributes = true; + } + if (isEHPad()) { + os << (hasAttributes ? ", " : " ("); + os << "landing-pad"; + hasAttributes = true; + } + if (isEHFuncletEntry()) { + os << (hasAttributes ? ", " : " ("); + os << "ehfunclet-entry"; + hasAttributes = true; + } + if (getAlignment() != Align(1)) { + os << (hasAttributes ? ", " : " ("); + os << "align " << getAlignment().value(); + hasAttributes = true; + } + if (getSectionID() != MBBSectionID(0)) { + os << (hasAttributes ? ", " : " ("); + os << "bbsections "; + switch (getSectionID().Type) { + case MBBSectionID::SectionType::Exception: + os << "Exception"; + break; + case MBBSectionID::SectionType::Cold: + os << "Cold"; + break; + default: + os << getSectionID().Number; + } + hasAttributes = true; + } + } + + if (hasAttributes) + os << ')'; +} + void MachineBasicBlock::printAsOperand(raw_ostream &OS, bool /*PrintType*/) const { - OS << '%'; - printName(OS, 0); + OS << '%'; + printName(OS, 0); } void MachineBasicBlock::removeLiveIn(MCPhysReg Reg, LaneBitmask LaneMask) { @@ -583,7 +583,7 @@ void MachineBasicBlock::sortUniqueLiveIns() { Register MachineBasicBlock::addLiveIn(MCRegister PhysReg, const TargetRegisterClass *RC) { assert(getParent() && "MBB must be inserted in function"); - assert(Register::isPhysicalRegister(PhysReg) && "Expected physreg"); + assert(Register::isPhysicalRegister(PhysReg) && "Expected physreg"); assert(RC && "Register class is required"); assert((isEHPad() || this == &getParent()->front()) && "Only the entry block and landing pads can have physreg live ins"); @@ -749,7 +749,7 @@ void MachineBasicBlock::splitSuccessor(MachineBasicBlock *Old, bool NormalizeSuccProbs) { succ_iterator OldI = llvm::find(successors(), Old); assert(OldI != succ_end() && "Old is not a successor of this block!"); - assert(!llvm::is_contained(successors(), New) && + assert(!llvm::is_contained(successors(), New) && "New is already a successor of this block!"); // Add a new successor with equal probability as the original one. Note @@ -828,7 +828,7 @@ void MachineBasicBlock::replaceSuccessor(MachineBasicBlock *Old, void MachineBasicBlock::copySuccessor(MachineBasicBlock *Orig, succ_iterator I) { - if (!Orig->Probs.empty()) + if (!Orig->Probs.empty()) addSuccessor(*I, Orig->getSuccProbability(I)); else addSuccessorWithoutProb(*I); @@ -944,47 +944,47 @@ bool MachineBasicBlock::canFallThrough() { return getFallThrough() != nullptr; } -MachineBasicBlock *MachineBasicBlock::splitAt(MachineInstr &MI, - bool UpdateLiveIns, - LiveIntervals *LIS) { - MachineBasicBlock::iterator SplitPoint(&MI); - ++SplitPoint; - - if (SplitPoint == end()) { - // Don't bother with a new block. - return this; - } - - MachineFunction *MF = getParent(); - - LivePhysRegs LiveRegs; - if (UpdateLiveIns) { - // Make sure we add any physregs we define in the block as liveins to the - // new block. - MachineBasicBlock::iterator Prev(&MI); - LiveRegs.init(*MF->getSubtarget().getRegisterInfo()); - LiveRegs.addLiveOuts(*this); - for (auto I = rbegin(), E = Prev.getReverse(); I != E; ++I) - LiveRegs.stepBackward(*I); - } - - MachineBasicBlock *SplitBB = MF->CreateMachineBasicBlock(getBasicBlock()); - - MF->insert(++MachineFunction::iterator(this), SplitBB); - SplitBB->splice(SplitBB->begin(), this, SplitPoint, end()); - - SplitBB->transferSuccessorsAndUpdatePHIs(this); - addSuccessor(SplitBB); - - if (UpdateLiveIns) - addLiveIns(*SplitBB, LiveRegs); - - if (LIS) - LIS->insertMBBInMaps(SplitBB); - - return SplitBB; -} - +MachineBasicBlock *MachineBasicBlock::splitAt(MachineInstr &MI, + bool UpdateLiveIns, + LiveIntervals *LIS) { + MachineBasicBlock::iterator SplitPoint(&MI); + ++SplitPoint; + + if (SplitPoint == end()) { + // Don't bother with a new block. + return this; + } + + MachineFunction *MF = getParent(); + + LivePhysRegs LiveRegs; + if (UpdateLiveIns) { + // Make sure we add any physregs we define in the block as liveins to the + // new block. + MachineBasicBlock::iterator Prev(&MI); + LiveRegs.init(*MF->getSubtarget().getRegisterInfo()); + LiveRegs.addLiveOuts(*this); + for (auto I = rbegin(), E = Prev.getReverse(); I != E; ++I) + LiveRegs.stepBackward(*I); + } + + MachineBasicBlock *SplitBB = MF->CreateMachineBasicBlock(getBasicBlock()); + + MF->insert(++MachineFunction::iterator(this), SplitBB); + SplitBB->splice(SplitBB->begin(), this, SplitPoint, end()); + + SplitBB->transferSuccessorsAndUpdatePHIs(this); + addSuccessor(SplitBB); + + if (UpdateLiveIns) + addLiveIns(*SplitBB, LiveRegs); + + if (LIS) + LIS->insertMBBInMaps(SplitBB); + + return SplitBB; +} + MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge( MachineBasicBlock *Succ, Pass &P, std::vector<SparseBitVector<>> *LiveInSets) { |