25#define DEBUG_TYPE "codegen-common"
32StackProtectorDescriptor::addSuccessorMBB(
40 MF->
insert(++BBI, SuccMBB);
59 if (!
MI.isCopy() && !
MI.isImplicitDef()) {
64 if (
MI.isDebugInstr())
69 switch (
MI.getOpcode()) {
70 case TargetOpcode::G_TRUNC:
71 case TargetOpcode::G_ZEXT:
72 case TargetOpcode::G_ANYEXT:
73 case TargetOpcode::G_SEXT:
74 case TargetOpcode::G_MERGE_VALUES:
75 case TargetOpcode::G_UNMERGE_VALUES:
76 case TargetOpcode::G_CONCAT_VECTORS:
77 case TargetOpcode::G_BUILD_VECTOR:
78 case TargetOpcode::G_EXTRACT:
98 if (
MI.isImplicitDef())
105 &&
"Should have a copy implying we should have 2 arguments.");
109 if (!OPI2->
isReg() ||
133 if (SplitPoint == BB->
begin())
140 }
while (Previous != Start && Previous->isDebugInstr());
142 if (
TII.isTailCall(*SplitPoint) &&
143 Previous->getOpcode() ==
TII.getCallFrameDestroyOpcode()) {
162 if (Previous->isCall())
164 }
while(Previous->getOpcode() !=
TII.getCallFrameSetupOpcode());
170 SplitPoint = Previous;
171 if (Previous == Start)
184 switch (
static_cast<unsigned>(InvertedTest)) {
213 return UseFCmp ? InvertedTest :
fcNone;
223 assert((Copy.getOpcode() == TargetOpcode::COPY ||
224 Copy.getOpcode() == TargetOpcode::G_BITCAST) &&
225 "Must be a COPY or G_BITCAST");
227 return &Copy.getOperand(1);
233 assert(
Trunc.getOpcode() == TargetOpcode::G_TRUNC &&
"Must be a G_TRUNC");
235 const auto FromLLT =
MRI.getType(
Trunc.getOperand(1).getReg());
236 const auto ToLLT =
MRI.getType(
Trunc.defs().begin()->getReg());
239 if (!FromLLT.isScalar()) {
244 ToLLT.getSizeInBits(),
false);
245 Ops.append(ExtOps.begin(), ExtOps.end());
246 return &
Trunc.getOperand(1);
252 switch (
MI.getOpcode()) {
253 case TargetOpcode::G_TRUNC:
255 case TargetOpcode::COPY:
256 case TargetOpcode::G_BITCAST:
279 if (VecSize > *VarSize)
284 unsigned EltSize = VecSize / NumElts;
286 for (
unsigned I = 0;
I != NumElts; ++
I) {
296 for (
unsigned I = NumElts - 1;
I != 0; --
I) {
314 const unsigned MaxExpressionSize = 128;
317 for (
auto *DefMO : DbgUsers) {
321 if (!Visited.
insert(DbgMI).second)
329 "Must use salvaged instruction as its location");
331 if (
MI.getOpcode() == TargetOpcode::G_BUILD_VECTOR) {
333 "Must be either DBG_VALUE or DBG_VALUE_LIST");
351 bool IsValidSalvageExpr =
353 if (IsValidSalvageExpr) {
355 LocMO->setReg(Op0->getReg());
356 LocMO->setSubReg(Op0->getSubReg());
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void salvageBuildVector(const MachineRegisterInfo &MRI, MachineInstr &BuildVector, MachineInstr &DbgMI)
Replace DbgMI, which describes the result of BuildVector, with one fragment debug value per vector el...
static MachineOperand * getSalvageOpsForTrunc(const MachineRegisterInfo &MRI, MachineInstr &Trunc, SmallVectorImpl< uint64_t > &Ops)
static MachineOperand * getSalvageOpsForCopy(const MachineRegisterInfo &MRI, MachineInstr &Copy)
static bool MIIsInTerminatorSequence(const MachineInstr &MI)
Given that the input MI is before a partial terminator sequence TSeq, return true if M + TSeq also a ...
const HexagonInstrInfo * TII
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
MachineRegisterInfo & MRI
This file defines the SmallPtrSet class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
static BranchProbability getBranchProbStackProtector(bool IsLikely)
unsigned getNumElements() const
static LLVM_ABI ExtOps getExtOps(unsigned FromSize, unsigned ToSize, bool Signed)
Returns the ops for a zero- or sign-extension in a DIExpression.
static LLVM_ABI DIExpression * appendOpsToArg(const DIExpression *Expr, ArrayRef< uint64_t > Ops, unsigned ArgNo, bool StackValue=false)
Create a copy of Expr by appending the given list of Ops to each instance of the operand DW_OP_LLVM_a...
LLVM_ABI bool isComplex() const
Return whether the location is computed on the expression stack, meaning it cannot be a simple regist...
static LLVM_ABI std::optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
static LLVM_ABI std::optional< DIExpression * > createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits)
Create a DIExpression to describe one part of an aggregate variable that is fragmented across multipl...
LLVM_ABI bool isSingleLocationExpression() const
Return whether the evaluated expression makes use of a single location at the start of the expression...
LLVM_ABI std::optional< uint64_t > getSizeInBits() const
Determines the size of the variable's type.
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineInstrBundleIterator< MachineInstr > iterator
BasicBlockListType::iterator iterator
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *BB=nullptr, std::optional< UniqueBBID > BBID=std::nullopt)
CreateMachineInstr - Allocate a new MachineInstr.
void insert(iterator MBBI, MachineBasicBlock *MBB)
Representation of each machine instruction.
bool hasDebugOperandForReg(Register Reg) const
Returns whether this debug value has at least one debug operand with the register Reg.
LLVM_ABI iterator_range< filter_iterator< const MachineOperand *, std::function< bool(const MachineOperand &Op)> > > getDebugOperandsForReg(Register Reg) const
Returns a range of all of the operands that correspond to a debug use of Reg.
const MachineBasicBlock * getParent() const
LLVM_ABI const MachineOperand & getDebugExpressionOp() const
Return the operand for the complex address expression referenced by this DBG_VALUE instruction.
unsigned getNumDebugOperands() const
Returns the total number of operands which are debug locations.
unsigned getNumOperands() const
Retuns the total number of operands.
const MachineOperand * const_mop_iterator
LLVM_ABI const DILocalVariable * getDebugVariable() const
Return the debug variable referenced by this DBG_VALUE instruction.
LLVM_ABI const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
bool isDebugValue() const
unsigned getDebugOperandIndex(const MachineOperand *Op) const
MachineOperand & getDebugOperand(unsigned Index)
const MachineOperand & getOperand(unsigned i) const
bool isIndirectDebugValue() const
A DBG_VALUE is indirect iff the location operand is a register and the offset operand is an immediate...
MachineOperand class - Representation of each machine instruction operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
void setMetadata(const MDNode *MD)
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Wrapper class representing virtual and physical registers.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TargetInstrInfo - Interface to description of machine instruction set.
self_iterator getIterator()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI FPClassTest invertFPClassTestIfSimpler(FPClassTest Test, bool UseFCmp)
Evaluates if the specified FP class test is better performed as the inverse (i.e.
LLVM_ABI MachineBasicBlock::iterator findSplitPointForStackProtector(MachineBasicBlock *BB, const TargetInstrInfo &TII)
Find the split point at which to splice the end of BB into its success stack protector check machine ...
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI Value * salvageDebugInfoImpl(Instruction &I, uint64_t CurrentLocOps, SmallVectorImpl< uint64_t > &Ops, SmallVectorImpl< Value * > &AdditionalValues)
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
LLVM_ABI void salvageDebugInfoForDbgValue(const MachineRegisterInfo &MRI, MachineInstr &MI, ArrayRef< MachineOperand * > DbgUsers)
Assuming the instruction MI is going to be deleted, attempt to salvage debug users of MI by writing t...