44 #define DEBUG_TYPE "function-lowering-info"
51 if (isa<PHINode>(I))
return true;
54 if (cast<Instruction>(U)->getParent() != BB || isa<PHINode>(U))
69 unsigned NumOfSigned = 0, NumOfUnsigned = 0;
71 if (
const auto *CI = dyn_cast<CmpInst>(U)) {
72 NumOfSigned += CI->isSigned();
73 NumOfUnsigned += CI->isUnsigned();
76 if (NumOfSigned > NumOfUnsigned)
116 CatchObjects.
insert({AI, {}}).
first->second.push_back(
129 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(&
I)) {
130 Type *Ty = AI->getAllocatedType();
138 if (AI->isStaticAlloca() &&
140 const ConstantInt *CUI = cast<ConstantInt>(AI->getArraySize());
144 if (TySize == 0) TySize = 1;
146 auto Iter = CatchObjects.
find(AI);
147 if (Iter != CatchObjects.
end() && TLI->needsFixedCatchObjects()) {
149 TySize, 0,
false,
true);
158 if (Iter != CatchObjects.
end()) {
159 for (
int *CatchObjPtr : Iter->second)
166 if (Align <= StackAlign)
174 if (isa<CallInst>(
I) || isa<InvokeInst>(
I)) {
177 unsigned SP = TLI->getStackPointerRegisterToSaveRestore();
179 std::vector<TargetLowering::AsmOperandInfo> Ops =
180 TLI->ParseConstraints(Fn->getParent()->getDataLayout(), TRI, CS);
184 TLI->ComputeConstraintToUse(
Op,
SDValue(), DAG);
185 std::pair<unsigned, const TargetRegisterClass *> PhysReg =
186 TLI->getRegForInlineAsmConstraint(TRI,
Op.ConstraintCode,
188 if (PhysReg.first == SP)
198 if (
const auto *II = dyn_cast<IntrinsicInst>(&
I)) {
199 if (II->getIntrinsicID() == Intrinsic::vastart)
205 if (
const auto *CI = dyn_cast<CallInst>(&
I)) {
206 if (CI->isMustTailCall() && Fn->isVarArg())
233 if (!isa<LandingPadInst>(PadInst)) {
237 if (isa<CatchSwitchInst>(PadInst)) {
238 assert(&*BB.begin() == PadInst &&
239 "WinEHPrepare failed to remove PHIs from imaginary BBs");
242 if (isa<FuncletPadInst>(PadInst))
243 assert(&*BB.begin() == PadInst &&
"WinEHPrepare failed to demote PHIs");
253 if (BB.hasAddressTaken())
272 assert(PHIReg &&
"PHI node does not have an assigned virtual register!");
276 for (
EVT VT : ValueVTs) {
277 unsigned NumRegisters = TLI->getNumRegisters(Fn->getContext(), VT);
279 for (
unsigned i = 0; i != NumRegisters; ++i)
280 BuildMI(MBB, DL, TII->
get(TargetOpcode::PHI), PHIReg + i);
281 PHIReg += NumRegisters;
318 LiveOutRegInfo.clear();
347 unsigned FirstReg = 0;
353 for (
unsigned i = 0; i != NumRegs; ++i) {
355 if (!FirstReg) FirstReg = R;
368 if (!LiveOutRegInfo.inBounds(Reg))
393 "PHIs with non-vector integer types should have a single VT.");
394 EVT IntVT = ValueVTs[0];
404 LiveOutRegInfo.grow(DestReg);
408 if (isa<UndefValue>(V) || isa<ConstantExpr>(V)) {
421 "CopyToReg node was created.");
437 "Masks should have the same bit width as the type.");
441 if (isa<UndefValue>(V) || isa<ConstantExpr>(V)) {
456 "its CopyToReg node was created.");
488 DEBUG(
dbgs() <<
"Argument does not have assigned frame index!\n");
496 unsigned &VReg =
I.first->second;
499 assert(VReg &&
"null vreg in exception pointer table!");
506 auto Key = std::make_pair(MBB, Val);
519 }
else return It->second;
527 std::pair<unsigned, bool>
536 return std::make_pair(VReg,
true);
538 return std::make_pair(It->second,
false);
541 std::pair<unsigned, bool>
548 return std::make_pair(VReg,
true);
550 return std::make_pair(It->second,
false);
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
SmallVector< WinEHHandlerType, 1 > HandlerArray
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This class represents an incoming formal argument to a Function.
unsigned getNumRegisters(LLVMContext &Context, EVT VT) const
Return the number of registers that this ValueType will eventually require.
unsigned getCatchPadExceptionPointerVReg(const Value *CPI, const TargetRegisterClass *RC)
void setIsEHPad(bool V=true)
Indicates the block is a landing pad.
SmallVector< SEHUnwindMapEntry, 4 > SEHUnwindMap
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
void setHasEHFunclets(bool V)
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
size_type count(const KeyT &Val) const
Return 1 if the specified key is in the map, 0 otherwise.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
const AllocaInst * Alloca
DenseMap< const Value *, unsigned > CatchPadExceptionPointers
Track virtual registers created for exception pointers.
bool CanLowerReturn
CanLowerReturn - true iff the function's return value can be lowered to registers.
unsigned getNumSignBits() const
Computes the number of leading bits of this APInt that are equal to its sign bit. ...
APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
void setCurrentSwiftErrorVReg(const MachineBasicBlock *MBB, const Value *, unsigned)
Set the swifterror virtual register in the SwiftErrorVRegDefMap for this basic block.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
void set(const Function &Fn, MachineFunction &MF, SelectionDAG *DAG)
set - Initialize this FunctionLoweringInfo with the given Function and its associated MachineFunction...
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool isStackRealignable() const
isStackRealignable - This method returns whether the stack can be realigned.
AttributeList getAttributes() const
Return the attribute list for this Function.
MBBOrBasicBlock Handler
Holds the __except or __finally basic block.
std::pair< unsigned, bool > getOrCreateSwiftErrorVRegDefAt(const Instruction *)
Get or create the swifterror value virtual register for a def of a swifterror by an instruction...
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
static bool isUsedOutsideOfDefiningBlock(const Instruction *I)
isUsedOutsideOfDefiningBlock - Return true if this instruction is used by PHI nodes or outside of the...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const HexagonInstrInfo * TII
void calculateSEHStateNumbers(const Function *ParentFn, WinEHFuncInfo &FuncInfo)
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
ValTy * getCalledValue() const
Return the pointer to function that is being called.
Reg
All possible values of the reg field in the ModR/M byte.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
int getArgumentFrameIndex(const Argument *A)
getArgumentFrameIndex - Get frame index for the byval argument.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
void setHasMustTailInVarArgFunc(bool B)
const LiveOutInfo * GetLiveOutRegInfo(unsigned Reg)
GetLiveOutRegInfo - Gets LiveOutInfo for a register, returning NULL if the register is a PHI destinat...
This contains information for each constraint that we are lowering.
KnownBits zextOrTrunc(unsigned BitWidth)
Zero extends or truncates the underlying known Zero and One bits.
static ISD::NodeType getPreferredExtendForValue(const Value *V)
unsigned getBitWidth() const
Get the bit width of this value.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
void setHasOpaqueSPAdjustment(bool B)
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< uint64_t > *Offsets=nullptr, uint64_t StartingOffset=0)
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
unsigned getNumIncomingValues() const
Return the number of incoming edges.
TargetInstrInfo - Interface to description of machine instruction set.
void clear()
clear - Clear out all the function-specific state.
iterator find(const_arg_type_t< KeyT > Val)
Similar to CxxUnwindMapEntry, but supports SEH filters.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
Type * getReturnType() const
Returns the type of the ret val.
SmallVector< ClrEHUnwindMapEntry, 4 > ClrEHUnwindMap
unsigned const MachineRegisterInfo * MRI
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
bool isVectorTy() const
True if this is an instance of VectorType.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
std::pair< unsigned, bool > getOrCreateSwiftErrorVRegUseAt(const Instruction *, const MachineBasicBlock *, const Value *)
bool hasPersonalityFn() const
Check whether this function has a personality function.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
void setHasVAStart(bool B)
unsigned getBitWidth() const
Return the number of bits in the APInt.
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
void calculateClrEHStateNumbers(const Function *Fn, WinEHFuncInfo &FuncInfo)
DenseMap< const Instruction *, StatepointSpillMap > StatepointSpillMaps
Maps gc.statepoint instructions to their corresponding StatepointSpillMap instances.
SmallPtrSet< const BasicBlock *, 4 > VisitedBBs
VisitedBBs - The set of basic blocks visited thus far by instruction selection.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
LLVMContext & getContext() const
All values hold a context through their type.
void ComputePHILiveOutRegInfo(const PHINode *)
ComputePHILiveOutRegInfo - Compute LiveOutInfo for a PHI's destination register based on the LiveOutI...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
MachineBasicBlock * MBB
MBB - The current block.
SmallVector< unsigned, 50 > StatepointStackSlots
StatepointStackSlots - A list of temporary stack slots (frame indices) used to spill values at a stat...
void calculateWinCXXEHStateNumbers(const Function *ParentFn, WinEHFuncInfo &FuncInfo)
Analyze the IR in ParentFn and it's handlers to build WinEHFuncInfo, which describes the state number...
virtual const TargetFrameLowering * getFrameLowering() const
SmallVector< CxxUnwindMapEntry, 4 > CxxUnwindMap
Iterator for intrusive lists based on ilist_node.
This is the shared class of boolean and integer constants.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
DenseMap< std::pair< const MachineBasicBlock *, const Value * >, unsigned > SwiftErrorVRegDefMap
A map from swifterror value in a basic block to the virtual register it is currently represented by...
DenseMap< unsigned, unsigned > RegFixups
RegFixups - Registers which need to be replaced after isel is done.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
T get() const
Returns the value of the specified pointer type.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
SmallVector< MachineInstr *, 8 > ArgDbgValues
ArgDbgValues - A list of DBG_VALUE instructions created during isel for function arguments that are i...
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
virtual const TargetLowering * getTargetLowering() const
Information about stack frame layout on the target.
DenseMap< std::pair< const MachineBasicBlock *, const Value * >, unsigned > SwiftErrorVRegUpwardsUse
A list of upward exposed vreg uses that need to be satisfied by either a copy def or a phi node at th...
unsigned CreateRegs(Type *Ty)
CreateRegs - Allocate the appropriate number of virtual registers of the correctly promoted or expand...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
SmallVector< WinEHTryBlockMapEntry, 4 > TryBlockMap
Class for arbitrary precision integers.
bool isIntegerTy() const
True if this is an instance of IntegerType.
virtual const TargetRegisterClass * getRegClassFor(MVT VT) const
Return the register class that should be used for the specified value type.
iterator_range< user_iterator > users()
void setHasAddressTaken()
Set this block to reflect that it potentially is the target of an indirect branch.
union llvm::WinEHHandlerType::@158 CatchObj
The CatchObj starts out life as an LLVM alloca and is eventually turned frame index.
ANY_EXTEND - Used for integer types. The high bits are undefined.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
DenseMap< const Value *, ISD::NodeType > PreferredExtendType
Record the preferred extend type (ISD::SIGN_EXTEND or ISD::ZERO_EXTEND) for a value.
MachineRegisterInfo * RegInfo
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
DenseMap< const Argument *, int > ByValArgFrameIndexMap
ByValArgFrameIndexMap - Keep track of frame indices for byval arguments.
Establish a view to a call site for examination.
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
const WinEHFuncInfo * getWinEHFuncInfo() const
getWinEHFuncInfo - Return information about how the current function uses Windows exception handling...
unsigned CreateReg(MVT VT)
CreateReg - Allocate a single virtual register for the given type.
DenseMap< const AllocaInst *, int > StaticAllocaMap
StaticAllocaMap - Keep track of frame indices for fixed sized allocas in the entry block...
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, const AllocaInst *Alloca=nullptr)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void GetReturnInfo(Type *ReturnType, AttributeList attr, SmallVectorImpl< ISD::OutputArg > &Outs, const TargetLowering &TLI, const DataLayout &DL)
Given an LLVM IR type and return type attributes, compute the return value EVTs and flags...
bool isAsynchronousEHPersonality(EHPersonality Pers)
Returns true if this personality function catches asynchronous exceptions.
bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty...
MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
virtual const TargetInstrInfo * getInstrInfo() const
EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
LLVM Value Representation.
void push_back(MachineBasicBlock *MBB)
llvm::DenseMap< PointerIntPair< const Instruction *, 1, bool >, unsigned > SwiftErrorVRegDefUses
A map from instructions that define/use a swifterror value to the virtual register that represents th...
DenseMap< const BasicBlock *, MachineBasicBlock * > MBBMap
MBBMap - A mapping from LLVM basic blocks to their machine code entry.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
const TargetLowering * TLI
void setArgumentFrameIndex(const Argument *A, int FI)
setArgumentFrameIndex - Record frame index for the byval argument.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
int CreateVariableSizedObject(unsigned Alignment, const AllocaInst *Alloca)
Notify the MachineFrameInfo object that a variable sized object has been created. ...
void setObjectAlignment(int ObjectIdx, unsigned Align)
setObjectAlignment - Change the alignment of the specified stack object.
const BasicBlock * getParent() const
This file describes how to lower LLVM code to machine code.
an instruction to allocate memory on the stack
unsigned InitializeRegForValue(const Value *V)
unsigned getOrCreateSwiftErrorVReg(const MachineBasicBlock *, const Value *)
Get or create the swifterror value virtual register in SwiftErrorVRegDefMap for this basic block...