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)
117 CatchObjects.
insert({AI, {}}).first->second.push_back(
130 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(&
I)) {
131 Type *Ty = AI->getAllocatedType();
139 if (AI->isStaticAlloca() &&
141 const ConstantInt *CUI = cast<ConstantInt>(AI->getArraySize());
145 if (TySize == 0) TySize = 1;
147 auto Iter = CatchObjects.
find(AI);
148 if (Iter != CatchObjects.
end() && TLI->needsFixedCatchObjects()) {
150 TySize, 0,
false,
true);
159 if (Iter != CatchObjects.
end()) {
160 for (
int *CatchObjPtr : Iter->second)
167 if (Align <= StackAlign)
175 if (isa<CallInst>(
I) || isa<InvokeInst>(
I)) {
178 unsigned SP = TLI->getStackPointerRegisterToSaveRestore();
180 std::vector<TargetLowering::AsmOperandInfo> Ops =
181 TLI->ParseConstraints(Fn->getParent()->getDataLayout(), TRI, CS);
185 TLI->ComputeConstraintToUse(
Op,
SDValue(), DAG);
186 std::pair<unsigned, const TargetRegisterClass *> PhysReg =
187 TLI->getRegForInlineAsmConstraint(TRI,
Op.ConstraintCode,
189 if (PhysReg.first == SP)
199 if (
const auto *II = dyn_cast<IntrinsicInst>(&
I)) {
200 if (II->getIntrinsicID() == Intrinsic::vastart)
206 if (
const auto *CI = dyn_cast<CallInst>(&
I)) {
207 if (CI->isMustTailCall() && Fn->isVarArg())
221 assert(DI->getVariable() &&
"Missing variable");
222 assert(DI->getDebugLoc() &&
"Missing location");
229 if (
const BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
230 Address = BCI->getOperand(0);
231 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(Address)) {
237 FI, DI->getDebugLoc());
261 if (!isa<LandingPadInst>(PadInst)) {
265 if (isa<CatchSwitchInst>(PadInst)) {
266 assert(&*BB.begin() == PadInst &&
267 "WinEHPrepare failed to remove PHIs from imaginary BBs");
270 if (isa<FuncletPadInst>(PadInst))
271 assert(&*BB.begin() == PadInst &&
"WinEHPrepare failed to demote PHIs");
281 if (BB.hasAddressTaken())
300 assert(PHIReg &&
"PHI node does not have an assigned virtual register!");
304 for (
EVT VT : ValueVTs) {
305 unsigned NumRegisters = TLI->getNumRegisters(Fn->getContext(), VT);
307 for (
unsigned i = 0;
i != NumRegisters; ++
i)
308 BuildMI(MBB, DL, TII->
get(TargetOpcode::PHI), PHIReg +
i);
309 PHIReg += NumRegisters;
346 LiveOutRegInfo.clear();
375 unsigned FirstReg = 0;
381 for (
unsigned i = 0;
i != NumRegs; ++
i) {
383 if (!FirstReg) FirstReg = R;
396 if (!LiveOutRegInfo.inBounds(Reg))
422 "PHIs with non-vector integer types should have a single VT.");
423 EVT IntVT = ValueVTs[0];
433 LiveOutRegInfo.grow(DestReg);
437 if (isa<UndefValue>(V) || isa<ConstantExpr>(V)) {
452 "CopyToReg node was created.");
468 "Masks should have the same bit width as the type.");
472 if (isa<UndefValue>(V) || isa<ConstantExpr>(V)) {
489 "its CopyToReg node was created.");
522 DEBUG(
dbgs() <<
"Argument does not have assigned frame index!\n");
530 unsigned &VReg =
I.first->second;
533 assert(VReg &&
"null vreg in exception pointer table!");
540 auto Key = std::make_pair(MBB, Val);
553 }
else return It->second;
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
llvm::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...
SmallVector< WinEHHandlerType, 1 > HandlerArray
void setVariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, unsigned Slot, const DILocation *Loc)
Collect information used to emit debugging information of a variable.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
LLVM Argument representation.
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...
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
Type * getReturnType() const
Returns the type of the ret val.
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.
MBBOrBasicBlock Handler
Holds the __except or __finally basic block.
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)
ValTy * getCalledValue() const
getCalledValue - 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.
bool hasDebugInfo() const
Returns true if valid debug info is present.
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...
void GetReturnInfo(Type *ReturnType, AttributeSet 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...
This contains information for each constraint that we are lowering.
This class represents a no-op cast from one type to another.
static ISD::NodeType getPreferredExtendForValue(const Value *V)
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...
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 etc Experimental Use value profile to guide fuzzing Number of simultaneous worker processes to run the jobs If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
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.
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.
SmallVector< ClrEHUnwindMapEntry, 4 > ClrEHUnwindMap
llvm::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...
unsigned const MachineRegisterInfo * MRI
MVT - Machine Value Type.
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.
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.
EVT - Extended Value Type.
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< 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.
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.
AttributeSet getAttributes() const
Return the attribute list for this Function.
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.
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.
ImmutableCallSite - establish a view to a call site for examination.
unsigned getSizeInBits() const
getSizeInBits - Return the size of the specified value type in bits.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
iterator find(const KeyT &Val)
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...
union llvm::WinEHHandlerType::@61 CatchObj
The CatchObj starts out life as an LLVM alloca and is eventually turned frame index.
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())
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)
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.
MachineModuleInfo & getMMI() const
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. ...
This represents the llvm.dbg.declare instruction.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
void setObjectAlignment(int ObjectIdx, unsigned Align)
setObjectAlignment - Change the alignment of the specified stack object.
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
const BasicBlock * getParent() const
This class contains meta information specific to a module.
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...