LLVM  14.0.0git
Function.h
Go to the documentation of this file.
1 //===- llvm/Function.h - Class to represent a single function ---*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the declaration of the Function class, which represents a
10 // single function/procedure in LLVM.
11 //
12 // A function basically consists of a list of basic blocks, a list of arguments,
13 // and a symbol table.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef LLVM_IR_FUNCTION_H
18 #define LLVM_IR_FUNCTION_H
19 
20 #include "llvm/ADT/DenseSet.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/ADT/Twine.h"
23 #include "llvm/ADT/ilist_node.h"
25 #include "llvm/IR/Argument.h"
26 #include "llvm/IR/Attributes.h"
27 #include "llvm/IR/BasicBlock.h"
28 #include "llvm/IR/CallingConv.h"
29 #include "llvm/IR/DerivedTypes.h"
30 #include "llvm/IR/GlobalObject.h"
31 #include "llvm/IR/GlobalValue.h"
32 #include "llvm/IR/OperandTraits.h"
34 #include "llvm/IR/Value.h"
35 #include "llvm/Support/Casting.h"
36 #include "llvm/Support/Compiler.h"
37 #include <cassert>
38 #include <cstddef>
39 #include <cstdint>
40 #include <memory>
41 #include <string>
42 
43 namespace llvm {
44 
45 namespace Intrinsic {
46 typedef unsigned ID;
47 }
48 
49 class AssemblyAnnotationWriter;
50 class Constant;
51 class DISubprogram;
52 class LLVMContext;
53 class Module;
54 template <typename T> class Optional;
55 class raw_ostream;
56 class Type;
57 class User;
58 class BranchProbabilityInfo;
59 class BlockFrequencyInfo;
60 
61 class Function : public GlobalObject, public ilist_node<Function> {
62 public:
64 
65  // BasicBlock iterators...
68 
70  using const_arg_iterator = const Argument *;
71 
72 private:
73  // Important things that make up a function!
74  BasicBlockListType BasicBlocks; ///< The basic blocks
75  mutable Argument *Arguments = nullptr; ///< The formal arguments
76  size_t NumArgs;
77  std::unique_ptr<ValueSymbolTable>
78  SymTab; ///< Symbol table of args/instructions
79  AttributeList AttributeSets; ///< Parameter attributes
80 
81  /*
82  * Value::SubclassData
83  *
84  * bit 0 : HasLazyArguments
85  * bit 1 : HasPrefixData
86  * bit 2 : HasPrologueData
87  * bit 3 : HasPersonalityFn
88  * bits 4-13 : CallingConvention
89  * bits 14 : HasGC
90  * bits 15 : [reserved]
91  */
92 
93  /// Bits from GlobalObject::GlobalObjectSubclassData.
94  enum {
95  /// Whether this function is materializable.
96  IsMaterializableBit = 0,
97  };
98 
100 
101  /// hasLazyArguments/CheckLazyArguments - The argument list of a function is
102  /// built on demand, so that the list isn't allocated until the first client
103  /// needs it. The hasLazyArguments predicate returns true if the arg list
104  /// hasn't been set up yet.
105 public:
106  bool hasLazyArguments() const {
107  return getSubclassDataFromValue() & (1<<0);
108  }
109 
110 private:
111  void CheckLazyArguments() const {
112  if (hasLazyArguments())
113  BuildLazyArguments();
114  }
115 
116  void BuildLazyArguments() const;
117 
118  void clearArguments();
119 
120  /// Function ctor - If the (optional) Module argument is specified, the
121  /// function is automatically inserted into the end of the function list for
122  /// the module.
123  ///
124  Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace,
125  const Twine &N = "", Module *M = nullptr);
126 
127 public:
128  Function(const Function&) = delete;
129  void operator=(const Function&) = delete;
130  ~Function();
131 
132  // This is here to help easily convert from FunctionT * (Function * or
133  // MachineFunction *) in BlockFrequencyInfoImpl to Function * by calling
134  // FunctionT->getFunction().
135  const Function &getFunction() const { return *this; }
136 
138  unsigned AddrSpace, const Twine &N = "",
139  Module *M = nullptr) {
140  return new Function(Ty, Linkage, AddrSpace, N, M);
141  }
142 
143  // TODO: remove this once all users have been updated to pass an AddrSpace
145  const Twine &N = "", Module *M = nullptr) {
146  return new Function(Ty, Linkage, static_cast<unsigned>(-1), N, M);
147  }
148 
149  /// Creates a new function and attaches it to a module.
150  ///
151  /// Places the function in the program address space as specified
152  /// by the module's data layout.
154  const Twine &N, Module &M);
155 
156  /// Creates a function with some attributes recorded in llvm.module.flags
157  /// applied.
158  ///
159  /// Use this when synthesizing new functions that need attributes that would
160  /// have been set by command line options.
162  unsigned AddrSpace,
163  const Twine &N = "",
164  Module *M = nullptr);
165 
166  // Provide fast operand accessors.
168 
169  /// Returns the number of non-debug IR instructions in this function.
170  /// This is equivalent to the sum of the sizes of each basic block contained
171  /// within this function.
172  unsigned getInstructionCount() const;
173 
174  /// Returns the FunctionType for me.
176  return cast<FunctionType>(getValueType());
177  }
178 
179  /// Returns the type of the ret val.
181 
182  /// getContext - Return a reference to the LLVMContext associated with this
183  /// function.
184  LLVMContext &getContext() const;
185 
186  /// isVarArg - Return true if this function takes a variable number of
187  /// arguments.
188  bool isVarArg() const { return getFunctionType()->isVarArg(); }
189 
190  bool isMaterializable() const {
191  return getGlobalObjectSubClassData() & (1 << IsMaterializableBit);
192  }
193  void setIsMaterializable(bool V) {
194  unsigned Mask = 1 << IsMaterializableBit;
196  (V ? Mask : 0u));
197  }
198 
199  /// getIntrinsicID - This method returns the ID number of the specified
200  /// function, or Intrinsic::not_intrinsic if the function is not an
201  /// intrinsic, or if the pointer is null. This value is always defined to be
202  /// zero to allow easy checking for whether a function is intrinsic or not.
203  /// The particular intrinsic functions which correspond to this value are
204  /// defined in llvm/Intrinsics.h.
206 
207  /// isIntrinsic - Returns true if the function's name starts with "llvm.".
208  /// It's possible for this function to return true while getIntrinsicID()
209  /// returns Intrinsic::not_intrinsic!
210  bool isIntrinsic() const { return HasLLVMReservedName; }
211 
212  /// isTargetIntrinsic - Returns true if IID is an intrinsic specific to a
213  /// certain target. If it is a generic intrinsic false is returned.
214  static bool isTargetIntrinsic(Intrinsic::ID IID);
215 
216  /// isTargetIntrinsic - Returns true if this function is an intrinsic and the
217  /// intrinsic is specific to a certain target. If this is not an intrinsic
218  /// or a generic intrinsic, false is returned.
219  bool isTargetIntrinsic() const;
220 
221  /// Returns true if the function is one of the "Constrained Floating-Point
222  /// Intrinsics". Returns false if not, and returns false when
223  /// getIntrinsicID() returns Intrinsic::not_intrinsic.
224  bool isConstrainedFPIntrinsic() const;
225 
227 
228  /// Recalculate the ID for this function if it is an Intrinsic defined
229  /// in llvm/Intrinsics.h. Sets the intrinsic ID to Intrinsic::not_intrinsic
230  /// if the name of this function does not match an intrinsic in that header.
231  /// Note, this method does not need to be called directly, as it is called
232  /// from Value::setName() whenever the name of this function changes.
233  void recalculateIntrinsicID();
234 
235  /// getCallingConv()/setCallingConv(CC) - These method get and set the
236  /// calling convention of this function. The enum values for the known
237  /// calling conventions are defined in CallingConv.h.
239  return static_cast<CallingConv::ID>((getSubclassDataFromValue() >> 4) &
241  }
243  auto ID = static_cast<unsigned>(CC);
244  assert(!(ID & ~CallingConv::MaxID) && "Unsupported calling convention");
245  setValueSubclassData((getSubclassDataFromValue() & 0xc00f) | (ID << 4));
246  }
247 
248  /// Return the attribute list for this Function.
249  AttributeList getAttributes() const { return AttributeSets; }
250 
251  /// Set the attribute list for this Function.
252  void setAttributes(AttributeList Attrs) { AttributeSets = Attrs; }
253 
254  /// Add function attributes to this function.
257  }
258 
259  /// Add function attributes to this function.
262  Attribute::get(getContext(), Kind, Val));
263  }
264 
265  /// Add function attributes to this function.
266  void addFnAttr(Attribute Attr) {
268  }
269 
270  /// Remove function attributes from this function.
273  }
274 
275  /// Remove function attribute from this function.
279  }
280 
281  /// A function will have the "coroutine.presplit" attribute if it's
282  /// a coroutine and has not gone through full CoroSplit pass.
283  bool isPresplitCoroutine() const {
284  return hasFnAttribute("coroutine.presplit");
285  }
286 
288 
289  /// Class to represent profile counts.
290  ///
291  /// This class represents both real and synthetic profile counts.
292  class ProfileCount {
293  private:
294  uint64_t Count;
295  ProfileCountType PCT;
296  static ProfileCount Invalid;
297 
298  public:
299  ProfileCount() : Count(-1), PCT(PCT_Invalid) {}
300  ProfileCount(uint64_t Count, ProfileCountType PCT)
301  : Count(Count), PCT(PCT) {}
302  bool hasValue() const { return PCT != PCT_Invalid; }
303  uint64_t getCount() const { return Count; }
304  ProfileCountType getType() const { return PCT; }
305  bool isSynthetic() const { return PCT == PCT_Synthetic; }
306  explicit operator bool() { return hasValue(); }
307  bool operator!() const { return !hasValue(); }
308  // Update the count retaining the same profile count type.
309  ProfileCount &setCount(uint64_t C) {
310  Count = C;
311  return *this;
312  }
314  };
315 
316  /// Set the entry count for this function.
317  ///
318  /// Entry count is the number of times this function was executed based on
319  /// pgo data. \p Imports points to a set of GUIDs that needs to
320  /// be imported by the function for sample PGO, to enable the same inlines as
321  /// the profiled optimized binary.
322  void setEntryCount(ProfileCount Count,
323  const DenseSet<GlobalValue::GUID> *Imports = nullptr);
324 
325  /// A convenience wrapper for setting entry count
326  void setEntryCount(uint64_t Count, ProfileCountType Type = PCT_Real,
327  const DenseSet<GlobalValue::GUID> *Imports = nullptr);
328 
329  /// Get the entry count for this function.
330  ///
331  /// Entry count is the number of times the function was executed.
332  /// When AllowSynthetic is false, only pgo_data will be returned.
333  ProfileCount getEntryCount(bool AllowSynthetic = false) const;
334 
335  /// Return true if the function is annotated with profile data.
336  ///
337  /// Presence of entry counts from a profile run implies the function has
338  /// profile annotations. If IncludeSynthetic is false, only return true
339  /// when the profile data is real.
340  bool hasProfileData(bool IncludeSynthetic = false) const {
341  return getEntryCount(IncludeSynthetic).hasValue();
342  }
343 
344  /// Returns the set of GUIDs that needs to be imported to the function for
345  /// sample PGO, to enable the same inlines as the profiled optimized binary.
347 
348  /// Set the section prefix for this function.
350 
351  /// Get the section prefix for this function.
353 
354  /// Return true if the function has the attribute.
356  return AttributeSets.hasFnAttribute(Kind);
357  }
358 
359  /// Return true if the function has the attribute.
361  return AttributeSets.hasFnAttribute(Kind);
362  }
363 
364  /// Return the attribute for the given attribute kind.
367  }
368 
369  /// Return the attribute for the given attribute kind.
372  }
373 
374  /// Return the stack alignment for the function.
375  unsigned getFnStackAlignment() const {
376  if (!hasFnAttribute(Attribute::StackAlignment))
377  return 0;
378  if (const auto MA =
380  return MA->value();
381  return 0;
382  }
383 
384  /// Return the stack alignment for the function.
386  if (!hasFnAttribute(Attribute::StackAlignment))
387  return None;
388  return AttributeSets.getStackAlignment(AttributeList::FunctionIndex);
389  }
390 
391  /// hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm
392  /// to use during code generation.
393  bool hasGC() const {
394  return getSubclassDataFromValue() & (1<<14);
395  }
396  const std::string &getGC() const;
397  void setGC(std::string Str);
398  void clearGC();
399 
400  /// Returns true if the function has ssp, sspstrong, or sspreq fn attrs.
401  bool hasStackProtectorFnAttr() const;
402 
403  /// adds the attribute to the list of attributes.
404  void addAttribute(unsigned i, Attribute::AttrKind Kind);
405 
406  /// adds the attribute to the list of attributes.
407  void addAttribute(unsigned i, Attribute Attr);
408 
409  /// adds the attributes to the list of attributes.
410  void addAttributes(unsigned i, const AttrBuilder &Attrs);
411 
412  /// adds the attribute to the list of attributes for the given arg.
413  void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind);
414 
415  /// adds the attribute to the list of attributes for the given arg.
416  void addParamAttr(unsigned ArgNo, Attribute Attr);
417 
418  /// adds the attributes to the list of attributes for the given arg.
419  void addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs);
420 
421  /// removes the attribute from the list of attributes.
422  void removeAttribute(unsigned i, Attribute::AttrKind Kind);
423 
424  /// removes the attribute from the list of attributes.
425  void removeAttribute(unsigned i, StringRef Kind);
426 
427  /// removes the attributes from the list of attributes.
428  void removeAttributes(unsigned i, const AttrBuilder &Attrs);
429 
430  /// removes the attribute from the list of attributes.
431  void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind);
432 
433  /// removes the attribute from the list of attributes.
434  void removeParamAttr(unsigned ArgNo, StringRef Kind);
435 
436  /// removes the attribute from the list of attributes.
437  void removeParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs);
438 
439  /// removes noundef and other attributes that imply undefined behavior if a
440  /// `undef` or `poison` value is passed from the list of attributes.
441  void removeParamUndefImplyingAttrs(unsigned ArgNo);
442 
443  /// check if an attributes is in the list of attributes.
444  bool hasAttribute(unsigned i, Attribute::AttrKind Kind) const {
445  return getAttributes().hasAttribute(i, Kind);
446  }
447 
448  /// check if an attributes is in the list of attributes.
449  bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const {
450  return getAttributes().hasParamAttribute(ArgNo, Kind);
451  }
452 
453  /// gets the specified attribute from the list of attributes.
455  return getAttributes().getParamAttr(ArgNo, Kind);
456  }
457 
458  /// gets the attribute from the list of attributes.
460  return AttributeSets.getAttribute(i, Kind);
461  }
462 
463  /// gets the attribute from the list of attributes.
464  Attribute getAttribute(unsigned i, StringRef Kind) const {
465  return AttributeSets.getAttribute(i, Kind);
466  }
467 
468  /// adds the dereferenceable attribute to the list of attributes.
469  void addDereferenceableAttr(unsigned i, uint64_t Bytes);
470 
471  /// adds the dereferenceable attribute to the list of attributes for
472  /// the given arg.
473  void addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes);
474 
475  /// adds the dereferenceable_or_null attribute to the list of
476  /// attributes.
477  void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes);
478 
479  /// adds the dereferenceable_or_null attribute to the list of
480  /// attributes for the given arg.
481  void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes);
482 
483  /// Extract the alignment for a call or parameter (0=unknown).
484  /// FIXME: Remove this function once transition to Align is over.
485  /// Use getParamAlign() instead.
486  unsigned getParamAlignment(unsigned ArgNo) const {
487  if (const auto MA = getParamAlign(ArgNo))
488  return MA->value();
489  return 0;
490  }
491 
492  MaybeAlign getParamAlign(unsigned ArgNo) const {
493  return AttributeSets.getParamAlignment(ArgNo);
494  }
495 
496  MaybeAlign getParamStackAlign(unsigned ArgNo) const {
497  return AttributeSets.getParamStackAlignment(ArgNo);
498  }
499 
500  /// Extract the byval type for a parameter.
501  Type *getParamByValType(unsigned ArgNo) const {
502  return AttributeSets.getParamByValType(ArgNo);
503  }
504 
505  /// Extract the sret type for a parameter.
506  Type *getParamStructRetType(unsigned ArgNo) const {
507  return AttributeSets.getParamStructRetType(ArgNo);
508  }
509 
510  /// Extract the inalloca type for a parameter.
511  Type *getParamInAllocaType(unsigned ArgNo) const {
512  return AttributeSets.getParamInAllocaType(ArgNo);
513  }
514 
515  /// Extract the byref type for a parameter.
516  Type *getParamByRefType(unsigned ArgNo) const {
517  return AttributeSets.getParamByRefType(ArgNo);
518  }
519 
520  /// Extract the number of dereferenceable bytes for a call or
521  /// parameter (0=unknown).
522  /// @param i AttributeList index, referring to a return value or argument.
523  uint64_t getDereferenceableBytes(unsigned i) const {
524  return AttributeSets.getDereferenceableBytes(i);
525  }
526 
527  /// Extract the number of dereferenceable bytes for a parameter.
528  /// @param ArgNo Index of an argument, with 0 being the first function arg.
529  uint64_t getParamDereferenceableBytes(unsigned ArgNo) const {
530  return AttributeSets.getParamDereferenceableBytes(ArgNo);
531  }
532 
533  /// Extract the number of dereferenceable_or_null bytes for a call or
534  /// parameter (0=unknown).
535  /// @param i AttributeList index, referring to a return value or argument.
536  uint64_t getDereferenceableOrNullBytes(unsigned i) const {
537  return AttributeSets.getDereferenceableOrNullBytes(i);
538  }
539 
540  /// Extract the number of dereferenceable_or_null bytes for a
541  /// parameter.
542  /// @param ArgNo AttributeList ArgNo, referring to an argument.
543  uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const {
544  return AttributeSets.getParamDereferenceableOrNullBytes(ArgNo);
545  }
546 
547  /// Determine if the function does not access memory.
548  bool doesNotAccessMemory() const {
549  return hasFnAttribute(Attribute::ReadNone);
550  }
552  addFnAttr(Attribute::ReadNone);
553  }
554 
555  /// Determine if the function does not access or only reads memory.
556  bool onlyReadsMemory() const {
558  }
561  }
562 
563  /// Determine if the function does not access or only writes memory.
564  bool doesNotReadMemory() const {
565  return doesNotAccessMemory() || hasFnAttribute(Attribute::WriteOnly);
566  }
568  addFnAttr(Attribute::WriteOnly);
569  }
570 
571  /// Determine if the call can access memmory only using pointers based
572  /// on its arguments.
573  bool onlyAccessesArgMemory() const {
574  return hasFnAttribute(Attribute::ArgMemOnly);
575  }
576  void setOnlyAccessesArgMemory() { addFnAttr(Attribute::ArgMemOnly); }
577 
578  /// Determine if the function may only access memory that is
579  /// inaccessible from the IR.
581  return hasFnAttribute(Attribute::InaccessibleMemOnly);
582  }
584  addFnAttr(Attribute::InaccessibleMemOnly);
585  }
586 
587  /// Determine if the function may only access memory that is
588  /// either inaccessible from the IR or pointed to by its arguments.
590  return hasFnAttribute(Attribute::InaccessibleMemOrArgMemOnly);
591  }
593  addFnAttr(Attribute::InaccessibleMemOrArgMemOnly);
594  }
595 
596  /// Determine if the function cannot return.
597  bool doesNotReturn() const {
598  return hasFnAttribute(Attribute::NoReturn);
599  }
601  addFnAttr(Attribute::NoReturn);
602  }
603 
604  /// Determine if the function should not perform indirect branch tracking.
605  bool doesNoCfCheck() const { return hasFnAttribute(Attribute::NoCfCheck); }
606 
607  /// Determine if the function cannot unwind.
608  bool doesNotThrow() const {
609  return hasFnAttribute(Attribute::NoUnwind);
610  }
612  addFnAttr(Attribute::NoUnwind);
613  }
614 
615  /// Determine if the call cannot be duplicated.
616  bool cannotDuplicate() const {
617  return hasFnAttribute(Attribute::NoDuplicate);
618  }
620  addFnAttr(Attribute::NoDuplicate);
621  }
622 
623  /// Determine if the call is convergent.
624  bool isConvergent() const {
626  }
627  void setConvergent() {
629  }
632  }
633 
634  /// Determine if the call has sideeffects.
635  bool isSpeculatable() const {
636  return hasFnAttribute(Attribute::Speculatable);
637  }
639  addFnAttr(Attribute::Speculatable);
640  }
641 
642  /// Determine if the call might deallocate memory.
643  bool doesNotFreeMemory() const {
644  return onlyReadsMemory() || hasFnAttribute(Attribute::NoFree);
645  }
647  addFnAttr(Attribute::NoFree);
648  }
649 
650  /// Determine if the call can synchroize with other threads
651  bool hasNoSync() const {
652  return hasFnAttribute(Attribute::NoSync);
653  }
654  void setNoSync() {
655  addFnAttr(Attribute::NoSync);
656  }
657 
658  /// Determine if the function is known not to recurse, directly or
659  /// indirectly.
660  bool doesNotRecurse() const {
661  return hasFnAttribute(Attribute::NoRecurse);
662  }
664  addFnAttr(Attribute::NoRecurse);
665  }
666 
667  /// Determine if the function is required to make forward progress.
668  bool mustProgress() const {
669  return hasFnAttribute(Attribute::MustProgress) ||
670  hasFnAttribute(Attribute::WillReturn);
671  }
672  void setMustProgress() { addFnAttr(Attribute::MustProgress); }
673 
674  /// Determine if the function will return.
675  bool willReturn() const { return hasFnAttribute(Attribute::WillReturn); }
676  void setWillReturn() { addFnAttr(Attribute::WillReturn); }
677 
678  /// True if the ABI mandates (or the user requested) that this
679  /// function be in a unwind table.
680  bool hasUWTable() const {
681  return hasFnAttribute(Attribute::UWTable);
682  }
683  void setHasUWTable() {
684  addFnAttr(Attribute::UWTable);
685  }
686 
687  /// True if this function needs an unwind table.
688  bool needsUnwindTableEntry() const {
689  return hasUWTable() || !doesNotThrow() || hasPersonalityFn();
690  }
691 
692  /// Determine if the function returns a structure through first
693  /// or second pointer argument.
694  bool hasStructRetAttr() const {
695  return AttributeSets.hasParamAttribute(0, Attribute::StructRet) ||
696  AttributeSets.hasParamAttribute(1, Attribute::StructRet);
697  }
698 
699  /// Determine if the parameter or return value is marked with NoAlias
700  /// attribute.
701  bool returnDoesNotAlias() const {
702  return AttributeSets.hasAttribute(AttributeList::ReturnIndex,
703  Attribute::NoAlias);
704  }
706  addAttribute(AttributeList::ReturnIndex, Attribute::NoAlias);
707  }
708 
709  /// Do not optimize this function (-O0).
710  bool hasOptNone() const { return hasFnAttribute(Attribute::OptimizeNone); }
711 
712  /// Optimize this function for minimum size (-Oz).
713  bool hasMinSize() const { return hasFnAttribute(Attribute::MinSize); }
714 
715  /// Optimize this function for size (-Os) or minimum size (-Oz).
716  bool hasOptSize() const {
717  return hasFnAttribute(Attribute::OptimizeForSize) || hasMinSize();
718  }
719 
720  /// Returns the denormal handling type for the default rounding mode of the
721  /// function.
722  DenormalMode getDenormalMode(const fltSemantics &FPType) const;
723 
724  /// copyAttributesFrom - copy all additional attributes (those not needed to
725  /// create a Function) from the Function Src to this one.
726  void copyAttributesFrom(const Function *Src);
727 
728  /// deleteBody - This method deletes the body of the function, and converts
729  /// the linkage to external.
730  ///
731  void deleteBody() {
734  }
735 
736  /// removeFromParent - This method unlinks 'this' from the containing module,
737  /// but does not delete it.
738  ///
739  void removeFromParent();
740 
741  /// eraseFromParent - This method unlinks 'this' from the containing module
742  /// and deletes it.
743  ///
744  void eraseFromParent();
745 
746  /// Steal arguments from another function.
747  ///
748  /// Drop this function's arguments and splice in the ones from \c Src.
749  /// Requires that this has no function body.
750  void stealArgumentListFrom(Function &Src);
751 
752  /// Get the underlying elements of the Function... the basic block list is
753  /// empty for external functions.
754  ///
755  const BasicBlockListType &getBasicBlockList() const { return BasicBlocks; }
756  BasicBlockListType &getBasicBlockList() { return BasicBlocks; }
757 
759  return &Function::BasicBlocks;
760  }
761 
762  const BasicBlock &getEntryBlock() const { return front(); }
763  BasicBlock &getEntryBlock() { return front(); }
764 
765  //===--------------------------------------------------------------------===//
766  // Symbol Table Accessing functions...
767 
768  /// getSymbolTable() - Return the symbol table if any, otherwise nullptr.
769  ///
770  inline ValueSymbolTable *getValueSymbolTable() { return SymTab.get(); }
771  inline const ValueSymbolTable *getValueSymbolTable() const {
772  return SymTab.get();
773  }
774 
775  //===--------------------------------------------------------------------===//
776  // BasicBlock iterator forwarding functions
777  //
778  iterator begin() { return BasicBlocks.begin(); }
779  const_iterator begin() const { return BasicBlocks.begin(); }
780  iterator end () { return BasicBlocks.end(); }
781  const_iterator end () const { return BasicBlocks.end(); }
782 
783  size_t size() const { return BasicBlocks.size(); }
784  bool empty() const { return BasicBlocks.empty(); }
785  const BasicBlock &front() const { return BasicBlocks.front(); }
786  BasicBlock &front() { return BasicBlocks.front(); }
787  const BasicBlock &back() const { return BasicBlocks.back(); }
788  BasicBlock &back() { return BasicBlocks.back(); }
789 
790 /// @name Function Argument Iteration
791 /// @{
792 
794  CheckLazyArguments();
795  return Arguments;
796  }
798  CheckLazyArguments();
799  return Arguments;
800  }
801 
803  CheckLazyArguments();
804  return Arguments + NumArgs;
805  }
807  CheckLazyArguments();
808  return Arguments + NumArgs;
809  }
810 
811  Argument* getArg(unsigned i) const {
812  assert (i < NumArgs && "getArg() out of range!");
813  CheckLazyArguments();
814  return Arguments + i;
815  }
816 
818  return make_range(arg_begin(), arg_end());
819  }
821  return make_range(arg_begin(), arg_end());
822  }
823 
824 /// @}
825 
826  size_t arg_size() const { return NumArgs; }
827  bool arg_empty() const { return arg_size() == 0; }
828 
829  /// Check whether this function has a personality function.
830  bool hasPersonalityFn() const {
831  return getSubclassDataFromValue() & (1<<3);
832  }
833 
834  /// Get the personality function associated with this function.
835  Constant *getPersonalityFn() const;
836  void setPersonalityFn(Constant *Fn);
837 
838  /// Check whether this function has prefix data.
839  bool hasPrefixData() const {
840  return getSubclassDataFromValue() & (1<<1);
841  }
842 
843  /// Get the prefix data associated with this function.
844  Constant *getPrefixData() const;
845  void setPrefixData(Constant *PrefixData);
846 
847  /// Check whether this function has prologue data.
848  bool hasPrologueData() const {
849  return getSubclassDataFromValue() & (1<<2);
850  }
851 
852  /// Get the prologue data associated with this function.
853  Constant *getPrologueData() const;
854  void setPrologueData(Constant *PrologueData);
855 
856  /// Print the function to an output stream with an optional
857  /// AssemblyAnnotationWriter.
858  void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW = nullptr,
859  bool ShouldPreserveUseListOrder = false,
860  bool IsForDebug = false) const;
861 
862  /// viewCFG - This function is meant for use from the debugger. You can just
863  /// say 'call F->viewCFG()' and a ghostview window should pop up from the
864  /// program, displaying the CFG of the current function with the code for each
865  /// basic block inside. This depends on there being a 'dot' and 'gv' program
866  /// in your path.
867  ///
868  void viewCFG() const;
869 
870  /// Extended form to print edge weights.
871  void viewCFG(bool ViewCFGOnly, const BlockFrequencyInfo *BFI,
872  const BranchProbabilityInfo *BPI) const;
873 
874  /// viewCFGOnly - This function is meant for use from the debugger. It works
875  /// just like viewCFG, but it does not include the contents of basic blocks
876  /// into the nodes, just the label. If you are only interested in the CFG
877  /// this can make the graph smaller.
878  ///
879  void viewCFGOnly() const;
880 
881  /// Extended form to print edge weights.
882  void viewCFGOnly(const BlockFrequencyInfo *BFI,
883  const BranchProbabilityInfo *BPI) const;
884 
885  /// Methods for support type inquiry through isa, cast, and dyn_cast:
886  static bool classof(const Value *V) {
887  return V->getValueID() == Value::FunctionVal;
888  }
889 
890  /// dropAllReferences() - This method causes all the subinstructions to "let
891  /// go" of all references that they are maintaining. This allows one to
892  /// 'delete' a whole module at a time, even though there may be circular
893  /// references... first all references are dropped, and all use counts go to
894  /// zero. Then everything is deleted for real. Note that no operations are
895  /// valid on an object that has "dropped all references", except operator
896  /// delete.
897  ///
898  /// Since no other object in the module can have references into the body of a
899  /// function, dropping all references deletes the entire body of the function,
900  /// including any contained basic blocks.
901  ///
902  void dropAllReferences();
903 
904  /// hasAddressTaken - returns true if there are any uses of this function
905  /// other than direct calls or invokes to it, or blockaddress expressions.
906  /// Optionally passes back an offending user for diagnostic purposes,
907  /// ignores callback uses, assume like pointer annotation calls, and
908  /// references in llvm.used and llvm.compiler.used variables.
909  ///
910  bool hasAddressTaken(const User ** = nullptr,
911  bool IgnoreCallbackUses = false,
912  bool IgnoreAssumeLikeCalls = true,
913  bool IngoreLLVMUsed = false) const;
914 
915  /// isDefTriviallyDead - Return true if it is trivially safe to remove
916  /// this function definition from the module (because it isn't externally
917  /// visible, does not have its address taken, and has no callers). To make
918  /// this more accurate, call removeDeadConstantUsers first.
919  bool isDefTriviallyDead() const;
920 
921  /// callsFunctionThatReturnsTwice - Return true if the function has a call to
922  /// setjmp or other function that gcc recognizes as "returning twice".
923  bool callsFunctionThatReturnsTwice() const;
924 
925  /// Set the attached subprogram.
926  ///
927  /// Calls \a setMetadata() with \a LLVMContext::MD_dbg.
928  void setSubprogram(DISubprogram *SP);
929 
930  /// Get the attached subprogram.
931  ///
932  /// Calls \a getMetadata() with \a LLVMContext::MD_dbg and casts the result
933  /// to \a DISubprogram.
934  DISubprogram *getSubprogram() const;
935 
936  /// Returns true if we should emit debug info for profiling.
937  bool isDebugInfoForProfiling() const;
938 
939  /// Check if null pointer dereferencing is considered undefined behavior for
940  /// the function.
941  /// Return value: false => null pointer dereference is undefined.
942  /// Return value: true => null pointer dereference is not undefined.
943  bool nullPointerIsDefined() const;
944 
945 private:
946  void allocHungoffUselist();
947  template<int Idx> void setHungoffOperand(Constant *C);
948 
949  /// Shadow Value::setValueSubclassData with a private forwarding method so
950  /// that subclasses cannot accidentally use it.
951  void setValueSubclassData(unsigned short D) {
953  }
954  void setValueSubclassDataBit(unsigned Bit, bool On);
955 };
956 
957 /// Check whether null pointer dereferencing is considered undefined behavior
958 /// for a given function or an address space.
959 /// Null pointer access in non-zero address space is not considered undefined.
960 /// Return value: false => null pointer dereference is undefined.
961 /// Return value: true => null pointer dereference is not undefined.
962 bool NullPointerIsDefined(const Function *F, unsigned AS = 0);
963 
964 template <>
966 
968 
969 } // end namespace llvm
970 
971 #endif // LLVM_IR_FUNCTION_H
i
i
Definition: README.txt:29
llvm::AttributeList::getParamInAllocaType
Type * getParamInAllocaType(unsigned ArgNo) const
Return the inalloca type for the specified function parameter.
Definition: Attributes.cpp:1455
llvm::Function::getBasicBlockList
BasicBlockListType & getBasicBlockList()
Definition: Function.h:756
llvm::objcarc::ARCInstKind::User
@ User
could "use" a pointer
llvm::Argument
This class represents an incoming formal argument to a Function.
Definition: Argument.h:29
llvm::Function::Create
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
Definition: Function.h:144
llvm::Function::setOnlyAccessesInaccessibleMemOrArgMem
void setOnlyAccessesInaccessibleMemOrArgMem()
Definition: Function.h:592
Attrs
Function Attrs
Definition: README_ALTIVEC.txt:215
llvm::Function::isIntrinsic
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
Definition: Function.h:210
llvm::Function::setNoSync
void setNoSync()
Definition: Function.h:654
llvm::Function::arg_empty
bool arg_empty() const
Definition: Function.h:827
LLVM_READONLY
#define LLVM_READONLY
Definition: Compiler.h:212
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::Function::args
iterator_range< arg_iterator > args()
Definition: Function.h:817
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition: iterator_range.h:53
llvm::AttributeList::hasFnAttribute
bool hasFnAttribute(Attribute::AttrKind Kind) const
Equivalent to hasAttribute(AttributeList::FunctionIndex, Kind) but may be faster.
Definition: Attributes.cpp:1400
llvm::Function::end
iterator end()
Definition: Function.h:780
FunctionType
Definition: ItaniumDemangle.h:643
llvm::Function::setSectionPrefix
void setSectionPrefix(StringRef Prefix)
Set the section prefix for this function.
Definition: Function.cpp:1904
llvm::Function::clearGC
void clearGC()
Definition: Function.cpp:654
llvm::GlobalObject::setGlobalObjectSubClassData
void setGlobalObjectSubClassData(unsigned Val)
Definition: GlobalObject.h:93
llvm::Function::getPrefixData
Constant * getPrefixData() const
Get the prefix data associated with this function.
Definition: Function.cpp:1793
llvm::Function::hasOptNone
bool hasOptNone() const
Do not optimize this function (-O0).
Definition: Function.h:710
llvm::cl::Prefix
@ Prefix
Definition: CommandLine.h:164
llvm::Function::empty
bool empty() const
Definition: Function.h:784
llvm::Function::getBasicBlockList
const BasicBlockListType & getBasicBlockList() const
Get the underlying elements of the Function...
Definition: Function.h:755
llvm::Function::doesNoCfCheck
bool doesNoCfCheck() const
Determine if the function should not perform indirect branch tracking.
Definition: Function.h:605
llvm::Function
Definition: Function.h:61
llvm::Function::print
void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW=nullptr, bool ShouldPreserveUseListOrder=false, bool IsForDebug=false) const
Print the function to an output stream with an optional AssemblyAnnotationWriter.
Definition: AsmWriter.cpp:4488
llvm::Attribute
Definition: Attributes.h:52
StringRef.h
llvm::Value::getSubclassDataFromValue
unsigned short getSubclassDataFromValue() const
Definition: Value.h:844
llvm::Function::getParamDereferenceableBytes
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const
Extract the number of dereferenceable bytes for a parameter.
Definition: Function.h:529
llvm::Attribute::get
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
Definition: Attributes.cpp:92
llvm::Function::addFnAttr
void addFnAttr(StringRef Kind, StringRef Val=StringRef())
Add function attributes to this function.
Definition: Function.h:260
llvm::Function::eraseFromParent
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Definition: Function.cpp:365
llvm::Function::getFnStackAlign
MaybeAlign getFnStackAlign() const
Return the stack alignment for the function.
Definition: Function.h:385
llvm::Function::PCT_Invalid
@ PCT_Invalid
Definition: Function.h:287
llvm::Function::getParamByValType
Type * getParamByValType(unsigned ArgNo) const
Extract the byval type for a parameter.
Definition: Function.h:501
llvm::Function::begin
const_iterator begin() const
Definition: Function.h:779
llvm::Function::getSubprogram
DISubprogram * getSubprogram() const
Get the attached subprogram.
Definition: Metadata.cpp:1532
llvm::Function::getEntryBlock
const BasicBlock & getEntryBlock() const
Definition: Function.h:762
llvm::AttributeList::getParamByValType
Type * getParamByValType(unsigned ArgNo) const
Return the byval type for the specified function parameter.
Definition: Attributes.cpp:1439
llvm::Function::setDoesNotThrow
void setDoesNotThrow()
Definition: Function.h:611
llvm::Function::setWillReturn
void setWillReturn()
Definition: Function.h:676
llvm::Function::getContext
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Definition: Function.cpp:321
llvm::Function::arg_size
size_t arg_size() const
Definition: Function.h:826
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::Function::getFnStackAlignment
unsigned getFnStackAlignment() const
Return the stack alignment for the function.
Definition: Function.h:375
llvm::AttributeList
Definition: Attributes.h:398
DEFINE_TRANSPARENT_OPERAND_ACCESSORS
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
Definition: OperandTraits.h:125
llvm::Function::front
BasicBlock & front()
Definition: Function.h:786
llvm::Function::addParamAttrs
void addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs)
adds the attributes to the list of attributes for the given arg.
Definition: Function.cpp:562
llvm::Function::hasFnAttribute
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:355
llvm::Optional
Definition: APInt.h:33
llvm::Function::getAttribute
Attribute getAttribute(unsigned i, StringRef Kind) const
gets the attribute from the list of attributes.
Definition: Function.h:464
GlobalObject.h
llvm::Function::setCannotDuplicate
void setCannotDuplicate()
Definition: Function.h:619
llvm::MCID::Convergent
@ Convergent
Definition: MCInstrDesc.h:182
llvm::Function::getDereferenceableBytes
uint64_t getDereferenceableBytes(unsigned i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
Definition: Function.h:523
llvm::Function::hasStackProtectorFnAttr
bool hasStackProtectorFnAttr() const
Returns true if the function has ssp, sspstrong, or sspreq fn attrs.
Definition: Function.cpp:661
llvm::Function::ProfileCount::isSynthetic
bool isSynthetic() const
Definition: Function.h:305
llvm::Function::isDefTriviallyDead
bool isDefTriviallyDead() const
isDefTriviallyDead - Return true if it is trivially safe to remove this function definition from the ...
Definition: Function.cpp:1758
llvm::GlobalValue::LinkageTypes
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
llvm::Value::setValueSubclassData
void setValueSubclassData(unsigned short D)
Definition: Value.h:845
llvm::Function::addFnAttr
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
Definition: Function.h:255
llvm::BitmaskEnumDetail::Mask
std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:80
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::FunctionType::isVarArg
bool isVarArg() const
Definition: DerivedTypes.h:122
llvm::Function::viewCFG
void viewCFG() const
viewCFG - This function is meant for use from the debugger.
Definition: CFGPrinter.cpp:263
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::AttributeList::hasAttribute
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
Definition: Attributes.cpp:1387
llvm::Function::setOnlyAccessesArgMemory
void setOnlyAccessesArgMemory()
Definition: Function.h:576
llvm::Function::setGC
void setGC(std::string Str)
Definition: Function.cpp:649
llvm::AttributeList::getParamStackAlignment
MaybeAlign getParamStackAlignment(unsigned ArgNo) const
Return the stack alignment for the specified function parameter.
Definition: Attributes.cpp:1435
llvm::Function::setConvergent
void setConvergent()
Definition: Function.h:627
llvm::Function::hasUWTable
bool hasUWTable() const
True if the ABI mandates (or the user requested) that this function be in a unwind table.
Definition: Function.h:680
llvm::BlockFrequencyInfo
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Definition: BlockFrequencyInfo.h:37
llvm::Function::getSublistAccess
static BasicBlockListType Function::* getSublistAccess(BasicBlock *)
Definition: Function.h:758
GlobalValue.h
llvm::OperandTraits
Compile-time customization of User operands.
Definition: User.h:42
llvm::Function::PCT_Synthetic
@ PCT_Synthetic
Definition: Function.h:287
llvm::Function::end
const_iterator end() const
Definition: Function.h:781
llvm::Function::ProfileCount::ProfileCount
ProfileCount()
Definition: Function.h:299
llvm::Function::removeParamUndefImplyingAttrs
void removeParamUndefImplyingAttrs(unsigned ArgNo)
removes noundef and other attributes that imply undefined behavior if a undef or poison value is pass...
llvm::Function::stealArgumentListFrom
void stealArgumentListFrom(Function &Src)
Steal arguments from another function.
Definition: Function.cpp:465
llvm::ISD::Constant
@ Constant
Definition: ISDOpcodes.h:76
llvm::Function::getEntryBlock
BasicBlock & getEntryBlock()
Definition: Function.h:763
llvm::User
Definition: User.h:44
llvm::Function::onlyAccessesInaccessibleMemory
bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
Definition: Function.h:580
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
Twine.h
llvm::GlobalObject
Definition: GlobalObject.h:28
llvm::Function::ProfileCount::operator!
bool operator!() const
Definition: Function.h:307
llvm::BranchProbabilityInfo
Analysis providing branch probability information.
Definition: BranchProbabilityInfo.h:115
llvm::Function::setSpeculatable
void setSpeculatable()
Definition: Function.h:638
llvm::Function::removeFnAttr
void removeFnAttr(StringRef Kind)
Remove function attribute from this function.
Definition: Function.h:276
llvm::Function::back
BasicBlock & back()
Definition: Function.h:788
DenseSet.h
llvm::Function::cannotDuplicate
bool cannotDuplicate() const
Determine if the call cannot be duplicated.
Definition: Function.h:616
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:109
llvm::Function::arg_end
arg_iterator arg_end()
Definition: Function.h:802
llvm::Value::getValueID
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:529
llvm::Function::ProfileCount::ProfileCount
ProfileCount(uint64_t Count, ProfileCountType PCT)
Definition: Function.h:300
llvm::Function::getDereferenceableOrNullBytes
uint64_t getDereferenceableOrNullBytes(unsigned i) const
Extract the number of dereferenceable_or_null bytes for a call or parameter (0=unknown).
Definition: Function.h:536
llvm::Function::setDoesNotRecurse
void setDoesNotRecurse()
Definition: Function.h:663
llvm::Function::copyAttributesFrom
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
Definition: Function.cpp:669
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::Function::removeParamAttr
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
Definition: Function.cpp:586
llvm::Function::hasPersonalityFn
bool hasPersonalityFn() const
Check whether this function has a personality function.
Definition: Function.h:830
OperandTraits.h
llvm::AttributeList::getStackAlignment
MaybeAlign getStackAlignment(unsigned Index) const
Get the stack alignment.
Definition: Attributes.cpp:1463
llvm::GlobalObject::getGlobalObjectSubClassData
unsigned getGlobalObjectSubClassData() const
Definition: GlobalObject.h:88
llvm::Function::PCT_Real
@ PCT_Real
Definition: Function.h:287
llvm::AttributeList::hasParamAttribute
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
Equivalent to hasAttribute(ArgNo + FirstArgIndex, Kind).
Definition: Attributes.cpp:1408
llvm::Function::isSpeculatable
bool isSpeculatable() const
Determine if the call has sideeffects.
Definition: Function.h:635
llvm::Function::viewCFGOnly
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
Definition: CFGPrinter.cpp:278
llvm::Function::getSectionPrefix
Optional< StringRef > getSectionPrefix() const
Get the section prefix for this function.
Definition: Function.cpp:1910
llvm::Function::isMaterializable
bool isMaterializable() const
Definition: Function.h:190
llvm::Function::doesNotAccessMemory
bool doesNotAccessMemory() const
Determine if the function does not access memory.
Definition: Function.h:548
llvm::None
const NoneType None
Definition: None.h:23
llvm::GlobalValue::IntID
Intrinsic::ID IntID
The intrinsic ID for this subclass (which must be a Function).
Definition: GlobalValue.h:156
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::Function::getParamInAllocaType
Type * getParamInAllocaType(unsigned ArgNo) const
Extract the inalloca type for a parameter.
Definition: Function.h:511
llvm::Function::getValueSymbolTable
const ValueSymbolTable * getValueSymbolTable() const
Definition: Function.h:771
llvm::Function::addDereferenceableOrNullAttr
void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable_or_null attribute to the list of attributes.
Definition: Function.cpp:616
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::codeview::ClassOptions::Intrinsic
@ Intrinsic
llvm::Function::hasPrologueData
bool hasPrologueData() const
Check whether this function has prologue data.
Definition: Function.h:848
llvm::Function::getAttributes
AttributeList getAttributes() const
Return the attribute list for this Function.
Definition: Function.h:249
llvm::Function::getGC
const std::string & getGC() const
Definition: Function.cpp:644
llvm::DenseSet< GlobalValue::GUID >
BasicBlock.h
llvm::Function::setSubprogram
void setSubprogram(DISubprogram *SP)
Set the attached subprogram.
Definition: Metadata.cpp:1528
llvm::AttributeList::ReturnIndex
@ ReturnIndex
Definition: Attributes.h:401
llvm::Function::setDoesNotFreeMemory
void setDoesNotFreeMemory()
Definition: Function.h:646
llvm::Function::hasFnAttribute
bool hasFnAttribute(StringRef Kind) const
Return true if the function has the attribute.
Definition: Function.h:360
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::Function::getReturnType
Type * getReturnType() const
Returns the type of the ret val.
Definition: Function.h:180
llvm::Function::willReturn
bool willReturn() const
Determine if the function will return.
Definition: Function.h:675
llvm::CallingConv::MaxID
@ MaxID
The highest possible calling convention ID. Must be some 2^k - 1.
Definition: CallingConv.h:256
llvm::Function::removeAttribute
void removeAttribute(unsigned i, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
Definition: Function.cpp:568
llvm::SymbolTableListTraits
Definition: GlobalAlias.h:25
llvm::Function::hasPrefixData
bool hasPrefixData() const
Check whether this function has prefix data.
Definition: Function.h:839
llvm::Function::dropAllReferences
void dropAllReferences()
dropAllReferences() - This method causes all the subinstructions to "let go" of all references that t...
Definition: Function.cpp:510
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::Function::getCallingConv
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Definition: Function.h:238
llvm::AttributeList::getDereferenceableBytes
uint64_t getDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown).
Definition: Attributes.cpp:1467
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
llvm::Function::isDebugInfoForProfiling
bool isDebugInfoForProfiling() const
Returns true if we should emit debug info for profiling.
Definition: Metadata.cpp:1536
llvm::Function::hasGC
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
Definition: Function.h:393
llvm::Function::setDoesNotAccessMemory
void setDoesNotAccessMemory()
Definition: Function.h:551
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
llvm::Function::removeParamAttrs
void removeParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs)
removes the attribute from the list of attributes.
Definition: Function.cpp:598
llvm::Function::setDoesNotReadMemory
void setDoesNotReadMemory()
Definition: Function.h:567
llvm::AttrBuilder
Definition: Attributes.h:814
llvm::Function::addDereferenceableOrNullParamAttr
void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes)
adds the dereferenceable_or_null attribute to the list of attributes for the given arg.
Definition: Function.cpp:622
llvm::Function::args
iterator_range< const_arg_iterator > args() const
Definition: Function.h:820
llvm::DenormalMode
Represent subnormal handling kind for floating point instruction inputs and outputs.
Definition: FloatingPointMode.h:67
llvm::Attribute::AttrKind
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition: Attributes.h:71
llvm::Function::setMustProgress
void setMustProgress()
Definition: Function.h:672
llvm::AttributeList::getParamAlignment
MaybeAlign getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
Definition: Attributes.cpp:1431
llvm::Function::hasStructRetAttr
bool hasStructRetAttr() const
Determine if the function returns a structure through first or second pointer argument.
Definition: Function.h:694
llvm::GlobalValue::setLinkage
void setLinkage(LinkageTypes LT)
Definition: GlobalValue.h:454
TemplateParamKind::Type
@ Type
llvm::GlobalValue::Linkage
unsigned Linkage
Definition: GlobalValue.h:94
llvm::Function::onlyAccessesInaccessibleMemOrArgMem
bool onlyAccessesInaccessibleMemOrArgMem() const
Determine if the function may only access memory that is either inaccessible from the IR or pointed t...
Definition: Function.h:589
llvm::Function::Create
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Definition: Function.h:137
llvm::Function::ProfileCountType
ProfileCountType
Definition: Function.h:287
llvm::SmallVectorImpl::const_iterator
typename SuperClass::const_iterator const_iterator
Definition: SmallVector.h:563
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::Function::hasParamAttribute
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
check if an attributes is in the list of attributes.
Definition: Function.h:449
llvm::Function::lookupIntrinsicID
static Intrinsic::ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
Definition: Function.cpp:727
iterator_range.h
llvm::Function::hasAttribute
bool hasAttribute(unsigned i, Attribute::AttrKind Kind) const
check if an attributes is in the list of attributes.
Definition: Function.h:444
llvm::Function::setPersonalityFn
void setPersonalityFn(Constant *Fn)
Definition: Function.cpp:1788
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::Function::doesNotRecurse
bool doesNotRecurse() const
Determine if the function is known not to recurse, directly or indirectly.
Definition: Function.h:660
llvm::Function::getFunction
const Function & getFunction() const
Definition: Function.h:135
llvm::Function::hasAddressTaken
bool hasAddressTaken(const User **=nullptr, bool IgnoreCallbackUses=false, bool IgnoreAssumeLikeCalls=true, bool IngoreLLVMUsed=false) const
hasAddressTaken - returns true if there are any uses of this function other than direct calls or invo...
Definition: Function.cpp:1703
llvm::Function::classof
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition: Function.h:886
llvm::Function::getIntrinsicID
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Definition: Function.h:205
llvm::Function::createWithDefaultAttr
static Function * createWithDefaultAttr(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Creates a function with some attributes recorded in llvm.module.flags applied.
Definition: Function.cpp:338
llvm::Function::setEntryCount
void setEntryCount(ProfileCount Count, const DenseSet< GlobalValue::GUID > *Imports=nullptr)
Set the entry count for this function.
Definition: Function.cpp:1847
llvm::Function::isConvergent
bool isConvergent() const
Determine if the call is convergent.
Definition: Function.h:624
llvm::SymbolTableList< BasicBlock >
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::Function::setCallingConv
void setCallingConv(CallingConv::ID CC)
Definition: Function.h:242
llvm::Function::getEntryCount
ProfileCount getEntryCount(bool AllowSynthetic=false) const
Get the entry count for this function.
Definition: Function.cpp:1870
Compiler.h
llvm::AttributeList::getParamByRefType
Type * getParamByRefType(unsigned ArgNo) const
Return the byref type for the specified function parameter.
Definition: Attributes.cpp:1447
llvm::Function::getParamAlign
MaybeAlign getParamAlign(unsigned ArgNo) const
Definition: Function.h:492
llvm::Function::ProfileCount::getType
ProfileCountType getType() const
Definition: Function.h:304
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::AMDGPUISD::BFI
@ BFI
Definition: AMDGPUISelLowering.h:421
llvm::Function::setOnlyReadsMemory
void setOnlyReadsMemory()
Definition: Function.h:559
llvm::Function::callsFunctionThatReturnsTwice
bool callsFunctionThatReturnsTwice() const
callsFunctionThatReturnsTwice - Return true if the function has a call to setjmp or other function th...
Definition: Function.cpp:1774
llvm::Function::setIsMaterializable
void setIsMaterializable(bool V)
Definition: Function.h:193
llvm::Function::begin
iterator begin()
Definition: Function.h:778
llvm::Function::getDenormalMode
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
Definition: Function.cpp:629
llvm::Function::doesNotFreeMemory
bool doesNotFreeMemory() const
Determine if the call might deallocate memory.
Definition: Function.h:643
llvm::ilist_node
Definition: ilist_node.h:148
llvm::Function::hasOptSize
bool hasOptSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
Definition: Function.h:716
llvm::Function::ProfileCount::getCount
uint64_t getCount() const
Definition: Function.h:303
llvm::Function::getFnAttribute
Attribute getFnAttribute(StringRef Kind) const
Return the attribute for the given attribute kind.
Definition: Function.h:370
llvm::cl::Optional
@ Optional
Definition: CommandLine.h:119
Argument.h
llvm::AttributeList::getParamDereferenceableOrNullBytes
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of an arg.
Definition: Attributes.h:733
llvm::Function::returnDoesNotAlias
bool returnDoesNotAlias() const
Determine if the parameter or return value is marked with NoAlias attribute.
Definition: Function.h:701
CallingConv.h
llvm::Function::doesNotThrow
bool doesNotThrow() const
Determine if the function cannot unwind.
Definition: Function.h:608
llvm::Function::addAttributes
void addAttributes(unsigned i, const AttrBuilder &Attrs)
adds the attributes to the list of attributes.
Definition: Function.cpp:544
Attributes.h
llvm::Function::hasLazyArguments
bool hasLazyArguments() const
hasLazyArguments/CheckLazyArguments - The argument list of a function is built on demand,...
Definition: Function.h:106
llvm::Function::ProfileCount::setCount
ProfileCount & setCount(uint64_t C)
Definition: Function.h:309
llvm::Function::addParamAttr
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
adds the attribute to the list of attributes for the given arg.
Definition: Function.cpp:550
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::Function::getValueSymbolTable
ValueSymbolTable * getValueSymbolTable()
getSymbolTable() - Return the symbol table if any, otherwise nullptr.
Definition: Function.h:770
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::AssemblyAnnotationWriter
Definition: AssemblyAnnotationWriter.h:27
llvm::Function::getFnAttribute
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
Definition: Function.h:365
llvm::Function::getArg
Argument * getArg(unsigned i) const
Definition: Function.h:811
llvm::Function::back
const BasicBlock & back() const
Definition: Function.h:787
llvm::Function::getParamDereferenceableOrNullBytes
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Extract the number of dereferenceable_or_null bytes for a parameter.
Definition: Function.h:543
llvm::AttributeList::getAttribute
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
Definition: Attributes.cpp:1418
llvm::AttributeList::getParamStructRetType
Type * getParamStructRetType(unsigned ArgNo) const
Return the sret type for the specified function parameter.
Definition: Attributes.cpp:1443
llvm::Function::removeAttributes
void removeAttributes(unsigned i, const AttrBuilder &Attrs)
removes the attributes from the list of attributes.
Definition: Function.cpp:580
Casting.h
llvm::fltSemantics
Definition: APFloat.cpp:54
llvm::Function::getParamAttribute
Attribute getParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
gets the specified attribute from the list of attributes.
Definition: Function.h:454
llvm::Function::addDereferenceableParamAttr
void addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes for the given arg.
Definition: Function.cpp:610
llvm::Function::needsUnwindTableEntry
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
Definition: Function.h:688
Arguments
AMDGPU Lower Kernel Arguments
Definition: AMDGPULowerKernelArguments.cpp:244
llvm::Function::addAttribute
void addAttribute(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
Definition: Function.cpp:532
llvm::Function::isTargetIntrinsic
bool isTargetIntrinsic() const
isTargetIntrinsic - Returns true if this function is an intrinsic and the intrinsic is specific to a ...
Definition: Function.cpp:702
llvm::Function::~Function
~Function()
Definition: Function.cpp:410
llvm::Function::getFunctionType
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition: Function.h:175
llvm::Function::hasProfileData
bool hasProfileData(bool IncludeSynthetic=false) const
Return true if the function is annotated with profile data.
Definition: Function.h:340
llvm::Function::onlyAccessesArgMemory
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
Definition: Function.h:573
llvm::Function::doesNotReadMemory
bool doesNotReadMemory() const
Determine if the function does not access or only writes memory.
Definition: Function.h:564
llvm::orc::ReadOnly
static constexpr sys::Memory::ProtectionFlags ReadOnly
Definition: DebugObjectManagerPlugin.cpp:111
llvm::Function::ProfileCount::getInvalid
static ProfileCount getInvalid()
Definition: Function.h:313
llvm::Function::setNotConvergent
void setNotConvergent()
Definition: Function.h:630
llvm::Function::mustProgress
bool mustProgress() const
Determine if the function is required to make forward progress.
Definition: Function.h:668
llvm::Function::isConstrainedFPIntrinsic
bool isConstrainedFPIntrinsic() const
Returns true if the function is one of the "Constrained Floating-Point Intrinsics".
Definition: Function.cpp:444
llvm::Function::getParamStackAlign
MaybeAlign getParamStackAlign(unsigned ArgNo) const
Definition: Function.h:496
llvm::Function::getPersonalityFn
Constant * getPersonalityFn() const
Get the personality function associated with this function.
Definition: Function.cpp:1783
llvm::Function::getInstructionCount
unsigned getInstructionCount() const
Returns the number of non-debug IR instructions in this function.
Definition: Function.cpp:325
llvm::Function::arg_begin
arg_iterator arg_begin()
Definition: Function.h:793
llvm::Function::deleteBody
void deleteBody()
deleteBody - This method deletes the body of the function, and converts the linkage to external.
Definition: Function.h:731
llvm::Function::addFnAttr
void addFnAttr(Attribute Attr)
Add function attributes to this function.
Definition: Function.h:266
llvm::Function::getParamByRefType
Type * getParamByRefType(unsigned ArgNo) const
Extract the byref type for a parameter.
Definition: Function.h:516
llvm::AttributeList::getDereferenceableOrNullBytes
uint64_t getDereferenceableOrNullBytes(unsigned Index) const
Get the number of dereferenceable_or_null bytes (or zero if unknown).
Definition: Attributes.cpp:1471
llvm::Function::front
const BasicBlock & front() const
Definition: Function.h:785
llvm::GlobalValue::ExternalLinkage
@ ExternalLinkage
Externally visible function.
Definition: GlobalValue.h:48
llvm::GlobalValue::HasLLVMReservedName
unsigned HasLLVMReservedName
True if the function's name starts with "llvm.".
Definition: GlobalValue.h:105
llvm::AttributeList::FunctionIndex
@ FunctionIndex
Definition: Attributes.h:402
llvm::Function::isVarArg
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
Definition: Function.h:188
llvm::Function::getParamAlignment
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Definition: Function.h:486
llvm::Function::nullPointerIsDefined
bool nullPointerIsDefined() const
Check if null pointer dereferencing is considered undefined behavior for the function.
Definition: Function.cpp:1921
llvm::Function::arg_end
const_arg_iterator arg_end() const
Definition: Function.h:806
llvm::Function::setPrefixData
void setPrefixData(Constant *PrefixData)
Definition: Function.cpp:1798
llvm::ValueSymbolTable
This class provides a symbol table of name/value pairs.
Definition: ValueSymbolTable.h:37
llvm::SmallVectorImpl::iterator
typename SuperClass::iterator iterator
Definition: SmallVector.h:562
llvm::Function::setHasUWTable
void setHasUWTable()
Definition: Function.h:683
N
#define N
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::tgtok::Bit
@ Bit
Definition: TGLexer.h:50
llvm::Function::setDoesNotReturn
void setDoesNotReturn()
Definition: Function.h:600
llvm::Function::doesNotReturn
bool doesNotReturn() const
Determine if the function cannot return.
Definition: Function.h:597
llvm::Function::getAttribute
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const
gets the attribute from the list of attributes.
Definition: Function.h:459
llvm::Function::onlyReadsMemory
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
Definition: Function.h:556
ilist_node.h
llvm::Function::removeFromParent
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
Definition: Function.cpp:361
llvm::DISubprogram
Subprogram description.
Definition: DebugInfoMetadata.h:1802
llvm::Function::hasMinSize
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
Definition: Function.h:713
DerivedTypes.h
llvm::Function::setPrologueData
void setPrologueData(Constant *PrologueData)
Definition: Function.cpp:1808
llvm::GlobalValue::getValueType
Type * getValueType() const
Definition: GlobalValue.h:273
llvm::Function::recalculateIntrinsicID
void recalculateIntrinsicID()
Recalculate the ID for this function if it is an Intrinsic defined in llvm/Intrinsics....
Definition: Function.cpp:747
llvm::Function::getPrologueData
Constant * getPrologueData() const
Get the prologue data associated with this function.
Definition: Function.cpp:1803
llvm::Function::setOnlyAccessesInaccessibleMemory
void setOnlyAccessesInaccessibleMemory()
Definition: Function.h:583
llvm::Function::hasNoSync
bool hasNoSync() const
Determine if the call can synchroize with other threads.
Definition: Function.h:651
llvm::Function::ProfileCount
Class to represent profile counts.
Definition: Function.h:292
llvm::HungoffOperandTraits
HungoffOperandTraits - determine the allocation regime of the Use array when it is not a prefix to th...
Definition: OperandTraits.h:95
llvm::NullPointerIsDefined
bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
Definition: Function.cpp:1925
llvm::Function::ProfileCount::hasValue
bool hasValue() const
Definition: Function.h:302
llvm::Function::arg_begin
const_arg_iterator arg_begin() const
Definition: Function.h:797
SymbolTableListTraits.h
llvm::Function::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Value.h
llvm::Function::getParamStructRetType
Type * getParamStructRetType(unsigned ArgNo) const
Extract the sret type for a parameter.
Definition: Function.h:506
llvm::Function::setAttributes
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
Definition: Function.h:252
llvm::AttributeList::getParamDereferenceableBytes
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const
Get the number of dereferenceable bytes (or zero if unknown) of an arg.
Definition: Attributes.h:723
llvm::Function::removeFnAttr
void removeFnAttr(Attribute::AttrKind Kind)
Remove function attributes from this function.
Definition: Function.h:271
llvm::FunctionType::getReturnType
Type * getReturnType() const
Definition: DerivedTypes.h:123
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::AttributeList::getParamAttr
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return the attribute object that exists at the arg index.
Definition: Attributes.h:679
llvm::Function::operator=
void operator=(const Function &)=delete
llvm::Function::isPresplitCoroutine
bool isPresplitCoroutine() const
A function will have the "coroutine.presplit" attribute if it's a coroutine and has not gone through ...
Definition: Function.h:283
llvm::Function::const_iterator
BasicBlockListType::const_iterator const_iterator
Definition: Function.h:67
llvm::Function::setReturnDoesNotAlias
void setReturnDoesNotAlias()
Definition: Function.h:705
llvm::Function::addDereferenceableAttr
void addDereferenceableAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes.
Definition: Function.cpp:604
llvm::FunctionType
Class to represent function types.
Definition: DerivedTypes.h:102
llvm::Function::size
size_t size() const
Definition: Function.h:783
llvm::Function::iterator
BasicBlockListType::iterator iterator
Definition: Function.h:66
llvm::Function::getImportGUIDs
DenseSet< GlobalValue::GUID > getImportGUIDs() const
Returns the set of GUIDs that needs to be imported to the function for sample PGO,...
Definition: Function.cpp:1892
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38