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/Intrinsics.h"
34 #include "llvm/IR/OperandTraits.h"
35 #include "llvm/IR/SymbolTableListTraits.h"
36 #include "llvm/IR/Value.h"
37 #include "llvm/Support/Casting.h"
38 #include "llvm/Support/Compiler.h"
47 class AssemblyAnnotationWriter;
52 template <typename T> class Optional;
57 class Function : public GlobalObject, public ilist_node<Function> {
59 using BasicBlockListType = SymbolTableList<BasicBlock>;
61 // BasicBlock iterators...
62 using iterator = BasicBlockListType::iterator;
63 using const_iterator = BasicBlockListType::const_iterator;
65 using arg_iterator = Argument *;
66 using const_arg_iterator = const Argument *;
69 // Important things that make up a function!
70 BasicBlockListType BasicBlocks; ///< The basic blocks
71 mutable Argument *Arguments = nullptr; ///< The formal arguments
73 std::unique_ptr<ValueSymbolTable>
74 SymTab; ///< Symbol table of args/instructions
75 AttributeList AttributeSets; ///< Parameter attributes
80 * bit 0 : HasLazyArguments
81 * bit 1 : HasPrefixData
82 * bit 2 : HasPrologueData
83 * bit 3 : HasPersonalityFn
84 * bits 4-13 : CallingConvention
86 * bits 15 : [reserved]
89 /// Bits from GlobalObject::GlobalObjectSubclassData.
91 /// Whether this function is materializable.
92 IsMaterializableBit = 0,
95 friend class SymbolTableListTraits<Function>;
97 /// hasLazyArguments/CheckLazyArguments - The argument list of a function is
98 /// built on demand, so that the list isn't allocated until the first client
99 /// needs it. The hasLazyArguments predicate returns true if the arg list
100 /// hasn't been set up yet.
102 bool hasLazyArguments() const {
103 return getSubclassDataFromValue() & (1<<0);
107 void CheckLazyArguments() const {
108 if (hasLazyArguments())
109 BuildLazyArguments();
112 void BuildLazyArguments() const;
114 void clearArguments();
116 /// Function ctor - If the (optional) Module argument is specified, the
117 /// function is automatically inserted into the end of the function list for
120 Function(FunctionType *Ty, LinkageTypes Linkage,
121 const Twine &N = "", Module *M = nullptr);
124 Function(const Function&) = delete;
125 void operator=(const Function&) = delete;
128 static Function *Create(FunctionType *Ty, LinkageTypes Linkage,
129 const Twine &N = "", Module *M = nullptr) {
130 return new Function(Ty, Linkage, N, M);
133 // Provide fast operand accessors.
134 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
136 /// Returns the FunctionType for me.
137 FunctionType *getFunctionType() const {
138 return cast<FunctionType>(getValueType());
141 /// Returns the type of the ret val.
142 Type *getReturnType() const { return getFunctionType()->getReturnType(); }
144 /// getContext - Return a reference to the LLVMContext associated with this
146 LLVMContext &getContext() const;
148 /// isVarArg - Return true if this function takes a variable number of
150 bool isVarArg() const { return getFunctionType()->isVarArg(); }
152 bool isMaterializable() const {
153 return getGlobalObjectSubClassData() & (1 << IsMaterializableBit);
155 void setIsMaterializable(bool V) {
156 unsigned Mask = 1 << IsMaterializableBit;
157 setGlobalObjectSubClassData((~Mask & getGlobalObjectSubClassData()) |
161 /// getIntrinsicID - This method returns the ID number of the specified
162 /// function, or Intrinsic::not_intrinsic if the function is not an
163 /// intrinsic, or if the pointer is null. This value is always defined to be
164 /// zero to allow easy checking for whether a function is intrinsic or not.
165 /// The particular intrinsic functions which correspond to this value are
166 /// defined in llvm/Intrinsics.h.
167 Intrinsic::ID getIntrinsicID() const LLVM_READONLY { return IntID; }
169 /// isIntrinsic - Returns true if the function's name starts with "llvm.".
170 /// It's possible for this function to return true while getIntrinsicID()
171 /// returns Intrinsic::not_intrinsic!
172 bool isIntrinsic() const { return HasLLVMReservedName; }
174 static Intrinsic::ID lookupIntrinsicID(StringRef Name);
176 /// \brief Recalculate the ID for this function if it is an Intrinsic defined
177 /// in llvm/Intrinsics.h. Sets the intrinsic ID to Intrinsic::not_intrinsic
178 /// if the name of this function does not match an intrinsic in that header.
179 /// Note, this method does not need to be called directly, as it is called
180 /// from Value::setName() whenever the name of this function changes.
181 void recalculateIntrinsicID();
183 /// getCallingConv()/setCallingConv(CC) - These method get and set the
184 /// calling convention of this function. The enum values for the known
185 /// calling conventions are defined in CallingConv.h.
186 CallingConv::ID getCallingConv() const {
187 return static_cast<CallingConv::ID>((getSubclassDataFromValue() >> 4) &
190 void setCallingConv(CallingConv::ID CC) {
191 auto ID = static_cast<unsigned>(CC);
192 assert(!(ID & ~CallingConv::MaxID) && "Unsupported calling convention");
193 setValueSubclassData((getSubclassDataFromValue() & 0xc00f) | (ID << 4));
196 /// @brief Return the attribute list for this Function.
197 AttributeList getAttributes() const { return AttributeSets; }
199 /// @brief Set the attribute list for this Function.
200 void setAttributes(AttributeList Attrs) { AttributeSets = Attrs; }
202 /// @brief Add function attributes to this function.
203 void addFnAttr(Attribute::AttrKind Kind) {
204 addAttribute(AttributeList::FunctionIndex, Kind);
207 /// @brief Add function attributes to this function.
208 void addFnAttr(StringRef Kind, StringRef Val = StringRef()) {
209 addAttribute(AttributeList::FunctionIndex,
210 Attribute::get(getContext(), Kind, Val));
213 void addFnAttr(Attribute Attr) {
214 addAttribute(AttributeList::FunctionIndex, Attr);
217 /// @brief Remove function attributes from this function.
218 void removeFnAttr(Attribute::AttrKind Kind) {
219 removeAttribute(AttributeList::FunctionIndex, Kind);
222 /// @brief Remove function attribute from this function.
223 void removeFnAttr(StringRef Kind) {
224 setAttributes(getAttributes().removeAttribute(
225 getContext(), AttributeList::FunctionIndex, Kind));
228 /// \brief Set the entry count for this function.
230 /// Entry count is the number of times this function was executed based on
231 /// pgo data. \p Imports points to a set of GUIDs that needs to be imported
232 /// by the function for sample PGO, to enable the same inlines as the
233 /// profiled optimized binary.
234 void setEntryCount(uint64_t Count,
235 const DenseSet<GlobalValue::GUID> *Imports = nullptr);
237 /// \brief Get the entry count for this function.
239 /// Entry count is the number of times the function was executed based on
241 Optional<uint64_t> getEntryCount() const;
243 /// Returns the set of GUIDs that needs to be imported to the function for
244 /// sample PGO, to enable the same inlines as the profiled optimized binary.
245 DenseSet<GlobalValue::GUID> getImportGUIDs() const;
247 /// Set the section prefix for this function.
248 void setSectionPrefix(StringRef Prefix);
250 /// Get the section prefix for this function.
251 Optional<StringRef> getSectionPrefix() const;
253 /// @brief Return true if the function has the attribute.
254 bool hasFnAttribute(Attribute::AttrKind Kind) const {
255 return AttributeSets.hasFnAttribute(Kind);
257 bool hasFnAttribute(StringRef Kind) const {
258 return AttributeSets.hasFnAttribute(Kind);
261 /// @brief Return the attribute for the given attribute kind.
262 Attribute getFnAttribute(Attribute::AttrKind Kind) const {
263 return getAttribute(AttributeList::FunctionIndex, Kind);
265 Attribute getFnAttribute(StringRef Kind) const {
266 return getAttribute(AttributeList::FunctionIndex, Kind);
269 /// \brief Return the stack alignment for the function.
270 unsigned getFnStackAlignment() const {
271 if (!hasFnAttribute(Attribute::StackAlignment))
273 return AttributeSets.getStackAlignment(AttributeList::FunctionIndex);
276 /// hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm
277 /// to use during code generation.
279 return getSubclassDataFromValue() & (1<<14);
281 const std::string &getGC() const;
282 void setGC(std::string Str);
285 /// @brief adds the attribute to the list of attributes.
286 void addAttribute(unsigned i, Attribute::AttrKind Kind);
288 /// @brief adds the attribute to the list of attributes.
289 void addAttribute(unsigned i, Attribute Attr);
291 /// @brief adds the attributes to the list of attributes.
292 void addAttributes(unsigned i, const AttrBuilder &Attrs);
294 /// @brief adds the attribute to the list of attributes for the given arg.
295 void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind);
297 /// @brief adds the attribute to the list of attributes for the given arg.
298 void addParamAttr(unsigned ArgNo, Attribute Attr);
300 /// @brief adds the attributes to the list of attributes for the given arg.
301 void addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs);
303 /// @brief removes the attribute from the list of attributes.
304 void removeAttribute(unsigned i, Attribute::AttrKind Kind);
306 /// @brief removes the attribute from the list of attributes.
307 void removeAttribute(unsigned i, StringRef Kind);
309 /// @brief removes the attributes from the list of attributes.
310 void removeAttributes(unsigned i, const AttrBuilder &Attrs);
312 /// @brief removes the attribute from the list of attributes.
313 void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind);
315 /// @brief removes the attribute from the list of attributes.
316 void removeParamAttr(unsigned ArgNo, StringRef Kind);
318 /// @brief removes the attribute from the list of attributes.
319 void removeParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs);
321 /// @brief check if an attributes is in the list of attributes.
322 bool hasAttribute(unsigned i, Attribute::AttrKind Kind) const {
323 return getAttributes().hasAttribute(i, Kind);
326 /// @brief check if an attributes is in the list of attributes.
327 bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const {
328 return getAttributes().hasParamAttribute(ArgNo, Kind);
331 Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const {
332 return AttributeSets.getAttribute(i, Kind);
335 Attribute getAttribute(unsigned i, StringRef Kind) const {
336 return AttributeSets.getAttribute(i, Kind);
339 /// @brief adds the dereferenceable attribute to the list of attributes.
340 void addDereferenceableAttr(unsigned i, uint64_t Bytes);
342 /// @brief adds the dereferenceable attribute to the list of attributes for
344 void addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes);
346 /// @brief adds the dereferenceable_or_null attribute to the list of
348 void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes);
350 /// @brief adds the dereferenceable_or_null attribute to the list of
351 /// attributes for the given arg.
352 void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes);
354 /// @brief Extract the alignment for a call or parameter (0=unknown).
355 unsigned getParamAlignment(unsigned ArgNo) const {
356 return AttributeSets.getParamAlignment(ArgNo);
359 /// @brief Extract the number of dereferenceable bytes for a call or
360 /// parameter (0=unknown).
361 /// @param i AttributeList index, referring to a return value or argument.
362 uint64_t getDereferenceableBytes(unsigned i) const {
363 return AttributeSets.getDereferenceableBytes(i);
366 /// @brief Extract the number of dereferenceable bytes for a parameter.
367 /// @param ArgNo Index of an argument, with 0 being the first function arg.
368 uint64_t getParamDereferenceableBytes(unsigned ArgNo) const {
369 return AttributeSets.getParamDereferenceableBytes(ArgNo);
372 /// @brief Extract the number of dereferenceable_or_null bytes for a call or
373 /// parameter (0=unknown).
374 /// @param i AttributeList index, referring to a return value or argument.
375 uint64_t getDereferenceableOrNullBytes(unsigned i) const {
376 return AttributeSets.getDereferenceableOrNullBytes(i);
379 /// @brief Extract the number of dereferenceable_or_null bytes for a
381 /// @param ArgNo AttributeList ArgNo, referring to an argument.
382 uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const {
383 return AttributeSets.getParamDereferenceableOrNullBytes(ArgNo);
386 /// @brief Determine if the function does not access memory.
387 bool doesNotAccessMemory() const {
388 return hasFnAttribute(Attribute::ReadNone);
390 void setDoesNotAccessMemory() {
391 addFnAttr(Attribute::ReadNone);
394 /// @brief Determine if the function does not access or only reads memory.
395 bool onlyReadsMemory() const {
396 return doesNotAccessMemory() || hasFnAttribute(Attribute::ReadOnly);
398 void setOnlyReadsMemory() {
399 addFnAttr(Attribute::ReadOnly);
402 /// @brief Determine if the function does not access or only writes memory.
403 bool doesNotReadMemory() const {
404 return doesNotAccessMemory() || hasFnAttribute(Attribute::WriteOnly);
406 void setDoesNotReadMemory() {
407 addFnAttr(Attribute::WriteOnly);
410 /// @brief Determine if the call can access memmory only using pointers based
411 /// on its arguments.
412 bool onlyAccessesArgMemory() const {
413 return hasFnAttribute(Attribute::ArgMemOnly);
415 void setOnlyAccessesArgMemory() { addFnAttr(Attribute::ArgMemOnly); }
417 /// @brief Determine if the function may only access memory that is
418 /// inaccessible from the IR.
419 bool onlyAccessesInaccessibleMemory() const {
420 return hasFnAttribute(Attribute::InaccessibleMemOnly);
422 void setOnlyAccessesInaccessibleMemory() {
423 addFnAttr(Attribute::InaccessibleMemOnly);
426 /// @brief Determine if the function may only access memory that is
427 /// either inaccessible from the IR or pointed to by its arguments.
428 bool onlyAccessesInaccessibleMemOrArgMem() const {
429 return hasFnAttribute(Attribute::InaccessibleMemOrArgMemOnly);
431 void setOnlyAccessesInaccessibleMemOrArgMem() {
432 addFnAttr(Attribute::InaccessibleMemOrArgMemOnly);
435 /// @brief Determine if the function cannot return.
436 bool doesNotReturn() const {
437 return hasFnAttribute(Attribute::NoReturn);
439 void setDoesNotReturn() {
440 addFnAttr(Attribute::NoReturn);
443 /// @brief Determine if the function cannot unwind.
444 bool doesNotThrow() const {
445 return hasFnAttribute(Attribute::NoUnwind);
447 void setDoesNotThrow() {
448 addFnAttr(Attribute::NoUnwind);
451 /// @brief Determine if the call cannot be duplicated.
452 bool cannotDuplicate() const {
453 return hasFnAttribute(Attribute::NoDuplicate);
455 void setCannotDuplicate() {
456 addFnAttr(Attribute::NoDuplicate);
459 /// @brief Determine if the call is convergent.
460 bool isConvergent() const {
461 return hasFnAttribute(Attribute::Convergent);
463 void setConvergent() {
464 addFnAttr(Attribute::Convergent);
466 void setNotConvergent() {
467 removeFnAttr(Attribute::Convergent);
470 /// @brief Determine if the call has sideeffects.
471 bool isSpeculatable() const {
472 return hasFnAttribute(Attribute::Speculatable);
474 void setSpeculatable() {
475 addFnAttr(Attribute::Speculatable);
478 /// Determine if the function is known not to recurse, directly or
480 bool doesNotRecurse() const {
481 return hasFnAttribute(Attribute::NoRecurse);
483 void setDoesNotRecurse() {
484 addFnAttr(Attribute::NoRecurse);
487 /// @brief True if the ABI mandates (or the user requested) that this
488 /// function be in a unwind table.
489 bool hasUWTable() const {
490 return hasFnAttribute(Attribute::UWTable);
492 void setHasUWTable() {
493 addFnAttr(Attribute::UWTable);
496 /// @brief True if this function needs an unwind table.
497 bool needsUnwindTableEntry() const {
498 return hasUWTable() || !doesNotThrow();
501 /// @brief Determine if the function returns a structure through first
502 /// or second pointer argument.
503 bool hasStructRetAttr() const {
504 return AttributeSets.hasParamAttribute(0, Attribute::StructRet) ||
505 AttributeSets.hasParamAttribute(1, Attribute::StructRet);
508 /// @brief Determine if the parameter or return value is marked with NoAlias
510 bool returnDoesNotAlias() const {
511 return AttributeSets.hasAttribute(AttributeList::ReturnIndex,
514 void setReturnDoesNotAlias() {
515 addAttribute(AttributeList::ReturnIndex, Attribute::NoAlias);
518 /// Optimize this function for minimum size (-Oz).
519 bool optForMinSize() const { return hasFnAttribute(Attribute::MinSize); }
521 /// Optimize this function for size (-Os) or minimum size (-Oz).
522 bool optForSize() const {
523 return hasFnAttribute(Attribute::OptimizeForSize) || optForMinSize();
526 /// copyAttributesFrom - copy all additional attributes (those not needed to
527 /// create a Function) from the Function Src to this one.
528 void copyAttributesFrom(const Function *Src);
530 /// deleteBody - This method deletes the body of the function, and converts
531 /// the linkage to external.
535 setLinkage(ExternalLinkage);
538 /// removeFromParent - This method unlinks 'this' from the containing module,
539 /// but does not delete it.
541 void removeFromParent();
543 /// eraseFromParent - This method unlinks 'this' from the containing module
546 void eraseFromParent();
548 /// Steal arguments from another function.
550 /// Drop this function's arguments and splice in the ones from \c Src.
551 /// Requires that this has no function body.
552 void stealArgumentListFrom(Function &Src);
554 /// Get the underlying elements of the Function... the basic block list is
555 /// empty for external functions.
557 const BasicBlockListType &getBasicBlockList() const { return BasicBlocks; }
558 BasicBlockListType &getBasicBlockList() { return BasicBlocks; }
560 static BasicBlockListType Function::*getSublistAccess(BasicBlock*) {
561 return &Function::BasicBlocks;
564 const BasicBlock &getEntryBlock() const { return front(); }
565 BasicBlock &getEntryBlock() { return front(); }
567 //===--------------------------------------------------------------------===//
568 // Symbol Table Accessing functions...
570 /// getSymbolTable() - Return the symbol table if any, otherwise nullptr.
572 inline ValueSymbolTable *getValueSymbolTable() { return SymTab.get(); }
573 inline const ValueSymbolTable *getValueSymbolTable() const {
577 //===--------------------------------------------------------------------===//
578 // BasicBlock iterator forwarding functions
580 iterator begin() { return BasicBlocks.begin(); }
581 const_iterator begin() const { return BasicBlocks.begin(); }
582 iterator end () { return BasicBlocks.end(); }
583 const_iterator end () const { return BasicBlocks.end(); }
585 size_t size() const { return BasicBlocks.size(); }
586 bool empty() const { return BasicBlocks.empty(); }
587 const BasicBlock &front() const { return BasicBlocks.front(); }
588 BasicBlock &front() { return BasicBlocks.front(); }
589 const BasicBlock &back() const { return BasicBlocks.back(); }
590 BasicBlock &back() { return BasicBlocks.back(); }
592 /// @name Function Argument Iteration
595 arg_iterator arg_begin() {
596 CheckLazyArguments();
599 const_arg_iterator arg_begin() const {
600 CheckLazyArguments();
604 arg_iterator arg_end() {
605 CheckLazyArguments();
606 return Arguments + NumArgs;
608 const_arg_iterator arg_end() const {
609 CheckLazyArguments();
610 return Arguments + NumArgs;
613 iterator_range<arg_iterator> args() {
614 return make_range(arg_begin(), arg_end());
616 iterator_range<const_arg_iterator> args() const {
617 return make_range(arg_begin(), arg_end());
622 size_t arg_size() const { return NumArgs; }
623 bool arg_empty() const { return arg_size() == 0; }
625 /// \brief Check whether this function has a personality function.
626 bool hasPersonalityFn() const {
627 return getSubclassDataFromValue() & (1<<3);
630 /// \brief Get the personality function associated with this function.
631 Constant *getPersonalityFn() const;
632 void setPersonalityFn(Constant *Fn);
634 /// \brief Check whether this function has prefix data.
635 bool hasPrefixData() const {
636 return getSubclassDataFromValue() & (1<<1);
639 /// \brief Get the prefix data associated with this function.
640 Constant *getPrefixData() const;
641 void setPrefixData(Constant *PrefixData);
643 /// \brief Check whether this function has prologue data.
644 bool hasPrologueData() const {
645 return getSubclassDataFromValue() & (1<<2);
648 /// \brief Get the prologue data associated with this function.
649 Constant *getPrologueData() const;
650 void setPrologueData(Constant *PrologueData);
652 /// Print the function to an output stream with an optional
653 /// AssemblyAnnotationWriter.
654 void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW = nullptr,
655 bool ShouldPreserveUseListOrder = false,
656 bool IsForDebug = false) const;
658 /// viewCFG - This function is meant for use from the debugger. You can just
659 /// say 'call F->viewCFG()' and a ghostview window should pop up from the
660 /// program, displaying the CFG of the current function with the code for each
661 /// basic block inside. This depends on there being a 'dot' and 'gv' program
664 void viewCFG() const;
666 /// viewCFGOnly - This function is meant for use from the debugger. It works
667 /// just like viewCFG, but it does not include the contents of basic blocks
668 /// into the nodes, just the label. If you are only interested in the CFG
669 /// this can make the graph smaller.
671 void viewCFGOnly() const;
673 /// Methods for support type inquiry through isa, cast, and dyn_cast:
674 static bool classof(const Value *V) {
675 return V->getValueID() == Value::FunctionVal;
678 /// dropAllReferences() - This method causes all the subinstructions to "let
679 /// go" of all references that they are maintaining. This allows one to
680 /// 'delete' a whole module at a time, even though there may be circular
681 /// references... first all references are dropped, and all use counts go to
682 /// zero. Then everything is deleted for real. Note that no operations are
683 /// valid on an object that has "dropped all references", except operator
686 /// Since no other object in the module can have references into the body of a
687 /// function, dropping all references deletes the entire body of the function,
688 /// including any contained basic blocks.
690 void dropAllReferences();
692 /// hasAddressTaken - returns true if there are any uses of this function
693 /// other than direct calls or invokes to it, or blockaddress expressions.
694 /// Optionally passes back an offending user for diagnostic purposes.
696 bool hasAddressTaken(const User** = nullptr) const;
698 /// isDefTriviallyDead - Return true if it is trivially safe to remove
699 /// this function definition from the module (because it isn't externally
700 /// visible, does not have its address taken, and has no callers). To make
701 /// this more accurate, call removeDeadConstantUsers first.
702 bool isDefTriviallyDead() const;
704 /// callsFunctionThatReturnsTwice - Return true if the function has a call to
705 /// setjmp or other function that gcc recognizes as "returning twice".
706 bool callsFunctionThatReturnsTwice() const;
708 /// \brief Set the attached subprogram.
710 /// Calls \a setMetadata() with \a LLVMContext::MD_dbg.
711 void setSubprogram(DISubprogram *SP);
713 /// \brief Get the attached subprogram.
715 /// Calls \a getMetadata() with \a LLVMContext::MD_dbg and casts the result
716 /// to \a DISubprogram.
717 DISubprogram *getSubprogram() const;
719 /// Returns true if we should emit debug info for profiling.
720 bool isDebugInfoForProfiling() const;
723 void allocHungoffUselist();
724 template<int Idx> void setHungoffOperand(Constant *C);
726 /// Shadow Value::setValueSubclassData with a private forwarding method so
727 /// that subclasses cannot accidentally use it.
728 void setValueSubclassData(unsigned short D) {
729 Value::setValueSubclassData(D);
731 void setValueSubclassDataBit(unsigned Bit, bool On);
735 struct OperandTraits<Function> : public HungoffOperandTraits<3> {};
737 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(Function, Value)
739 } // end namespace llvm
741 #endif // LLVM_IR_FUNCTION_H