1 //===- llvm/Function.h - Class to represent a single function ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the declaration of the Function class, which represents a
11 // single function/procedure in LLVM.
13 // A function basically consists of a list of basic blocks, a list of arguments,
14 // and a symbol table.
16 //===----------------------------------------------------------------------===//
18 #ifndef LLVM_IR_FUNCTION_H
19 #define LLVM_IR_FUNCTION_H
21 #include "llvm/ADT/DenseSet.h"
22 #include "llvm/ADT/StringRef.h"
23 #include "llvm/ADT/Twine.h"
24 #include "llvm/ADT/ilist_node.h"
25 #include "llvm/ADT/iterator_range.h"
26 #include "llvm/IR/Argument.h"
27 #include "llvm/IR/Attributes.h"
28 #include "llvm/IR/BasicBlock.h"
29 #include "llvm/IR/CallingConv.h"
30 #include "llvm/IR/DerivedTypes.h"
31 #include "llvm/IR/GlobalObject.h"
32 #include "llvm/IR/GlobalValue.h"
33 #include "llvm/IR/OperandTraits.h"
34 #include "llvm/IR/SymbolTableListTraits.h"
35 #include "llvm/IR/Value.h"
36 #include "llvm/Support/Casting.h"
37 #include "llvm/Support/Compiler.h"
50 class AssemblyAnnotationWriter;
55 template <typename T> class Optional;
60 class Function : public GlobalObject, public ilist_node<Function> {
62 using BasicBlockListType = SymbolTableList<BasicBlock>;
64 // BasicBlock iterators...
65 using iterator = BasicBlockListType::iterator;
66 using const_iterator = BasicBlockListType::const_iterator;
68 using arg_iterator = Argument *;
69 using const_arg_iterator = const Argument *;
72 // Important things that make up a function!
73 BasicBlockListType BasicBlocks; ///< The basic blocks
74 mutable Argument *Arguments = nullptr; ///< The formal arguments
76 std::unique_ptr<ValueSymbolTable>
77 SymTab; ///< Symbol table of args/instructions
78 AttributeList AttributeSets; ///< Parameter attributes
83 * bit 0 : HasLazyArguments
84 * bit 1 : HasPrefixData
85 * bit 2 : HasPrologueData
86 * bit 3 : HasPersonalityFn
87 * bits 4-13 : CallingConvention
89 * bits 15 : [reserved]
92 /// Bits from GlobalObject::GlobalObjectSubclassData.
94 /// Whether this function is materializable.
95 IsMaterializableBit = 0,
98 friend class SymbolTableListTraits<Function>;
100 /// hasLazyArguments/CheckLazyArguments - The argument list of a function is
101 /// built on demand, so that the list isn't allocated until the first client
102 /// needs it. The hasLazyArguments predicate returns true if the arg list
103 /// hasn't been set up yet.
105 bool hasLazyArguments() const {
106 return getSubclassDataFromValue() & (1<<0);
110 void CheckLazyArguments() const {
111 if (hasLazyArguments())
112 BuildLazyArguments();
115 void BuildLazyArguments() const;
117 void clearArguments();
119 /// Function ctor - If the (optional) Module argument is specified, the
120 /// function is automatically inserted into the end of the function list for
123 Function(FunctionType *Ty, LinkageTypes Linkage,
124 const Twine &N = "", Module *M = nullptr);
127 Function(const Function&) = delete;
128 void operator=(const Function&) = delete;
131 // This is here to help easily convert from FunctionT * (Function * or
132 // MachineFunction *) in BlockFrequencyInfoImpl to Function * by calling
133 // FunctionT->getFunction().
134 const Function &getFunction() const { return *this; }
136 static Function *Create(FunctionType *Ty, LinkageTypes Linkage,
137 const Twine &N = "", Module *M = nullptr) {
138 return new Function(Ty, Linkage, N, M);
141 // Provide fast operand accessors.
142 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
144 /// Returns the FunctionType for me.
145 FunctionType *getFunctionType() const {
146 return cast<FunctionType>(getValueType());
149 /// Returns the type of the ret val.
150 Type *getReturnType() const { return getFunctionType()->getReturnType(); }
152 /// getContext - Return a reference to the LLVMContext associated with this
154 LLVMContext &getContext() const;
156 /// isVarArg - Return true if this function takes a variable number of
158 bool isVarArg() const { return getFunctionType()->isVarArg(); }
160 bool isMaterializable() const {
161 return getGlobalObjectSubClassData() & (1 << IsMaterializableBit);
163 void setIsMaterializable(bool V) {
164 unsigned Mask = 1 << IsMaterializableBit;
165 setGlobalObjectSubClassData((~Mask & getGlobalObjectSubClassData()) |
169 /// getIntrinsicID - This method returns the ID number of the specified
170 /// function, or Intrinsic::not_intrinsic if the function is not an
171 /// intrinsic, or if the pointer is null. This value is always defined to be
172 /// zero to allow easy checking for whether a function is intrinsic or not.
173 /// The particular intrinsic functions which correspond to this value are
174 /// defined in llvm/Intrinsics.h.
175 Intrinsic::ID getIntrinsicID() const LLVM_READONLY { return IntID; }
177 /// isIntrinsic - Returns true if the function's name starts with "llvm.".
178 /// It's possible for this function to return true while getIntrinsicID()
179 /// returns Intrinsic::not_intrinsic!
180 bool isIntrinsic() const { return HasLLVMReservedName; }
182 static Intrinsic::ID lookupIntrinsicID(StringRef Name);
184 /// \brief Recalculate the ID for this function if it is an Intrinsic defined
185 /// in llvm/Intrinsics.h. Sets the intrinsic ID to Intrinsic::not_intrinsic
186 /// if the name of this function does not match an intrinsic in that header.
187 /// Note, this method does not need to be called directly, as it is called
188 /// from Value::setName() whenever the name of this function changes.
189 void recalculateIntrinsicID();
191 /// getCallingConv()/setCallingConv(CC) - These method get and set the
192 /// calling convention of this function. The enum values for the known
193 /// calling conventions are defined in CallingConv.h.
194 CallingConv::ID getCallingConv() const {
195 return static_cast<CallingConv::ID>((getSubclassDataFromValue() >> 4) &
198 void setCallingConv(CallingConv::ID CC) {
199 auto ID = static_cast<unsigned>(CC);
200 assert(!(ID & ~CallingConv::MaxID) && "Unsupported calling convention");
201 setValueSubclassData((getSubclassDataFromValue() & 0xc00f) | (ID << 4));
204 /// @brief Return the attribute list for this Function.
205 AttributeList getAttributes() const { return AttributeSets; }
207 /// @brief Set the attribute list for this Function.
208 void setAttributes(AttributeList Attrs) { AttributeSets = Attrs; }
210 /// @brief Add function attributes to this function.
211 void addFnAttr(Attribute::AttrKind Kind) {
212 addAttribute(AttributeList::FunctionIndex, Kind);
215 /// @brief Add function attributes to this function.
216 void addFnAttr(StringRef Kind, StringRef Val = StringRef()) {
217 addAttribute(AttributeList::FunctionIndex,
218 Attribute::get(getContext(), Kind, Val));
221 /// @brief Add function attributes to this function.
222 void addFnAttr(Attribute Attr) {
223 addAttribute(AttributeList::FunctionIndex, Attr);
226 /// @brief Remove function attributes from this function.
227 void removeFnAttr(Attribute::AttrKind Kind) {
228 removeAttribute(AttributeList::FunctionIndex, Kind);
231 /// @brief Remove function attribute from this function.
232 void removeFnAttr(StringRef Kind) {
233 setAttributes(getAttributes().removeAttribute(
234 getContext(), AttributeList::FunctionIndex, Kind));
237 /// \brief Set the entry count for this function.
239 /// Entry count is the number of times this function was executed based on
240 /// pgo data. \p Imports points to a set of GUIDs that needs to be imported
241 /// by the function for sample PGO, to enable the same inlines as the
242 /// profiled optimized binary.
243 void setEntryCount(uint64_t Count,
244 const DenseSet<GlobalValue::GUID> *Imports = nullptr);
246 /// \brief Get the entry count for this function.
248 /// Entry count is the number of times the function was executed based on
250 Optional<uint64_t> getEntryCount() const;
252 /// Return true if the function is annotated with profile data.
254 /// Presence of entry counts from a profile run implies the function has
255 /// profile annotations.
256 bool hasProfileData() const { return getEntryCount().hasValue(); }
258 /// Returns the set of GUIDs that needs to be imported to the function for
259 /// sample PGO, to enable the same inlines as the profiled optimized binary.
260 DenseSet<GlobalValue::GUID> getImportGUIDs() const;
262 /// Set the section prefix for this function.
263 void setSectionPrefix(StringRef Prefix);
265 /// Get the section prefix for this function.
266 Optional<StringRef> getSectionPrefix() const;
268 /// @brief Return true if the function has the attribute.
269 bool hasFnAttribute(Attribute::AttrKind Kind) const {
270 return AttributeSets.hasFnAttribute(Kind);
273 /// @brief Return true if the function has the attribute.
274 bool hasFnAttribute(StringRef Kind) const {
275 return AttributeSets.hasFnAttribute(Kind);
278 /// @brief Return the attribute for the given attribute kind.
279 Attribute getFnAttribute(Attribute::AttrKind Kind) const {
280 return getAttribute(AttributeList::FunctionIndex, Kind);
283 /// @brief Return the attribute for the given attribute kind.
284 Attribute getFnAttribute(StringRef Kind) const {
285 return getAttribute(AttributeList::FunctionIndex, Kind);
288 /// \brief Return the stack alignment for the function.
289 unsigned getFnStackAlignment() const {
290 if (!hasFnAttribute(Attribute::StackAlignment))
292 return AttributeSets.getStackAlignment(AttributeList::FunctionIndex);
295 /// hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm
296 /// to use during code generation.
298 return getSubclassDataFromValue() & (1<<14);
300 const std::string &getGC() const;
301 void setGC(std::string Str);
304 /// @brief adds the attribute to the list of attributes.
305 void addAttribute(unsigned i, Attribute::AttrKind Kind);
307 /// @brief adds the attribute to the list of attributes.
308 void addAttribute(unsigned i, Attribute Attr);
310 /// @brief adds the attributes to the list of attributes.
311 void addAttributes(unsigned i, const AttrBuilder &Attrs);
313 /// @brief adds the attribute to the list of attributes for the given arg.
314 void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind);
316 /// @brief adds the attribute to the list of attributes for the given arg.
317 void addParamAttr(unsigned ArgNo, Attribute Attr);
319 /// @brief adds the attributes to the list of attributes for the given arg.
320 void addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs);
322 /// @brief removes the attribute from the list of attributes.
323 void removeAttribute(unsigned i, Attribute::AttrKind Kind);
325 /// @brief removes the attribute from the list of attributes.
326 void removeAttribute(unsigned i, StringRef Kind);
328 /// @brief removes the attributes from the list of attributes.
329 void removeAttributes(unsigned i, const AttrBuilder &Attrs);
331 /// @brief removes the attribute from the list of attributes.
332 void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind);
334 /// @brief removes the attribute from the list of attributes.
335 void removeParamAttr(unsigned ArgNo, StringRef Kind);
337 /// @brief removes the attribute from the list of attributes.
338 void removeParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs);
340 /// @brief check if an attributes is in the list of attributes.
341 bool hasAttribute(unsigned i, Attribute::AttrKind Kind) const {
342 return getAttributes().hasAttribute(i, Kind);
345 /// @brief check if an attributes is in the list of attributes.
346 bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const {
347 return getAttributes().hasParamAttribute(ArgNo, Kind);
350 /// @brief gets the attribute from the list of attributes.
351 Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const {
352 return AttributeSets.getAttribute(i, Kind);
355 /// @brief gets the attribute from the list of attributes.
356 Attribute getAttribute(unsigned i, StringRef Kind) const {
357 return AttributeSets.getAttribute(i, Kind);
360 /// @brief adds the dereferenceable attribute to the list of attributes.
361 void addDereferenceableAttr(unsigned i, uint64_t Bytes);
363 /// @brief adds the dereferenceable attribute to the list of attributes for
365 void addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes);
367 /// @brief adds the dereferenceable_or_null attribute to the list of
369 void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes);
371 /// @brief adds the dereferenceable_or_null attribute to the list of
372 /// attributes for the given arg.
373 void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes);
375 /// @brief Extract the alignment for a call or parameter (0=unknown).
376 unsigned getParamAlignment(unsigned ArgNo) const {
377 return AttributeSets.getParamAlignment(ArgNo);
380 /// @brief Extract the number of dereferenceable bytes for a call or
381 /// parameter (0=unknown).
382 /// @param i AttributeList index, referring to a return value or argument.
383 uint64_t getDereferenceableBytes(unsigned i) const {
384 return AttributeSets.getDereferenceableBytes(i);
387 /// @brief Extract the number of dereferenceable bytes for a parameter.
388 /// @param ArgNo Index of an argument, with 0 being the first function arg.
389 uint64_t getParamDereferenceableBytes(unsigned ArgNo) const {
390 return AttributeSets.getParamDereferenceableBytes(ArgNo);
393 /// @brief Extract the number of dereferenceable_or_null bytes for a call or
394 /// parameter (0=unknown).
395 /// @param i AttributeList index, referring to a return value or argument.
396 uint64_t getDereferenceableOrNullBytes(unsigned i) const {
397 return AttributeSets.getDereferenceableOrNullBytes(i);
400 /// @brief Extract the number of dereferenceable_or_null bytes for a
402 /// @param ArgNo AttributeList ArgNo, referring to an argument.
403 uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const {
404 return AttributeSets.getParamDereferenceableOrNullBytes(ArgNo);
407 /// @brief Determine if the function does not access memory.
408 bool doesNotAccessMemory() const {
409 return hasFnAttribute(Attribute::ReadNone);
411 void setDoesNotAccessMemory() {
412 addFnAttr(Attribute::ReadNone);
415 /// @brief Determine if the function does not access or only reads memory.
416 bool onlyReadsMemory() const {
417 return doesNotAccessMemory() || hasFnAttribute(Attribute::ReadOnly);
419 void setOnlyReadsMemory() {
420 addFnAttr(Attribute::ReadOnly);
423 /// @brief Determine if the function does not access or only writes memory.
424 bool doesNotReadMemory() const {
425 return doesNotAccessMemory() || hasFnAttribute(Attribute::WriteOnly);
427 void setDoesNotReadMemory() {
428 addFnAttr(Attribute::WriteOnly);
431 /// @brief Determine if the call can access memmory only using pointers based
432 /// on its arguments.
433 bool onlyAccessesArgMemory() const {
434 return hasFnAttribute(Attribute::ArgMemOnly);
436 void setOnlyAccessesArgMemory() { addFnAttr(Attribute::ArgMemOnly); }
438 /// @brief Determine if the function may only access memory that is
439 /// inaccessible from the IR.
440 bool onlyAccessesInaccessibleMemory() const {
441 return hasFnAttribute(Attribute::InaccessibleMemOnly);
443 void setOnlyAccessesInaccessibleMemory() {
444 addFnAttr(Attribute::InaccessibleMemOnly);
447 /// @brief Determine if the function may only access memory that is
448 /// either inaccessible from the IR or pointed to by its arguments.
449 bool onlyAccessesInaccessibleMemOrArgMem() const {
450 return hasFnAttribute(Attribute::InaccessibleMemOrArgMemOnly);
452 void setOnlyAccessesInaccessibleMemOrArgMem() {
453 addFnAttr(Attribute::InaccessibleMemOrArgMemOnly);
456 /// @brief Determine if the function cannot return.
457 bool doesNotReturn() const {
458 return hasFnAttribute(Attribute::NoReturn);
460 void setDoesNotReturn() {
461 addFnAttr(Attribute::NoReturn);
464 /// @brief Determine if the function cannot unwind.
465 bool doesNotThrow() const {
466 return hasFnAttribute(Attribute::NoUnwind);
468 void setDoesNotThrow() {
469 addFnAttr(Attribute::NoUnwind);
472 /// @brief Determine if the call cannot be duplicated.
473 bool cannotDuplicate() const {
474 return hasFnAttribute(Attribute::NoDuplicate);
476 void setCannotDuplicate() {
477 addFnAttr(Attribute::NoDuplicate);
480 /// @brief Determine if the call is convergent.
481 bool isConvergent() const {
482 return hasFnAttribute(Attribute::Convergent);
484 void setConvergent() {
485 addFnAttr(Attribute::Convergent);
487 void setNotConvergent() {
488 removeFnAttr(Attribute::Convergent);
491 /// @brief Determine if the call has sideeffects.
492 bool isSpeculatable() const {
493 return hasFnAttribute(Attribute::Speculatable);
495 void setSpeculatable() {
496 addFnAttr(Attribute::Speculatable);
499 /// Determine if the function is known not to recurse, directly or
501 bool doesNotRecurse() const {
502 return hasFnAttribute(Attribute::NoRecurse);
504 void setDoesNotRecurse() {
505 addFnAttr(Attribute::NoRecurse);
508 /// @brief True if the ABI mandates (or the user requested) that this
509 /// function be in a unwind table.
510 bool hasUWTable() const {
511 return hasFnAttribute(Attribute::UWTable);
513 void setHasUWTable() {
514 addFnAttr(Attribute::UWTable);
517 /// @brief True if this function needs an unwind table.
518 bool needsUnwindTableEntry() const {
519 return hasUWTable() || !doesNotThrow();
522 /// @brief Determine if the function returns a structure through first
523 /// or second pointer argument.
524 bool hasStructRetAttr() const {
525 return AttributeSets.hasParamAttribute(0, Attribute::StructRet) ||
526 AttributeSets.hasParamAttribute(1, Attribute::StructRet);
529 /// @brief Determine if the parameter or return value is marked with NoAlias
531 bool returnDoesNotAlias() const {
532 return AttributeSets.hasAttribute(AttributeList::ReturnIndex,
535 void setReturnDoesNotAlias() {
536 addAttribute(AttributeList::ReturnIndex, Attribute::NoAlias);
539 /// Optimize this function for minimum size (-Oz).
540 bool optForMinSize() const { return hasFnAttribute(Attribute::MinSize); }
542 /// Optimize this function for size (-Os) or minimum size (-Oz).
543 bool optForSize() const {
544 return hasFnAttribute(Attribute::OptimizeForSize) || optForMinSize();
547 /// copyAttributesFrom - copy all additional attributes (those not needed to
548 /// create a Function) from the Function Src to this one.
549 void copyAttributesFrom(const Function *Src);
551 /// deleteBody - This method deletes the body of the function, and converts
552 /// the linkage to external.
556 setLinkage(ExternalLinkage);
559 /// removeFromParent - This method unlinks 'this' from the containing module,
560 /// but does not delete it.
562 void removeFromParent();
564 /// eraseFromParent - This method unlinks 'this' from the containing module
567 void eraseFromParent();
569 /// Steal arguments from another function.
571 /// Drop this function's arguments and splice in the ones from \c Src.
572 /// Requires that this has no function body.
573 void stealArgumentListFrom(Function &Src);
575 /// Get the underlying elements of the Function... the basic block list is
576 /// empty for external functions.
578 const BasicBlockListType &getBasicBlockList() const { return BasicBlocks; }
579 BasicBlockListType &getBasicBlockList() { return BasicBlocks; }
581 static BasicBlockListType Function::*getSublistAccess(BasicBlock*) {
582 return &Function::BasicBlocks;
585 const BasicBlock &getEntryBlock() const { return front(); }
586 BasicBlock &getEntryBlock() { return front(); }
588 //===--------------------------------------------------------------------===//
589 // Symbol Table Accessing functions...
591 /// getSymbolTable() - Return the symbol table if any, otherwise nullptr.
593 inline ValueSymbolTable *getValueSymbolTable() { return SymTab.get(); }
594 inline const ValueSymbolTable *getValueSymbolTable() const {
598 //===--------------------------------------------------------------------===//
599 // BasicBlock iterator forwarding functions
601 iterator begin() { return BasicBlocks.begin(); }
602 const_iterator begin() const { return BasicBlocks.begin(); }
603 iterator end () { return BasicBlocks.end(); }
604 const_iterator end () const { return BasicBlocks.end(); }
606 size_t size() const { return BasicBlocks.size(); }
607 bool empty() const { return BasicBlocks.empty(); }
608 const BasicBlock &front() const { return BasicBlocks.front(); }
609 BasicBlock &front() { return BasicBlocks.front(); }
610 const BasicBlock &back() const { return BasicBlocks.back(); }
611 BasicBlock &back() { return BasicBlocks.back(); }
613 /// @name Function Argument Iteration
616 arg_iterator arg_begin() {
617 CheckLazyArguments();
620 const_arg_iterator arg_begin() const {
621 CheckLazyArguments();
625 arg_iterator arg_end() {
626 CheckLazyArguments();
627 return Arguments + NumArgs;
629 const_arg_iterator arg_end() const {
630 CheckLazyArguments();
631 return Arguments + NumArgs;
634 iterator_range<arg_iterator> args() {
635 return make_range(arg_begin(), arg_end());
637 iterator_range<const_arg_iterator> args() const {
638 return make_range(arg_begin(), arg_end());
643 size_t arg_size() const { return NumArgs; }
644 bool arg_empty() const { return arg_size() == 0; }
646 /// \brief Check whether this function has a personality function.
647 bool hasPersonalityFn() const {
648 return getSubclassDataFromValue() & (1<<3);
651 /// \brief Get the personality function associated with this function.
652 Constant *getPersonalityFn() const;
653 void setPersonalityFn(Constant *Fn);
655 /// \brief Check whether this function has prefix data.
656 bool hasPrefixData() const {
657 return getSubclassDataFromValue() & (1<<1);
660 /// \brief Get the prefix data associated with this function.
661 Constant *getPrefixData() const;
662 void setPrefixData(Constant *PrefixData);
664 /// \brief Check whether this function has prologue data.
665 bool hasPrologueData() const {
666 return getSubclassDataFromValue() & (1<<2);
669 /// \brief Get the prologue data associated with this function.
670 Constant *getPrologueData() const;
671 void setPrologueData(Constant *PrologueData);
673 /// Print the function to an output stream with an optional
674 /// AssemblyAnnotationWriter.
675 void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW = nullptr,
676 bool ShouldPreserveUseListOrder = false,
677 bool IsForDebug = false) const;
679 /// viewCFG - This function is meant for use from the debugger. You can just
680 /// say 'call F->viewCFG()' and a ghostview window should pop up from the
681 /// program, displaying the CFG of the current function with the code for each
682 /// basic block inside. This depends on there being a 'dot' and 'gv' program
685 void viewCFG() const;
687 /// viewCFGOnly - This function is meant for use from the debugger. It works
688 /// just like viewCFG, but it does not include the contents of basic blocks
689 /// into the nodes, just the label. If you are only interested in the CFG
690 /// this can make the graph smaller.
692 void viewCFGOnly() const;
694 /// Methods for support type inquiry through isa, cast, and dyn_cast:
695 static bool classof(const Value *V) {
696 return V->getValueID() == Value::FunctionVal;
699 /// dropAllReferences() - This method causes all the subinstructions to "let
700 /// go" of all references that they are maintaining. This allows one to
701 /// 'delete' a whole module at a time, even though there may be circular
702 /// references... first all references are dropped, and all use counts go to
703 /// zero. Then everything is deleted for real. Note that no operations are
704 /// valid on an object that has "dropped all references", except operator
707 /// Since no other object in the module can have references into the body of a
708 /// function, dropping all references deletes the entire body of the function,
709 /// including any contained basic blocks.
711 void dropAllReferences();
713 /// hasAddressTaken - returns true if there are any uses of this function
714 /// other than direct calls or invokes to it, or blockaddress expressions.
715 /// Optionally passes back an offending user for diagnostic purposes.
717 bool hasAddressTaken(const User** = nullptr) const;
719 /// isDefTriviallyDead - Return true if it is trivially safe to remove
720 /// this function definition from the module (because it isn't externally
721 /// visible, does not have its address taken, and has no callers). To make
722 /// this more accurate, call removeDeadConstantUsers first.
723 bool isDefTriviallyDead() const;
725 /// callsFunctionThatReturnsTwice - Return true if the function has a call to
726 /// setjmp or other function that gcc recognizes as "returning twice".
727 bool callsFunctionThatReturnsTwice() const;
729 /// \brief Set the attached subprogram.
731 /// Calls \a setMetadata() with \a LLVMContext::MD_dbg.
732 void setSubprogram(DISubprogram *SP);
734 /// \brief Get the attached subprogram.
736 /// Calls \a getMetadata() with \a LLVMContext::MD_dbg and casts the result
737 /// to \a DISubprogram.
738 DISubprogram *getSubprogram() const;
740 /// Returns true if we should emit debug info for profiling.
741 bool isDebugInfoForProfiling() const;
744 void allocHungoffUselist();
745 template<int Idx> void setHungoffOperand(Constant *C);
747 /// Shadow Value::setValueSubclassData with a private forwarding method so
748 /// that subclasses cannot accidentally use it.
749 void setValueSubclassData(unsigned short D) {
750 Value::setValueSubclassData(D);
752 void setValueSubclassDataBit(unsigned Bit, bool On);
756 struct OperandTraits<Function> : public HungoffOperandTraits<3> {};
758 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(Function, Value)
760 } // end namespace llvm
762 #endif // LLVM_IR_FUNCTION_H