LLVM  4.0.0
FunctionLoweringInfo.cpp
Go to the documentation of this file.
1 //===-- FunctionLoweringInfo.cpp ------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This implements routines for translating functions from LLVM IR into
11 // Machine IR.
12 //
13 //===----------------------------------------------------------------------===//
14 
16 #include "llvm/CodeGen/Analysis.h"
23 #include "llvm/IR/DataLayout.h"
24 #include "llvm/IR/DebugInfo.h"
25 #include "llvm/IR/DerivedTypes.h"
26 #include "llvm/IR/Function.h"
27 #include "llvm/IR/Instructions.h"
28 #include "llvm/IR/IntrinsicInst.h"
29 #include "llvm/IR/LLVMContext.h"
30 #include "llvm/IR/Module.h"
31 #include "llvm/Support/Debug.h"
41 #include <algorithm>
42 using namespace llvm;
43 
44 #define DEBUG_TYPE "function-lowering-info"
45 
46 /// isUsedOutsideOfDefiningBlock - Return true if this instruction is used by
47 /// PHI nodes or outside of the basic block that defines it, or used by a
48 /// switch or atomic instruction, which may expand to multiple basic blocks.
50  if (I->use_empty()) return false;
51  if (isa<PHINode>(I)) return true;
52  const BasicBlock *BB = I->getParent();
53  for (const User *U : I->users())
54  if (cast<Instruction>(U)->getParent() != BB || isa<PHINode>(U))
55  return true;
56 
57  return false;
58 }
59 
61  // For the users of the source value being used for compare instruction, if
62  // the number of signed predicate is greater than unsigned predicate, we
63  // prefer to use SIGN_EXTEND.
64  //
65  // With this optimization, we would be able to reduce some redundant sign or
66  // zero extension instruction, and eventually more machine CSE opportunities
67  // can be exposed.
68  ISD::NodeType ExtendKind = ISD::ANY_EXTEND;
69  unsigned NumOfSigned = 0, NumOfUnsigned = 0;
70  for (const User *U : V->users()) {
71  if (const auto *CI = dyn_cast<CmpInst>(U)) {
72  NumOfSigned += CI->isSigned();
73  NumOfUnsigned += CI->isUnsigned();
74  }
75  }
76  if (NumOfSigned > NumOfUnsigned)
77  ExtendKind = ISD::SIGN_EXTEND;
78 
79  return ExtendKind;
80 }
81 
83  SelectionDAG *DAG) {
84  Fn = &fn;
85  MF = &mf;
87  RegInfo = &MF->getRegInfo();
88  MachineModuleInfo &MMI = MF->getMMI();
90  unsigned StackAlign = TFI->getStackAlignment();
91 
92  // Check whether the function can return without sret-demotion.
95  mf.getDataLayout());
96  CanLowerReturn = TLI->CanLowerReturn(Fn->getCallingConv(), *MF,
97  Fn->isVarArg(), Outs, Fn->getContext());
98 
99  // If this personality uses funclets, we need to do a bit more work.
101  EHPersonality Personality = classifyEHPersonality(
102  Fn->hasPersonalityFn() ? Fn->getPersonalityFn() : nullptr);
103  if (isFuncletEHPersonality(Personality)) {
104  // Calculate state numbers if we haven't already.
105  WinEHFuncInfo &EHInfo = *MF->getWinEHFuncInfo();
106  if (Personality == EHPersonality::MSVC_CXX)
107  calculateWinCXXEHStateNumbers(&fn, EHInfo);
108  else if (isAsynchronousEHPersonality(Personality))
109  calculateSEHStateNumbers(&fn, EHInfo);
110  else if (Personality == EHPersonality::CoreCLR)
111  calculateClrEHStateNumbers(&fn, EHInfo);
112 
113  // Map all BB references in the WinEH data to MBBs.
114  for (WinEHTryBlockMapEntry &TBME : EHInfo.TryBlockMap) {
115  for (WinEHHandlerType &H : TBME.HandlerArray) {
116  if (const AllocaInst *AI = H.CatchObj.Alloca)
117  CatchObjects.insert({AI, {}}).first->second.push_back(
118  &H.CatchObj.FrameIndex);
119  else
120  H.CatchObj.FrameIndex = INT_MAX;
121  }
122  }
123  }
124 
125  // Initialize the mapping of values to registers. This is only set up for
126  // instruction values that are used outside of the block that defines
127  // them.
128  for (const BasicBlock &BB : *Fn) {
129  for (const Instruction &I : BB) {
130  if (const AllocaInst *AI = dyn_cast<AllocaInst>(&I)) {
131  Type *Ty = AI->getAllocatedType();
132  unsigned Align =
133  std::max((unsigned)MF->getDataLayout().getPrefTypeAlignment(Ty),
134  AI->getAlignment());
135 
136  // Static allocas can be folded into the initial stack frame
137  // adjustment. For targets that don't realign the stack, don't
138  // do this if there is an extra alignment requirement.
139  if (AI->isStaticAlloca() &&
140  (TFI->isStackRealignable() || (Align <= StackAlign))) {
141  const ConstantInt *CUI = cast<ConstantInt>(AI->getArraySize());
142  uint64_t TySize = MF->getDataLayout().getTypeAllocSize(Ty);
143 
144  TySize *= CUI->getZExtValue(); // Get total allocated size.
145  if (TySize == 0) TySize = 1; // Don't create zero-sized stack objects.
146  int FrameIndex = INT_MAX;
147  auto Iter = CatchObjects.find(AI);
148  if (Iter != CatchObjects.end() && TLI->needsFixedCatchObjects()) {
149  FrameIndex = MF->getFrameInfo().CreateFixedObject(
150  TySize, 0, /*Immutable=*/false, /*isAliased=*/true);
151  MF->getFrameInfo().setObjectAlignment(FrameIndex, Align);
152  } else {
153  FrameIndex =
154  MF->getFrameInfo().CreateStackObject(TySize, Align, false, AI);
155  }
156 
158  // Update the catch handler information.
159  if (Iter != CatchObjects.end()) {
160  for (int *CatchObjPtr : Iter->second)
161  *CatchObjPtr = FrameIndex;
162  }
163  } else {
164  // FIXME: Overaligned static allocas should be grouped into
165  // a single dynamic allocation instead of using a separate
166  // stack allocation for each one.
167  if (Align <= StackAlign)
168  Align = 0;
169  // Inform the Frame Information that we have variable-sized objects.
170  MF->getFrameInfo().CreateVariableSizedObject(Align ? Align : 1, AI);
171  }
172  }
173 
174  // Look for inline asm that clobbers the SP register.
175  if (isa<CallInst>(I) || isa<InvokeInst>(I)) {
176  ImmutableCallSite CS(&I);
177  if (isa<InlineAsm>(CS.getCalledValue())) {
178  unsigned SP = TLI->getStackPointerRegisterToSaveRestore();
180  std::vector<TargetLowering::AsmOperandInfo> Ops =
181  TLI->ParseConstraints(Fn->getParent()->getDataLayout(), TRI, CS);
182  for (TargetLowering::AsmOperandInfo &Op : Ops) {
183  if (Op.Type == InlineAsm::isClobber) {
184  // Clobbers don't have SDValue operands, hence SDValue().
185  TLI->ComputeConstraintToUse(Op, SDValue(), DAG);
186  std::pair<unsigned, const TargetRegisterClass *> PhysReg =
187  TLI->getRegForInlineAsmConstraint(TRI, Op.ConstraintCode,
188  Op.ConstraintVT);
189  if (PhysReg.first == SP)
191  }
192  }
193  }
194  }
195 
196  // Look for calls to the @llvm.va_start intrinsic. We can omit some
197  // prologue boilerplate for variadic functions that don't examine their
198  // arguments.
199  if (const auto *II = dyn_cast<IntrinsicInst>(&I)) {
200  if (II->getIntrinsicID() == Intrinsic::vastart)
201  MF->getFrameInfo().setHasVAStart(true);
202  }
203 
204  // If we have a musttail call in a variadic function, we need to ensure we
205  // forward implicit register parameters.
206  if (const auto *CI = dyn_cast<CallInst>(&I)) {
207  if (CI->isMustTailCall() && Fn->isVarArg())
209  }
210 
211  // Mark values used outside their block as exported, by allocating
212  // a virtual register for them.
214  if (!isa<AllocaInst>(I) || !StaticAllocaMap.count(cast<AllocaInst>(&I)))
216 
217  // Collect llvm.dbg.declare information. This is done now instead of
218  // during the initial isel pass through the IR so that it is done
219  // in a predictable order.
220  if (const DbgDeclareInst *DI = dyn_cast<DbgDeclareInst>(&I)) {
221  assert(DI->getVariable() && "Missing variable");
222  assert(DI->getDebugLoc() && "Missing location");
223  if (MMI.hasDebugInfo()) {
224  // Don't handle byval struct arguments or VLAs, for example.
225  // Non-byval arguments are handled here (they refer to the stack
226  // temporary alloca at this point).
227  const Value *Address = DI->getAddress();
228  if (Address) {
229  if (const BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
230  Address = BCI->getOperand(0);
231  if (const AllocaInst *AI = dyn_cast<AllocaInst>(Address)) {
233  StaticAllocaMap.find(AI);
234  if (SI != StaticAllocaMap.end()) { // Check for VLAs.
235  int FI = SI->second;
236  MF->setVariableDbgInfo(DI->getVariable(), DI->getExpression(),
237  FI, DI->getDebugLoc());
238  }
239  }
240  }
241  }
242  }
243 
244  // Decide the preferred extend type for a value.
246  }
247  }
248 
249  // Create an initial MachineBasicBlock for each LLVM BasicBlock in F. This
250  // also creates the initial PHI MachineInstrs, though none of the input
251  // operands are populated.
252  for (const BasicBlock &BB : *Fn) {
253  // Don't create MachineBasicBlocks for imaginary EH pad blocks. These blocks
254  // are really data, and no instructions can live here.
255  if (BB.isEHPad()) {
256  const Instruction *PadInst = BB.getFirstNonPHI();
257  // If this is a non-landingpad EH pad, mark this function as using
258  // funclets.
259  // FIXME: SEH catchpads do not create funclets, so we could avoid setting
260  // this in such cases in order to improve frame layout.
261  if (!isa<LandingPadInst>(PadInst)) {
262  MF->setHasEHFunclets(true);
264  }
265  if (isa<CatchSwitchInst>(PadInst)) {
266  assert(&*BB.begin() == PadInst &&
267  "WinEHPrepare failed to remove PHIs from imaginary BBs");
268  continue;
269  }
270  if (isa<FuncletPadInst>(PadInst))
271  assert(&*BB.begin() == PadInst && "WinEHPrepare failed to demote PHIs");
272  }
273 
275  MBBMap[&BB] = MBB;
276  MF->push_back(MBB);
277 
278  // Transfer the address-taken flag. This is necessary because there could
279  // be multiple MachineBasicBlocks corresponding to one BasicBlock, and only
280  // the first one should be marked.
281  if (BB.hasAddressTaken())
282  MBB->setHasAddressTaken();
283 
284  // Mark landing pad blocks.
285  if (BB.isEHPad())
286  MBB->setIsEHPad();
287 
288  // Create Machine PHI nodes for LLVM PHI nodes, lowering them as
289  // appropriate.
290  for (BasicBlock::const_iterator I = BB.begin();
291  const PHINode *PN = dyn_cast<PHINode>(I); ++I) {
292  if (PN->use_empty()) continue;
293 
294  // Skip empty types
295  if (PN->getType()->isEmptyTy())
296  continue;
297 
298  DebugLoc DL = PN->getDebugLoc();
299  unsigned PHIReg = ValueMap[PN];
300  assert(PHIReg && "PHI node does not have an assigned virtual register!");
301 
302  SmallVector<EVT, 4> ValueVTs;
303  ComputeValueVTs(*TLI, MF->getDataLayout(), PN->getType(), ValueVTs);
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;
310  }
311  }
312  }
313 
314  if (!isFuncletEHPersonality(Personality))
315  return;
316 
317  WinEHFuncInfo &EHInfo = *MF->getWinEHFuncInfo();
318 
319  // Map all BB references in the WinEH data to MBBs.
320  for (WinEHTryBlockMapEntry &TBME : EHInfo.TryBlockMap) {
321  for (WinEHHandlerType &H : TBME.HandlerArray) {
322  if (H.Handler)
323  H.Handler = MBBMap[H.Handler.get<const BasicBlock *>()];
324  }
325  }
326  for (CxxUnwindMapEntry &UME : EHInfo.CxxUnwindMap)
327  if (UME.Cleanup)
328  UME.Cleanup = MBBMap[UME.Cleanup.get<const BasicBlock *>()];
329  for (SEHUnwindMapEntry &UME : EHInfo.SEHUnwindMap) {
330  const BasicBlock *BB = UME.Handler.get<const BasicBlock *>();
331  UME.Handler = MBBMap[BB];
332  }
333  for (ClrEHUnwindMapEntry &CME : EHInfo.ClrEHUnwindMap) {
334  const BasicBlock *BB = CME.Handler.get<const BasicBlock *>();
335  CME.Handler = MBBMap[BB];
336  }
337 }
338 
339 /// clear - Clear out all the function-specific state. This returns this
340 /// FunctionLoweringInfo to an empty state, ready to be used for a
341 /// different function.
343  MBBMap.clear();
344  ValueMap.clear();
345  StaticAllocaMap.clear();
346  LiveOutRegInfo.clear();
347  VisitedBBs.clear();
348  ArgDbgValues.clear();
349  ByValArgFrameIndexMap.clear();
350  RegFixups.clear();
352  StatepointSpillMaps.clear();
353  PreferredExtendType.clear();
354 }
355 
356 /// CreateReg - Allocate a single virtual register for the given type.
360 }
361 
362 /// CreateRegs - Allocate the appropriate number of virtual registers of
363 /// the correctly promoted or expanded types. Assign these registers
364 /// consecutive vreg numbers and return the first assigned number.
365 ///
366 /// In the case that the given value has struct or array type, this function
367 /// will assign registers for each member or element.
368 ///
371 
372  SmallVector<EVT, 4> ValueVTs;
373  ComputeValueVTs(*TLI, MF->getDataLayout(), Ty, ValueVTs);
374 
375  unsigned FirstReg = 0;
376  for (unsigned Value = 0, e = ValueVTs.size(); Value != e; ++Value) {
377  EVT ValueVT = ValueVTs[Value];
378  MVT RegisterVT = TLI->getRegisterType(Ty->getContext(), ValueVT);
379 
380  unsigned NumRegs = TLI->getNumRegisters(Ty->getContext(), ValueVT);
381  for (unsigned i = 0; i != NumRegs; ++i) {
382  unsigned R = CreateReg(RegisterVT);
383  if (!FirstReg) FirstReg = R;
384  }
385  }
386  return FirstReg;
387 }
388 
389 /// GetLiveOutRegInfo - Gets LiveOutInfo for a register, returning NULL if the
390 /// register is a PHI destination and the PHI's LiveOutInfo is not valid. If
391 /// the register's LiveOutInfo is for a smaller bit width, it is extended to
392 /// the larger bit width by zero extension. The bit width must be no smaller
393 /// than the LiveOutInfo's existing bit width.
395 FunctionLoweringInfo::GetLiveOutRegInfo(unsigned Reg, unsigned BitWidth) {
396  if (!LiveOutRegInfo.inBounds(Reg))
397  return nullptr;
398 
399  LiveOutInfo *LOI = &LiveOutRegInfo[Reg];
400  if (!LOI->IsValid)
401  return nullptr;
402 
403  if (BitWidth > LOI->KnownZero.getBitWidth()) {
404  LOI->NumSignBits = 1;
405  LOI->KnownZero = LOI->KnownZero.zextOrTrunc(BitWidth);
406  LOI->KnownOne = LOI->KnownOne.zextOrTrunc(BitWidth);
407  }
408 
409  return LOI;
410 }
411 
412 /// ComputePHILiveOutRegInfo - Compute LiveOutInfo for a PHI's destination
413 /// register based on the LiveOutInfo of its operands.
415  Type *Ty = PN->getType();
416  if (!Ty->isIntegerTy() || Ty->isVectorTy())
417  return;
418 
419  SmallVector<EVT, 1> ValueVTs;
420  ComputeValueVTs(*TLI, MF->getDataLayout(), Ty, ValueVTs);
421  assert(ValueVTs.size() == 1 &&
422  "PHIs with non-vector integer types should have a single VT.");
423  EVT IntVT = ValueVTs[0];
424 
425  if (TLI->getNumRegisters(PN->getContext(), IntVT) != 1)
426  return;
427  IntVT = TLI->getTypeToTransformTo(PN->getContext(), IntVT);
428  unsigned BitWidth = IntVT.getSizeInBits();
429 
430  unsigned DestReg = ValueMap[PN];
432  return;
433  LiveOutRegInfo.grow(DestReg);
434  LiveOutInfo &DestLOI = LiveOutRegInfo[DestReg];
435 
436  Value *V = PN->getIncomingValue(0);
437  if (isa<UndefValue>(V) || isa<ConstantExpr>(V)) {
438  DestLOI.NumSignBits = 1;
439  APInt Zero(BitWidth, 0);
440  DestLOI.KnownZero = Zero;
441  DestLOI.KnownOne = Zero;
442  return;
443  }
444 
445  if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
446  APInt Val = CI->getValue().zextOrTrunc(BitWidth);
447  DestLOI.NumSignBits = Val.getNumSignBits();
448  DestLOI.KnownZero = ~Val;
449  DestLOI.KnownOne = Val;
450  } else {
451  assert(ValueMap.count(V) && "V should have been placed in ValueMap when its"
452  "CopyToReg node was created.");
453  unsigned SrcReg = ValueMap[V];
455  DestLOI.IsValid = false;
456  return;
457  }
458  const LiveOutInfo *SrcLOI = GetLiveOutRegInfo(SrcReg, BitWidth);
459  if (!SrcLOI) {
460  DestLOI.IsValid = false;
461  return;
462  }
463  DestLOI = *SrcLOI;
464  }
465 
466  assert(DestLOI.KnownZero.getBitWidth() == BitWidth &&
467  DestLOI.KnownOne.getBitWidth() == BitWidth &&
468  "Masks should have the same bit width as the type.");
469 
470  for (unsigned i = 1, e = PN->getNumIncomingValues(); i != e; ++i) {
471  Value *V = PN->getIncomingValue(i);
472  if (isa<UndefValue>(V) || isa<ConstantExpr>(V)) {
473  DestLOI.NumSignBits = 1;
474  APInt Zero(BitWidth, 0);
475  DestLOI.KnownZero = Zero;
476  DestLOI.KnownOne = Zero;
477  return;
478  }
479 
480  if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
481  APInt Val = CI->getValue().zextOrTrunc(BitWidth);
482  DestLOI.NumSignBits = std::min(DestLOI.NumSignBits, Val.getNumSignBits());
483  DestLOI.KnownZero &= ~Val;
484  DestLOI.KnownOne &= Val;
485  continue;
486  }
487 
488  assert(ValueMap.count(V) && "V should have been placed in ValueMap when "
489  "its CopyToReg node was created.");
490  unsigned SrcReg = ValueMap[V];
492  DestLOI.IsValid = false;
493  return;
494  }
495  const LiveOutInfo *SrcLOI = GetLiveOutRegInfo(SrcReg, BitWidth);
496  if (!SrcLOI) {
497  DestLOI.IsValid = false;
498  return;
499  }
500  DestLOI.NumSignBits = std::min(DestLOI.NumSignBits, SrcLOI->NumSignBits);
501  DestLOI.KnownZero &= SrcLOI->KnownZero;
502  DestLOI.KnownOne &= SrcLOI->KnownOne;
503  }
504 }
505 
506 /// setArgumentFrameIndex - Record frame index for the byval
507 /// argument. This overrides previous frame index entry for this argument,
508 /// if any.
510  int FI) {
511  ByValArgFrameIndexMap[A] = FI;
512 }
513 
514 /// getArgumentFrameIndex - Get frame index for the byval argument.
515 /// If the argument does not have any assigned frame index then 0 is
516 /// returned.
519  ByValArgFrameIndexMap.find(A);
520  if (I != ByValArgFrameIndexMap.end())
521  return I->second;
522  DEBUG(dbgs() << "Argument does not have assigned frame index!\n");
523  return 0;
524 }
525 
527  const Value *CPI, const TargetRegisterClass *RC) {
529  auto I = CatchPadExceptionPointers.insert({CPI, 0});
530  unsigned &VReg = I.first->second;
531  if (I.second)
532  VReg = MRI.createVirtualRegister(RC);
533  assert(VReg && "null vreg in exception pointer table!");
534  return VReg;
535 }
536 
537 unsigned
539  const Value *Val) {
540  auto Key = std::make_pair(MBB, Val);
541  auto It = SwiftErrorVRegDefMap.find(Key);
542  // If this is the first use of this swifterror value in this basic block,
543  // create a new virtual register.
544  // After we processed all basic blocks we will satisfy this "upwards exposed
545  // use" by inserting a copy or phi at the beginning of this block.
546  if (It == SwiftErrorVRegDefMap.end()) {
547  auto &DL = MF->getDataLayout();
549  auto VReg = MF->getRegInfo().createVirtualRegister(RC);
550  SwiftErrorVRegDefMap[Key] = VReg;
551  SwiftErrorVRegUpwardsUse[Key] = VReg;
552  return VReg;
553  } else return It->second;
554 }
555 
557  const MachineBasicBlock *MBB, const Value *Val, unsigned VReg) {
558  SwiftErrorVRegDefMap[std::make_pair(MBB, Val)] = VReg;
559 }
void clear()
Definition: ValueMap.h:148
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
MBBOrBasicBlock Handler
Definition: WinEHFuncInfo.h:85
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
Definition: WinEHFuncInfo.h:79
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. ...
Definition: Function.cpp:226
LLVM Argument representation.
Definition: Argument.h:34
MBBOrBasicBlock Cleanup
Definition: WinEHFuncInfo.h:45
size_t i
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.
Definition: DataLayout.cpp:699
size_type count(const KeyT &Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition: ValueMap.h:154
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
const AllocaInst * Alloca
Definition: WinEHFuncInfo.h:68
Type * getReturnType() const
Returns the type of the ret val.
Definition: Function.cpp:238
A debug info location.
Definition: DebugLoc.h:34
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. ...
Definition: APInt.h:1363
APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
Definition: APInt.cpp:999
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.
Definition: ISDOpcodes.h:39
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...
Definition: Function.h:165
bool isStackRealignable() const
isStackRealignable - This method returns whether the stack can be realigned.
MBBOrBasicBlock Handler
Holds the __except or __finally basic block.
Definition: WinEHFuncInfo.h:60
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:172
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.
Definition: CallSite.h:102
Reg
All possible values of the reg field in the ModR/M byte.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
Definition: Function.cpp:1218
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...
Definition: Constants.h:154
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.
Definition: Type.h:128
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...
MachineBasicBlock * MBB
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.
Definition: WinEHFuncInfo.h:49
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.
Definition: BasicBlock.h:51
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
bool isVectorTy() const
True if this is an instance of VectorType.
Definition: Type.h:219
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
#define H(x, y, z)
Definition: MD5.cpp:53
bool hasPersonalityFn() const
Check whether this function has a personality function.
Definition: Function.h:581
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:259
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition: APInt.h:1255
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.
Definition: ValueTypes.h:31
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.
Definition: Value.cpp:654
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...
Definition: MCInstrInfo.h:45
MachineBasicBlock * MBB
MBB - The current block.
MBBOrBasicBlock Handler
Definition: WinEHFuncInfo.h:72
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
Definition: WinEHFuncInfo.h:98
Iterator for intrusive lists based on ilist_node.
See the file comment.
Definition: ValueMap.h:87
This is the shared class of boolean and integer constants.
Definition: Constants.h:88
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...
Definition: DataLayout.h:408
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...
Definition: SelectionDAG.h:166
T get() const
Returns the value of the specified pointer type.
Definition: PointerUnion.h:135
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:843
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.
Definition: Value.h:230
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.
Definition: Debug.cpp:132
AttributeSet getAttributes() const
Return the attribute list for this Function.
Definition: Function.h:176
SmallVector< WinEHTryBlockMapEntry, 4 > TryBlockMap
Definition: WinEHFuncInfo.h:99
Class for arbitrary precision integers.
Definition: APInt.h:77
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:195
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()
Definition: Value.h:370
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.
Definition: ISDOpcodes.h:403
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.
Definition: CallSite.h:665
unsigned getSizeInBits() const
getSizeInBits - Return the size of the specified value type in bits.
Definition: ValueTypes.h:256
#define I(x, y, z)
Definition: MD5.cpp:54
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
Definition: SmallVector.h:135
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:287
static volatile int Zero
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...
bool use_empty() const
Definition: Value.h:299
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...
Definition: Type.cpp:91
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.
Definition: Value.h:71
void push_back(MachineBasicBlock *MBB)
#define DEBUG(X)
Definition: Debug.h:100
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
Conversion operators.
Definition: ISDOpcodes.h:397
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.
Definition: IntrinsicInst.h:89
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.
Definition: Function.cpp:234
const BasicBlock * getParent() const
Definition: Instruction.h:62
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
Definition: Instructions.h:60
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...