24#define DEBUG_TYPE "codegen-common"
31StackProtectorDescriptor::addSuccessorMBB(
39 MF->
insert(++BBI, SuccMBB);
58 if (!
MI.isCopy() && !
MI.isImplicitDef()) {
63 if (
MI.isDebugInstr())
68 switch (
MI.getOpcode()) {
69 case TargetOpcode::G_TRUNC:
70 case TargetOpcode::G_ZEXT:
71 case TargetOpcode::G_ANYEXT:
72 case TargetOpcode::G_SEXT:
73 case TargetOpcode::G_MERGE_VALUES:
74 case TargetOpcode::G_UNMERGE_VALUES:
75 case TargetOpcode::G_CONCAT_VECTORS:
76 case TargetOpcode::G_BUILD_VECTOR:
77 case TargetOpcode::G_EXTRACT:
97 if (
MI.isImplicitDef())
104 &&
"Should have a copy implying we should have 2 arguments.");
108 if (!OPI2->
isReg() ||
132 if (SplitPoint == BB->
begin())
139 }
while (Previous != Start && Previous->isDebugInstr());
141 if (
TII.isTailCall(*SplitPoint) &&
142 Previous->getOpcode() ==
TII.getCallFrameDestroyOpcode()) {
161 if (Previous->isCall())
163 }
while(Previous->getOpcode() !=
TII.getCallFrameSetupOpcode());
169 SplitPoint = Previous;
170 if (Previous == Start)
183 switch (
static_cast<unsigned>(InvertedTest)) {
212 return UseFCmp ? InvertedTest :
fcNone;
222 assert((Copy.getOpcode() == TargetOpcode::COPY ||
223 Copy.getOpcode() == TargetOpcode::G_BITCAST) &&
224 "Must be a COPY or G_BITCAST");
226 return &Copy.getOperand(1);
232 assert(
Trunc.getOpcode() == TargetOpcode::G_TRUNC &&
"Must be a G_TRUNC");
234 const auto FromLLT =
MRI.getType(
Trunc.getOperand(1).getReg());
235 const auto ToLLT =
MRI.getType(
Trunc.defs().begin()->getReg());
238 if (!FromLLT.isScalar()) {
243 ToLLT.getSizeInBits(),
false);
244 Ops.append(ExtOps.begin(), ExtOps.end());
245 return &
Trunc.getOperand(1);
251 switch (
MI.getOpcode()) {
252 case TargetOpcode::G_TRUNC:
254 case TargetOpcode::COPY:
255 case TargetOpcode::G_BITCAST:
278 if (VecSize > *VarSize)
283 unsigned EltSize = VecSize / NumElts;
285 for (
unsigned I = 0;
I != NumElts; ++
I) {
295 for (
unsigned I = NumElts - 1;
I != 0; --
I) {
313 const unsigned MaxExpressionSize = 128;
316 for (
auto *DefMO : DbgUsers) {
320 if (!Visited.
insert(DbgMI).second)
328 "Must use salvaged instruction as its location");
330 if (
MI.getOpcode() == TargetOpcode::G_BUILD_VECTOR) {
332 "Must be either DBG_VALUE or DBG_VALUE_LIST");
350 bool IsValidSalvageExpr =
352 if (IsValidSalvageExpr) {
354 LocMO->setReg(Op0->getReg());
355 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...