Lines Matching +full:p +full:- +full:mos
1 //===- VarLocBasedImpl.cpp - Tracking Debug Value MIs with VarLoc class----===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
14 /// fragment might be located, qualified by a DIExpression and indirect-ness
18 /// clobbered or re-specified by a different DBG_VALUE for the same
27 /// clobbering, instead when a variable is re-assigned, any expressions using
33 /// needed when a DebugVariable has its location re-specified, to invalidate
38 /// live-in. This propagates variable locations into every basic block where
61 /// Formally, all DebugVariable locations that are live-out of a block are
62 /// initialized to \top. A blocks live-in values take the meet of the lattice
63 /// value for every predecessors live-outs, except for the entry block, where
64 /// all live-ins are \bot. The usual dataflow propagation occurs: the transfer
67 /// clobbered; or the live-in value if it is unaffected by the block. We
76 /// that variable locations are live-through every loop, and then removing those
81 /// machine-locations that currently describe it (a single location for
83 /// specifies the location. Each VarLoc is indexed in the (function-scope) \p
85 /// corresponds to one of the VarLoc's machine-locations and can be used to
96 /// for each live-in location at the start of blocks, while "Transfers" records
97 /// transfers of values between machine-locations.
111 //===----------------------------------------------------------------------===//
137 #include "llvm/Config/llvm-config.h"
164 /// If \p Op is a stack or frame register return true, otherwise return false.
173 const MachineFunction *MF = MI.getParent()->getParent(); in isRegOtherThanSPAndFP()
174 const TargetLowering *TLI = MF->getSubtarget().getTargetLowering(); in isRegOtherThanSPAndFP()
175 Register SP = TLI->getStackPointerRegisterToSaveRestore(); in isRegOtherThanSPAndFP()
176 Register FP = TRI->getFrameRegister(*MF); in isRegOtherThanSPAndFP()
197 /// A type-checked pair of {Register Location (or 0), Index}, used to index
198 /// into a \ref VarLocMap. This can be efficiently converted to a 64-bit int
200 /// type-checker helps ensure that the conversions aren't lossy.
204 /// performance-critical operation for LiveDebugValues.
211 // here to encode non-register locations.
257 /// which reside in \p Reg. The end is at rawIndexForReg(Reg+1)-1.
263 /// \p Location in \p Set.
311 // Target indices used for wasm-specific locations.
314 // local-related TargetIndex in this analysis (TI_LOCAL and
424 MI.getDebugLoc()->getInlinedAt()), in VarLoc()
473 /// Take the variable and machine-location in DBG_VALUE MI, and build an
486 /// Take the variable and machine-location from the DBG_VALUE (from the
500 /// Take the variable and machine-location from the DBG_VALUE (from the
544 /// Copies variable-specific information such as DILocalVariable and
557 SmallVector<MachineOperand, 8> MOs; in BuildDbgValue() local
564 // An entry value is a register location -- but with an updated in BuildDbgValue()
568 // Non-entry value register locations are like the source in BuildDbgValue()
570 MOs.push_back(MachineOperand::CreateReg( in BuildDbgValue()
584 DIExpr = TRI->prependOffsetExpression( in BuildDbgValue()
590 TRI->getOffsetOpcodes(Loc.SpillLocation.SpillOffset, Ops); in BuildDbgValue()
594 MOs.push_back(MachineOperand::CreateReg(Base, false)); in BuildDbgValue()
598 MOs.push_back(Orig); in BuildDbgValue()
602 MOs.push_back(Orig); in BuildDbgValue()
609 return BuildMI(MF, DbgLoc, IID, Indirect, MOs, Var, DIExpr); in BuildDbgValue()
623 /// If this variable is described by register \p Reg holding the entry
629 /// If this variable is described by register \p Reg holding a copy of the
636 /// If this variable is described in whole or part by \p Reg, return true.
644 /// If this variable is described in whole or part by \p Reg, return true.
654 /// add each of them to \p Regs and return true.
671 /// If this variable is described in whole or part by \p SpillLocation,
680 /// If this variable is described in whole or part by \p SpillLocation,
696 /// If this variable is described in whole or part by \p WasmLocation,
735 auto Indices = TII->getSerializableTargetIndices(); in dump()
741 Out << Found->second; in dump()
754 Out << ", \"" << Var.getVariable()->getName() << "\", " << *Expr << ", "; in dump()
756 Out << "!" << Var.getInlinedAt()->getMetadataID() << ")\n"; in dump()
797 /// Retrieve LocIndices for \p VL.
837 return IndIt->second; in getAllIndices()
840 /// Retrieve the unique VarLoc associated with \p ID.
844 return LocIt->second[ID.Index]; in operator []()
873 /// Collects all VarLocs from \p CollectFrom. Each unique VarLoc is added
874 /// to \p Collected once, in order of insertion into \p VarLocIDs.
880 /// by \p CollectFrom.
908 // Fetches all VarLocs in \p VarLocIDs and inserts them into \p Collected.
955 /// Get all set IDs for VarLocs with MLs of kind RegisterKind in \p Reg.
980 /// Collect all VarLoc IDs from \p CollectFrom for VarLocs with MLs of kind
981 /// RegisterKind which are located in any reg in \p Regs. The IDs for each
983 /// VarLoc has exactly 1 entry for. Insert collected IDs into \p Collected.
1000 return *It->second; in getVarLocsInMBB()
1008 /// - Is this instruction a store to a spill slot?
1009 /// - Is there a register operand that is both used and killed?
1024 /// and set \p Reg to the spilled register.
1104 //===----------------------------------------------------------------------===//
1106 //===----------------------------------------------------------------------===//
1121 auto It = EraseFrom->find(VarToErase); in erase()
1122 if (It != EraseFrom->end()) { in erase()
1123 LocIndices IDs = It->second; in erase()
1126 EraseFrom->erase(It); in erase()
1140 // in the pre-computed overlap map, and erase them too. in erase()
1143 for (auto Fragment : MapIt->second) { in erase()
1159 EraseFrom->erase(VL.Var); in erase()
1186 InsertInto->insert({VL.Var, VarLocIDs}); in insert()
1195 return It->second; in getEntryValueBackup()
1211 // The half-open interval [FirstIndexForReg, FirstInvalidIndex) contains in collectIDsForRegs()
1218 // Iterate through that half-open interval and collect all the set IDs. in collectIDsForRegs()
1237 // All register-based VarLocs are assigned indices greater than or equal to in getUsedRegs()
1261 //===----------------------------------------------------------------------===//
1263 //===----------------------------------------------------------------------===//
1282 Out << " Var: " << VL.Var.getVariable()->getName(); in printVarLocInMBB()
1296 const PseudoSourceValue *PVal = (*MMOI)->getPseudoValue(); in extractSpillBaseRegAndOffset()
1297 assert(PVal->kind() == PseudoSourceValue::FixedStack && in extractSpillBaseRegAndOffset()
1299 int FI = cast<FixedStackPseudoSourceValue>(PVal)->getFrameIndex(); in extractSpillBaseRegAndOffset()
1302 StackOffset Offset = TFI->getFrameIndexReference(*MBB->getParent(), FI, Reg); in extractSpillBaseRegAndOffset()
1306 /// Do cleanup of \p EntryValTransfers created by \p TRInst, by removing the
1307 /// Transfer, which uses the to-be-deleted \p EntryVL.
1347 // Try to get non-debug instruction responsible for the DBG_VALUE. in removeEntryValue()
1351 TransferInst = RegSetInstrs.find(Reg)->second; in removeEntryValue()
1354 if (!TransferInst && !LastNonDbgMI && MI.getParent()->isEntryBlock()) in removeEntryValue()
1360 if (MI.getDebugExpression()->getNumElements() == 0 && TransferInst) { in removeEntryValue()
1367 auto DestSrc = TII->isCopyLikeInstr(*TransferInst); in removeEntryValue()
1370 SrcRegOp = DestSrc->Source; in removeEntryValue()
1371 DestRegOp = DestSrc->Destination; in removeEntryValue()
1372 if (Reg == DestRegOp->getReg()) { in removeEntryValue()
1377 VL.MI.getDebugOperand(0).getReg() == SrcRegOp->getReg()) in removeEntryValue()
1405 const DILocation *InlinedAt = DebugLoc->getInlinedAt(); in transferDebugValue()
1406 assert(Var->isValidLocationForIntrinsic(DebugLoc) && in transferDebugValue()
1407 "Expected inlined-at fields to agree"); in transferDebugValue()
1414 if (Var->isParameter() && EntryValBackupID) { in transferDebugValue()
1415 const VarLoc &EntryVL = VarLocIDs[EntryValBackupID->back()]; in transferDebugValue()
1437 "Unexpected non-undef DBG_VALUE encountered"); in transferDebugValue()
1447 // The half-open interval [FirstIndexForReg, FirstInvalidIndex) contains all in collectAllVarLocs()
1453 // Iterate through that half-open interval and collect all the set IDs. in collectAllVarLocs()
1475 if (!VL.Var.getVariable()->isParameter()) in emitEntryValues()
1487 const VarLoc &EntryVL = VarLocIDs[EntryValBackupIDs->back()]; in emitEntryValues()
1498 /// Create new TransferDebugPair and insert it in \p Transfers. The VarLoc
1499 /// with \p OldVarID should be deleted form \p OpenRanges and replaced with
1500 /// new VarLoc. If \p NewReg is different than default zero value then the
1555 // DebugInstr refers to the pre-spill location, therefore we can reuse in insertTransferDebugPair()
1582 const TargetLowering *TLI = MF->getSubtarget().getTargetLowering(); in transferRegisterDef()
1583 Register SP = TLI->getStackPointerRegisterToSaveRestore(); in transferRegisterDef()
1614 // callee-cleanup calls, transferring the DEBUG_VALUE across the call is in transferRegisterDef()
1639 auto &TM = TPC->getTM<TargetMachine>(); in transferRegisterDef()
1652 if (!TII->isExplicitTargetIndexDef(MI, Index, Offset)) in transferWasmDef()
1707 if (MI.getParent()->end() == NextI) in isLocationSpill()
1710 for (const MachineOperand &MONext : NextI->operands()) { in isLocationSpill()
1741 /// the DBG_VALUE without inserting it and keep track of it in \p Transfers.
1766 // This location is overwritten by the current instruction -- terminate in transferSpillOrRestoreInst()
1769 // Doing this at a later stage would require re-interpreting all in transferSpillOrRestoreInst()
1815 << VL.Var.getVariable()->getName() << ")\n"); in transferSpillOrRestoreInst()
1824 << VL.Var.getVariable()->getName() << ")\n"); in transferSpillOrRestoreInst()
1836 /// If \p MI is a register copy instruction, that copies a previously tracked
1843 auto DestSrc = TII->isCopyLikeInstr(MI); in transferRegisterCopy()
1847 const MachineOperand *DestRegOp = DestSrc->Destination; in transferRegisterCopy()
1848 const MachineOperand *SrcRegOp = DestSrc->Source; in transferRegisterCopy()
1850 if (!DestRegOp->isDef()) in transferRegisterCopy()
1860 Register SrcReg = SrcRegOp->getReg(); in transferRegisterCopy()
1861 Register DestReg = DestRegOp->getReg(); in transferRegisterCopy()
1893 if (!SrcRegOp->isKill()) in transferRegisterCopy()
1921 dbgs() << "Add to OutLocs in MBB #" << CurMBB->getNumber() << ": "; in transferTerminator()
1937 /// the data-flow stage from "Find any overlapping fragments" to "Check if the
1938 /// known-to-overlap fragments are present".
1949 MI.getDebugLoc()->getInlinedAt()); in accumulateFragmentMap()
1972 auto &ThisFragmentsOverlaps = IsInOLapMap.first->second; in accumulateFragmentMap()
1973 auto &AllSeenFragments = SeenIt->second; in accumulateFragmentMap()
1989 ASeenFragmentsOverlaps->second.push_back(ThisFragment); in accumulateFragmentMap()
2013 /// inserting a new DBG_VALUE instruction at the start of the @MBB - if the same
2027 for (auto *p : MBB.predecessors()) { in join() local
2033 if (!Visited.count(p)) { in join()
2034 LLVM_DEBUG(dbgs() << " ignoring unvisited pred MBB: " << p->getNumber() in join()
2038 auto OL = OutLocs.find(p); in join()
2045 VarLocSet &OutLocVLS = *OL->second; in join()
2057 << VL.Var.getVariable()->getName() << "\n"; in join()
2073 auto Name = VarLocIDs[Idx].Var.getVariable()->getName(); in join()
2081 // As we are processing blocks in reverse post-order we in join()
2110 // The ID location is live-in to MBB -- work out what kind of machine in flushPendingLocs()
2118 LLVM_DEBUG(dbgs() << "Inserted: "; MI->dump();); in flushPendingLocs()
2132 if (!DIVar->isParameter()) in isEntryValueCandidate()
2136 if (MI.getDebugLoc()->getInlinedAt()) in isEntryValueCandidate()
2152 // TODO: Add support for parameters that have a pre-existing debug expressions in isEntryValueCandidate()
2156 if (Expr->getNumElements() > 0 && !Expr->isDeref()) in isEntryValueCandidate()
2182 auto &TM = TPC->getTM<TargetMachine>(); in recordEntryValue()
2188 MI.getDebugLoc()->getInlinedAt()); in recordEntryValue()
2219 if (MF.getFunction().getSubprogram()->getUnit()->getEmissionKind() == in ExtendRanges()
2226 TFI->getCalleeSaves(MF, CalleeSavedRegs); in ExtendRanges()
2227 this->TPC = TPC; in ExtendRanges()
2275 // Initialize per-block structures and scan for fragment overlaps. in ExtendRanges()
2281 auto hasNonArtificialLocation = [](const MachineInstr &MI) -> bool { in ExtendRanges()
2356 for (auto *s : MBB->successors()) in ExtendRanges()
2371 assert(!TR.TransferInst->isTerminator() && in ExtendRanges()
2373 MachineBasicBlock *MBB = TR.TransferInst->getParent(); in ExtendRanges()
2376 MBB->insertAfterBundle(TR.TransferInst->getIterator(), MI); in ExtendRanges()
2383 assert(!TRInst->isTerminator() && in ExtendRanges()
2385 MachineBasicBlock *MBB = TRInst->getParent(); in ExtendRanges()
2388 MBB->insertAfterBundle(TRInst->getIterator(), MI); in ExtendRanges()