LLVM 23.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"
31#include "llvm/IR/GlobalValue.h"
34#include "llvm/IR/Value.h"
36#include <cassert>
37#include <cstddef>
38#include <cstdint>
39#include <memory>
40#include <string>
41
42namespace llvm {
43
44namespace Intrinsic {
45typedef unsigned ID;
46}
47
49class Constant;
50class ConstantRange;
51class DataLayout;
52struct DenormalMode;
53class DISubprogram;
54enum LibFunc : unsigned;
55class LLVMContext;
56class Module;
57class raw_ostream;
59class Type;
60class User;
63
64class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
65public:
67
68 // BasicBlock iterators...
71
74
75private:
76 constexpr static HungOffOperandsAllocMarker AllocMarker{};
77
78 // Important things that make up a function!
79 BasicBlockListType BasicBlocks; ///< The basic blocks
80
81 // Basic blocks need to get their number when added to a function.
82 friend void BasicBlock::setParent(Function *);
83 unsigned NextBlockNum = 0;
84 /// Epoch of block numbers. (Could be shrinked to uint8_t if required.)
85 unsigned BlockNumEpoch = 0;
86
87 mutable Argument *Arguments = nullptr; ///< The formal arguments
88 size_t NumArgs;
89 std::unique_ptr<ValueSymbolTable>
90 SymTab; ///< Symbol table of args/instructions
91 AttributeList AttributeSets; ///< Parameter attributes
92
93 /*
94 * Value::SubclassData
95 *
96 * bit 0 : HasLazyArguments
97 * bit 1 : HasPrefixData
98 * bit 2 : HasPrologueData
99 * bit 3 : HasPersonalityFn
100 * bits 4-13 : CallingConvention
101 * bits 14 : HasGC
102 * bits 15 : [reserved]
103 */
104
105 /// Bits from GlobalObject::GlobalObjectSubclassData.
106 enum {
107 /// Whether this function is materializable.
108 IsMaterializableBit = 0,
109 };
110
111 friend class SymbolTableListTraits<Function>;
112
113public:
114 /// hasLazyArguments/CheckLazyArguments - The argument list of a function is
115 /// built on demand, so that the list isn't allocated until the first client
116 /// needs it. The hasLazyArguments predicate returns true if the arg list
117 /// hasn't been set up yet.
118 bool hasLazyArguments() const {
119 return getSubclassDataFromValue() & (1<<0);
120 }
121
122 /// \see BasicBlock::convertToNewDbgValues.
123 void convertToNewDbgValues();
124
125 /// \see BasicBlock::convertFromNewDbgValues.
126 void convertFromNewDbgValues();
127
128private:
130
131 static constexpr LibFunc UnknownLibFunc = LibFunc(-1);
132
133 /// Cache for TLI::getLibFunc() result without prototype validation.
134 /// UnknownLibFunc if uninitialized. NotLibFunc if definitely not lib func.
135 /// Otherwise may be libfunc if prototype validation passes.
136 mutable LibFunc LibFuncCache = UnknownLibFunc;
137
138 void CheckLazyArguments() const {
139 if (hasLazyArguments())
140 BuildLazyArguments();
141 }
142
143 void BuildLazyArguments() const;
144
145 void clearArguments();
146
147 void deleteBodyImpl(bool ShouldDrop);
148
149 /// Function ctor - If the (optional) Module argument is specified, the
150 /// function is automatically inserted into the end of the function list for
151 /// the module.
152 ///
153 Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace,
154 const Twine &N = "", Module *M = nullptr);
155
156public:
157 Function(const Function&) = delete;
158 void operator=(const Function&) = delete;
159 ~Function();
160
161 // This is here to help easily convert from FunctionT * (Function * or
162 // MachineFunction *) in BlockFrequencyInfoImpl to Function * by calling
163 // FunctionT->getFunction().
164 const Function &getFunction() const { return *this; }
165
167 unsigned AddrSpace, const Twine &N = "",
168 Module *M = nullptr) {
169 return new (AllocMarker) Function(Ty, Linkage, AddrSpace, N, M);
170 }
171
172 // TODO: remove this once all users have been updated to pass an AddrSpace
174 const Twine &N = "", Module *M = nullptr) {
175 return new (AllocMarker)
176 Function(Ty, Linkage, static_cast<unsigned>(-1), N, M);
177 }
178
179 /// Creates a new function and attaches it to a module.
180 ///
181 /// Places the function in the program address space as specified
182 /// by the module's data layout.
183 static Function *Create(FunctionType *Ty, LinkageTypes Linkage,
184 const Twine &N, Module &M);
185
186 /// Creates a function with some attributes recorded in llvm.module.flags
187 /// and the LLVMContext applied.
188 ///
189 /// Use this when synthesizing new functions that need attributes that would
190 /// have been set by command line options.
191 ///
192 /// This function should not be called from backends or the LTO pipeline. If
193 /// it is called from one of those places, some default attributes will not be
194 /// applied to the function.
195 static Function *createWithDefaultAttr(FunctionType *Ty, LinkageTypes Linkage,
196 unsigned AddrSpace,
197 const Twine &N = "",
198 Module *M = nullptr);
199
200 // Provide fast operand accessors.
202
203 /// Returns the number of non-debug IR instructions in this function.
204 /// This is equivalent to the sum of the sizes of each basic block contained
205 /// within this function.
206 unsigned getInstructionCount() const;
207
208 /// Returns the FunctionType for me.
212
213 /// Returns the type of the ret val.
214 Type *getReturnType() const { return getFunctionType()->getReturnType(); }
215
216 /// getContext - Return a reference to the LLVMContext associated with this
217 /// function.
218 LLVMContext &getContext() const;
219
220 /// Get the data layout of the module this function belongs to.
221 ///
222 /// Requires the function to have a parent module.
223 const DataLayout &getDataLayout() const;
224
225 /// isVarArg - Return true if this function takes a variable number of
226 /// arguments.
227 bool isVarArg() const { return getFunctionType()->isVarArg(); }
228
229 bool isMaterializable() const {
230 return getGlobalObjectSubClassData() & (1 << IsMaterializableBit);
231 }
232 void setIsMaterializable(bool V) {
233 unsigned Mask = 1 << IsMaterializableBit;
235 (V ? Mask : 0u));
236 }
237
238 /// getIntrinsicID - This method returns the ID number of the specified
239 /// function, or Intrinsic::not_intrinsic if the function is not an
240 /// intrinsic, or if the pointer is null. This value is always defined to be
241 /// zero to allow easy checking for whether a function is intrinsic or not.
242 /// The particular intrinsic functions which correspond to this value are
243 /// defined in llvm/Intrinsics.h.
245
246 /// isIntrinsic - Returns true if the function's name starts with "llvm.".
247 /// It's possible for this function to return true while getIntrinsicID()
248 /// returns Intrinsic::not_intrinsic!
249 bool isIntrinsic() const { return HasLLVMReservedName; }
250
251 /// isTargetIntrinsic - Returns true if this function is an intrinsic and the
252 /// intrinsic is specific to a certain target. If this is not an intrinsic
253 /// or a generic intrinsic, false is returned.
254 bool isTargetIntrinsic() const;
255
256 /// Returns true if the function is one of the "Constrained Floating-Point
257 /// Intrinsics". Returns false if not, and returns false when
258 /// getIntrinsicID() returns Intrinsic::not_intrinsic.
259 bool isConstrainedFPIntrinsic() const;
260
261 /// Update internal caches that depend on the function name (such as the
262 /// intrinsic ID and libcall cache).
263 /// Note, this method does not need to be called directly, as it is called
264 /// from Value::setName() whenever the name of this function changes.
265 void updateAfterNameChange();
266
267 /// getCallingConv()/setCallingConv(CC) - These method get and set the
268 /// calling convention of this function. The enum values for the known
269 /// calling conventions are defined in CallingConv.h.
271 return static_cast<CallingConv::ID>((getSubclassDataFromValue() >> 4) &
273 }
275 auto ID = static_cast<unsigned>(CC);
276 assert(!(ID & ~CallingConv::MaxID) && "Unsupported calling convention");
277 setValueSubclassData((getSubclassDataFromValue() & 0xc00f) | (ID << 4));
278 }
279
280 /// Does it have a kernel calling convention?
281 bool hasKernelCallingConv() const {
282 switch (getCallingConv()) {
283 default:
284 return false;
288 return true;
289 }
290 }
291
293
294 /// Class to represent profile counts.
295 ///
296 /// This class represents both real and synthetic profile counts.
298 private:
299 uint64_t Count = 0;
301
302 public:
304 : Count(Count), PCT(PCT) {}
305 uint64_t getCount() const { return Count; }
306 ProfileCountType getType() const { return PCT; }
307 bool isSynthetic() const { return PCT == PCT_Synthetic; }
308 };
309
310 /// Set the entry count for this function.
311 ///
312 /// Entry count is the number of times this function was executed based on
313 /// pgo data. \p Imports points to a set of GUIDs that needs to
314 /// be imported by the function for sample PGO, to enable the same inlines as
315 /// the profiled optimized binary.
316 void setEntryCount(ProfileCount Count,
317 const DenseSet<GlobalValue::GUID> *Imports = nullptr);
318
319 /// A convenience wrapper for setting entry count
320 void setEntryCount(uint64_t Count, ProfileCountType Type = PCT_Real,
321 const DenseSet<GlobalValue::GUID> *Imports = nullptr);
322
323 /// Get the entry count for this function.
324 ///
325 /// Entry count is the number of times the function was executed.
326 /// When AllowSynthetic is false, only pgo_data will be returned.
327 std::optional<ProfileCount> getEntryCount(bool AllowSynthetic = false) const;
328
329 /// Return true if the function is annotated with profile data.
330 ///
331 /// Presence of entry counts from a profile run implies the function has
332 /// profile annotations. If IncludeSynthetic is false, only return true
333 /// when the profile data is real.
334 bool hasProfileData(bool IncludeSynthetic = false) const {
335 return getEntryCount(IncludeSynthetic).has_value();
336 }
337
338 /// Returns the set of GUIDs that needs to be imported to the function for
339 /// sample PGO, to enable the same inlines as the profiled optimized binary.
340 DenseSet<GlobalValue::GUID> getImportGUIDs() const;
341
342 /// hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm
343 /// to use during code generation.
344 bool hasGC() const {
345 return getSubclassDataFromValue() & (1<<14);
346 }
347 const std::string &getGC() const;
348 void setGC(std::string Str);
349 void clearGC();
350
351 /// Return the attribute list for this Function.
352 AttributeList getAttributes() const { return AttributeSets; }
353
354 /// Set the attribute list for this Function.
355 void setAttributes(AttributeList Attrs) { AttributeSets = Attrs; }
356
357 // TODO: remove non-AtIndex versions of these methods.
358 /// adds the attribute to the list of attributes.
359 void addAttributeAtIndex(unsigned i, Attribute Attr);
360
361 /// Add function attributes to this function.
362 void addFnAttr(Attribute::AttrKind Kind);
363
364 /// Add function attributes to this function.
365 void addFnAttr(StringRef Kind, StringRef Val = StringRef());
366
367 /// Add function attributes to this function.
368 void addFnAttr(Attribute Attr);
369
370 /// Add function attributes to this function.
371 void addFnAttrs(const AttrBuilder &Attrs);
372
373 /// Add return value attributes to this function.
374 void addRetAttr(Attribute::AttrKind Kind);
375
376 /// Add return value attributes to this function.
377 void addRetAttr(Attribute Attr);
378
379 /// Add return value attributes to this function.
380 void addRetAttrs(const AttrBuilder &Attrs);
381
382 /// adds the attribute to the list of attributes for the given arg.
383 void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind);
384
385 /// adds the attribute to the list of attributes for the given arg.
386 void addParamAttr(unsigned ArgNo, Attribute Attr);
387
388 /// adds the attributes to the list of attributes for the given arg.
389 void addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs);
390
391 /// removes the attribute from the list of attributes.
392 void removeAttributeAtIndex(unsigned i, Attribute::AttrKind Kind);
393
394 /// removes the attribute from the list of attributes.
395 void removeAttributeAtIndex(unsigned i, StringRef Kind);
396
397 /// Remove function attributes from this function.
398 void removeFnAttr(Attribute::AttrKind Kind);
399
400 /// Remove function attribute from this function.
401 void removeFnAttr(StringRef Kind);
402
403 void removeFnAttrs(const AttributeMask &Attrs);
404
405 /// removes the attribute from the return value list of attributes.
406 void removeRetAttr(Attribute::AttrKind Kind);
407
408 /// removes the attribute from the return value list of attributes.
409 void removeRetAttr(StringRef Kind);
410
411 /// removes the attributes from the return value list of attributes.
412 void removeRetAttrs(const AttributeMask &Attrs);
413
414 /// removes the attribute from the list of attributes.
415 void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind);
416
417 /// removes the attribute from the list of attributes.
418 void removeParamAttr(unsigned ArgNo, StringRef Kind);
419
420 /// removes the attribute from the list of attributes.
421 void removeParamAttrs(unsigned ArgNo, const AttributeMask &Attrs);
422
423 /// Return true if the function has the attribute.
424 bool hasFnAttribute(Attribute::AttrKind Kind) const;
425
426 /// Return true if the function has the attribute.
427 bool hasFnAttribute(StringRef Kind) const;
428
429 /// check if an attribute is in the list of attributes for the return value.
430 bool hasRetAttribute(Attribute::AttrKind Kind) const;
431
432 /// check if an attributes is in the list of attributes.
433 bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const;
434
435 /// Check if an attribute is in the list of attributes.
436 bool hasParamAttribute(unsigned ArgNo, StringRef Kind) const;
437
438 /// gets the attribute from the list of attributes.
439 Attribute getAttributeAtIndex(unsigned i, Attribute::AttrKind Kind) const;
440
441 /// gets the attribute from the list of attributes.
442 Attribute getAttributeAtIndex(unsigned i, StringRef Kind) const;
443
444 /// Check if attribute of the given kind is set at the given index.
445 bool hasAttributeAtIndex(unsigned Idx, Attribute::AttrKind Kind) const;
446
447 /// Return the attribute for the given attribute kind.
448 Attribute getFnAttribute(Attribute::AttrKind Kind) const;
449
450 /// Return the attribute for the given attribute kind.
451 Attribute getFnAttribute(StringRef Kind) const;
452
453 /// Return the attribute for the given attribute kind for the return value.
454 Attribute getRetAttribute(Attribute::AttrKind Kind) const;
455
456 /// For a string attribute \p Kind, parse attribute as an integer.
457 ///
458 /// \returns \p Default if attribute is not present.
459 ///
460 /// \returns \p Default if there is an error parsing the attribute integer,
461 /// and error is emitted to the LLVMContext
462 uint64_t getFnAttributeAsParsedInteger(StringRef Kind,
463 uint64_t Default = 0) const;
464
465 /// gets the specified attribute from the list of attributes.
466 Attribute getParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const;
467
468 /// Return the stack alignment for the function.
470 return AttributeSets.getFnStackAlignment();
471 }
472
473 /// Returns true if the function has ssp, sspstrong, or sspreq fn attrs.
474 bool hasStackProtectorFnAttr() const;
475
476 /// adds the dereferenceable attribute to the list of attributes for
477 /// the given arg.
478 void addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes);
479
480 /// adds the dereferenceable_or_null attribute to the list of
481 /// attributes for the given arg.
482 void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes);
483
484 /// adds the range attribute to the list of attributes for the return value.
485 void addRangeRetAttr(const ConstantRange &CR);
486
487 MaybeAlign getParamAlign(unsigned ArgNo) const {
488 return AttributeSets.getParamAlignment(ArgNo);
489 }
490
491 MaybeAlign getParamStackAlign(unsigned ArgNo) const {
492 return AttributeSets.getParamStackAlignment(ArgNo);
493 }
494
495 /// Extract the byval type for a parameter.
496 Type *getParamByValType(unsigned ArgNo) const {
497 return AttributeSets.getParamByValType(ArgNo);
498 }
499
500 /// Extract the sret type for a parameter.
501 Type *getParamStructRetType(unsigned ArgNo) const {
502 return AttributeSets.getParamStructRetType(ArgNo);
503 }
504
505 /// Extract the inalloca type for a parameter.
506 Type *getParamInAllocaType(unsigned ArgNo) const {
507 return AttributeSets.getParamInAllocaType(ArgNo);
508 }
509
510 /// Extract the byref type for a parameter.
511 Type *getParamByRefType(unsigned ArgNo) const {
512 return AttributeSets.getParamByRefType(ArgNo);
513 }
514
515 /// Extract the preallocated type for a parameter.
516 Type *getParamPreallocatedType(unsigned ArgNo) const {
517 return AttributeSets.getParamPreallocatedType(ArgNo);
518 }
519
520 /// Extract the number of dereferenceable bytes for a parameter.
521 /// @param ArgNo Index of an argument, with 0 being the first function arg.
523 return AttributeSets.getParamDereferenceableBytes(ArgNo);
524 }
525
526 /// Extract the number of dead_on_return bytes for a parameter.
527 /// @param ArgNo Index of an argument, with 0 being the first function arg.
528 DeadOnReturnInfo getDeadOnReturnInfo(unsigned ArgNo) const {
529 return AttributeSets.getDeadOnReturnInfo(ArgNo);
530 }
531
532 /// Extract the number of dereferenceable_or_null bytes for a
533 /// parameter.
534 /// @param ArgNo AttributeList ArgNo, referring to an argument.
536 return AttributeSets.getParamDereferenceableOrNullBytes(ArgNo);
537 }
538
539 /// Extract the nofpclass attribute for a parameter.
540 FPClassTest getParamNoFPClass(unsigned ArgNo) const {
541 return AttributeSets.getParamNoFPClass(ArgNo);
542 }
543
544 /// Determine if the function is presplit coroutine.
545 bool isPresplitCoroutine() const {
546 return hasFnAttribute(Attribute::PresplitCoroutine);
547 }
548 void setPresplitCoroutine() { addFnAttr(Attribute::PresplitCoroutine); }
549 void setSplittedCoroutine() { removeFnAttr(Attribute::PresplitCoroutine); }
550
552 return hasFnAttribute(Attribute::CoroDestroyOnlyWhenComplete);
553 }
555 addFnAttr(Attribute::CoroDestroyOnlyWhenComplete);
556 }
557
558 MemoryEffects getMemoryEffects() const;
560
561 /// Determine if the function does not access memory.
562 bool doesNotAccessMemory() const;
564
565 /// Determine if the function does not access or only reads memory.
566 bool onlyReadsMemory() const;
567 void setOnlyReadsMemory();
568
569 /// Determine if the function does not access or only writes memory.
570 bool onlyWritesMemory() const;
571 void setOnlyWritesMemory();
572
573 /// Determine if the call can access memory only using pointers based
574 /// on its arguments.
575 bool onlyAccessesArgMemory() const;
577
578 /// Determine if the function may only access memory that is
579 /// inaccessible from the IR.
580 bool onlyAccessesInaccessibleMemory() const;
582
583 /// Determine if the function may only access memory that is
584 /// either inaccessible from the IR or pointed to by its arguments.
585 bool onlyAccessesInaccessibleMemOrArgMem() const;
587
588 /// Determine if the function cannot return.
589 bool doesNotReturn() const {
590 return hasFnAttribute(Attribute::NoReturn);
591 }
593 addFnAttr(Attribute::NoReturn);
594 }
595
596 /// Determine if the function should not perform indirect branch tracking.
597 bool doesNoCfCheck() const { return hasFnAttribute(Attribute::NoCfCheck); }
598
599 /// Determine if the function cannot unwind.
600 bool doesNotThrow() const {
601 return hasFnAttribute(Attribute::NoUnwind);
602 }
604 addFnAttr(Attribute::NoUnwind);
605 }
606
607 /// Determine if the call cannot be duplicated.
608 bool cannotDuplicate() const {
609 return hasFnAttribute(Attribute::NoDuplicate);
610 }
612 addFnAttr(Attribute::NoDuplicate);
613 }
614
615 /// Determine if the call is convergent.
616 bool isConvergent() const {
617 return hasFnAttribute(Attribute::Convergent);
618 }
620 addFnAttr(Attribute::Convergent);
621 }
623 removeFnAttr(Attribute::Convergent);
624 }
625
626 /// Determine if the call has sideeffects.
627 bool isSpeculatable() const {
628 return hasFnAttribute(Attribute::Speculatable);
629 }
631 addFnAttr(Attribute::Speculatable);
632 }
633
634 /// Determine if the call might deallocate memory.
635 bool doesNotFreeMemory() const {
636 return onlyReadsMemory() || hasFnAttribute(Attribute::NoFree);
637 }
639 addFnAttr(Attribute::NoFree);
640 }
641
642 /// Determine if the call can synchroize with other threads
643 bool hasNoSync() const {
644 return hasFnAttribute(Attribute::NoSync);
645 }
646 void setNoSync() {
647 addFnAttr(Attribute::NoSync);
648 }
649
650 /// Determine if the function is known not to recurse, directly or
651 /// indirectly.
652 bool doesNotRecurse() const {
653 return hasFnAttribute(Attribute::NoRecurse);
654 }
656 addFnAttr(Attribute::NoRecurse);
657 }
658
659 /// Determine if the function is required to make forward progress.
660 bool mustProgress() const {
661 return hasFnAttribute(Attribute::MustProgress) ||
662 hasFnAttribute(Attribute::WillReturn);
663 }
664 void setMustProgress() { addFnAttr(Attribute::MustProgress); }
665
666 /// Determine if the function will return.
667 bool willReturn() const { return hasFnAttribute(Attribute::WillReturn); }
668 void setWillReturn() { addFnAttr(Attribute::WillReturn); }
669
670 /// Get what kind of unwind table entry to generate for this function.
672 return AttributeSets.getUWTableKind();
673 }
674
675 /// True if the ABI mandates (or the user requested) that this
676 /// function be in a unwind table.
677 bool hasUWTable() const {
679 }
681 if (K == UWTableKind::None)
682 removeFnAttr(Attribute::UWTable);
683 else
685 }
686 /// True if this function needs an unwind table.
688 return hasUWTable() || !doesNotThrow() || hasPersonalityFn();
689 }
690
691 /// Determine if the function returns a structure through first
692 /// or second pointer argument.
693 bool hasStructRetAttr() const {
694 return AttributeSets.hasParamAttr(0, Attribute::StructRet) ||
695 AttributeSets.hasParamAttr(1, Attribute::StructRet);
696 }
697
698 /// Determine if the parameter or return value is marked with NoAlias
699 /// attribute.
700 bool returnDoesNotAlias() const {
701 return AttributeSets.hasRetAttr(Attribute::NoAlias);
702 }
703 void setReturnDoesNotAlias() { addRetAttr(Attribute::NoAlias); }
704
705 /// Do not optimize this function (-O0).
706 bool hasOptNone() const { return hasFnAttribute(Attribute::OptimizeNone); }
707
708 /// Optimize this function for minimum size (-Oz).
709 bool hasMinSize() const { return hasFnAttribute(Attribute::MinSize); }
710
711 /// Optimize this function for size (-Os) or minimum size (-Oz).
712 bool hasOptSize() const {
713 return hasFnAttribute(Attribute::OptimizeForSize) || hasMinSize();
714 }
715
716 /// Returns the denormal handling type for the default rounding mode of the
717 /// function.
718 DenormalMode getDenormalMode(const fltSemantics &FPType) const;
719
720 /// Return the representational value of "denormal-fp-math". Code interested
721 /// in the semantics of the function should use getDenormalMode instead.
722 DenormalMode getDenormalModeRaw() const;
723
724 /// Return the representational value of "denormal-fp-math-f32". Code
725 /// interested in the semantics of the function should use getDenormalMode
726 /// instead.
727 DenormalMode getDenormalModeF32Raw() const;
728
729 /// copyAttributesFrom - copy all additional attributes (those not needed to
730 /// create a Function) from the Function Src to this one.
731 void copyAttributesFrom(const Function *Src);
732
733 /// deleteBody - This method deletes the body of the function, and converts
734 /// the linkage to external.
735 ///
736 void deleteBody() {
737 deleteBodyImpl(/*ShouldDrop=*/false);
739 }
740
741 /// removeFromParent - This method unlinks 'this' from the containing module,
742 /// but does not delete it.
743 ///
744 void removeFromParent();
745
746 /// eraseFromParent - This method unlinks 'this' from the containing module
747 /// and deletes it.
748 ///
749 void eraseFromParent();
750
751 /// Steal arguments from another function.
752 ///
753 /// Drop this function's arguments and splice in the ones from \c Src.
754 /// Requires that this has no function body.
755 void stealArgumentListFrom(Function &Src);
756
757 /// Insert \p BB in the basic block list at \p Position. \Returns an iterator
758 /// to the newly inserted BB.
760 Function::iterator FIt = BasicBlocks.insert(Position, BB);
761 return FIt;
762 }
763
764 /// Transfer all blocks from \p FromF to this function at \p ToIt.
765 void splice(Function::iterator ToIt, Function *FromF) {
766 splice(ToIt, FromF, FromF->begin(), FromF->end());
767 }
768
769 /// Transfer one BasicBlock from \p FromF at \p FromIt to this function
770 /// at \p ToIt.
771 void splice(Function::iterator ToIt, Function *FromF,
772 Function::iterator FromIt) {
773 auto FromItNext = std::next(FromIt);
774 // Single-element splice is a noop if destination == source.
775 if (ToIt == FromIt || ToIt == FromItNext)
776 return;
777 splice(ToIt, FromF, FromIt, FromItNext);
778 }
779
780 /// Transfer a range of basic blocks that belong to \p FromF from \p
781 /// FromBeginIt to \p FromEndIt, to this function at \p ToIt.
782 void splice(Function::iterator ToIt, Function *FromF,
783 Function::iterator FromBeginIt,
784 Function::iterator FromEndIt);
785
786 /// Erases a range of BasicBlocks from \p FromIt to (not including) \p ToIt.
787 /// \Returns \p ToIt.
789
790private:
791 // These need access to the underlying BB list.
794 template <class BB_t, class BB_i_t, class BI_t, class II_t>
795 friend class InstIterator;
797 friend class llvm::ilist_node_with_parent<llvm::BasicBlock, llvm::Function>;
798
799 /// Get the underlying elements of the Function... the basic block list is
800 /// empty for external functions.
801 ///
802 /// This is deliberately private because we have implemented an adequate set
803 /// of functions to modify the list, including Function::splice(),
804 /// Function::erase(), Function::insert() etc.
805 const BasicBlockListType &getBasicBlockList() const { return BasicBlocks; }
806 BasicBlockListType &getBasicBlockList() { return BasicBlocks; }
807
808 static BasicBlockListType Function::*getSublistAccess(BasicBlock*) {
809 return &Function::BasicBlocks;
810 }
811
812public:
813 const BasicBlock &getEntryBlock() const { return front(); }
815
816 //===--------------------------------------------------------------------===//
817 // Symbol Table Accessing functions...
818
819 /// getSymbolTable() - Return the symbol table if any, otherwise nullptr.
820 ///
821 inline ValueSymbolTable *getValueSymbolTable() { return SymTab.get(); }
822 inline const ValueSymbolTable *getValueSymbolTable() const {
823 return SymTab.get();
824 }
825
826 //===--------------------------------------------------------------------===//
827 // Block number functions
828
829 /// Return a value larger than the largest block number. Intended to allocate
830 /// a vector that is sufficiently large to hold all blocks indexed by their
831 /// number.
832 unsigned getMaxBlockNumber() const { return NextBlockNum; }
833
834 /// Renumber basic blocks into a dense value range starting from 0. Be aware
835 /// that other data structures and analyses (e.g., DominatorTree) may depend
836 /// on the value numbers and need to be updated or invalidated.
837 void renumberBlocks();
838
839 /// Return the "epoch" of current block numbers. This will return a different
840 /// value after every renumbering. The intention is: if something (e.g., an
841 /// analysis) uses block numbers, it also stores the number epoch and then
842 /// can assert later on that the epoch didn't change (indicating that the
843 /// numbering is still valid). If the epoch changed, blocks might have been
844 /// assigned new numbers and previous uses of the numbers needs to be
845 /// invalidated. This is solely intended as a debugging feature.
846 unsigned getBlockNumberEpoch() const { return BlockNumEpoch; }
847
848private:
849 /// Assert that all blocks have unique numbers within 0..NextBlockNum. This
850 /// has O(n) runtime complexity.
851 void validateBlockNumbers() const;
852
853public:
854 //===--------------------------------------------------------------------===//
855 // BasicBlock iterator forwarding functions
856 //
857 iterator begin() { return BasicBlocks.begin(); }
858 const_iterator begin() const { return BasicBlocks.begin(); }
859 iterator end () { return BasicBlocks.end(); }
860 const_iterator end () const { return BasicBlocks.end(); }
861
862 size_t size() const { return BasicBlocks.size(); }
863 bool empty() const { return BasicBlocks.empty(); }
864 const BasicBlock &front() const { return BasicBlocks.front(); }
865 BasicBlock &front() { return BasicBlocks.front(); }
866 const BasicBlock &back() const { return BasicBlocks.back(); }
867 BasicBlock &back() { return BasicBlocks.back(); }
868
869/// @name Function Argument Iteration
870/// @{
871
873 CheckLazyArguments();
874 return Arguments;
875 }
877 CheckLazyArguments();
878 return Arguments;
879 }
880
882 CheckLazyArguments();
883 return Arguments + NumArgs;
884 }
886 CheckLazyArguments();
887 return Arguments + NumArgs;
888 }
889
890 Argument* getArg(unsigned i) const {
891 assert (i < NumArgs && "getArg() out of range!");
892 CheckLazyArguments();
893 return Arguments + i;
894 }
895
902
903/// @}
904
905 size_t arg_size() const { return NumArgs; }
906 bool arg_empty() const { return arg_size() == 0; }
907
908 /// Check whether this function has a personality function.
909 bool hasPersonalityFn() const {
910 return getSubclassDataFromValue() & (1<<3);
911 }
912
913 /// Get the personality function associated with this function.
914 Constant *getPersonalityFn() const;
915 void setPersonalityFn(Constant *Fn);
916
917 /// Check whether this function has prefix data.
918 bool hasPrefixData() const {
919 return getSubclassDataFromValue() & (1<<1);
920 }
921
922 /// Get the prefix data associated with this function.
923 Constant *getPrefixData() const;
924 void setPrefixData(Constant *PrefixData);
925
926 /// Check whether this function has prologue data.
927 bool hasPrologueData() const {
928 return getSubclassDataFromValue() & (1<<2);
929 }
930
931 /// Get the prologue data associated with this function.
932 Constant *getPrologueData() const;
933 void setPrologueData(Constant *PrologueData);
934
935 /// Print the function to an output stream with an optional
936 /// AssemblyAnnotationWriter.
937 void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW = nullptr,
938 bool ShouldPreserveUseListOrder = false,
939 bool IsForDebug = false) const;
940
941 /// viewCFG - This function is meant for use from the debugger. You can just
942 /// say 'call F->viewCFG()' and a ghostview window should pop up from the
943 /// program, displaying the CFG of the current function with the code for each
944 /// basic block inside. This depends on there being a 'dot' and 'gv' program
945 /// in your path.
946 ///
947 void viewCFG() const;
948
949 /// viewCFG - This function is meant for use from the debugger. It works just
950 /// like viewCFG(), but generates the dot file with the given file name.
951 void viewCFG(const char *OutputFileName) const;
952
953 /// Extended form to print edge weights.
954 void viewCFG(bool ViewCFGOnly, const BlockFrequencyInfo *BFI,
955 const BranchProbabilityInfo *BPI,
956 const char *OutputFileName = nullptr) const;
957
958 /// viewCFGOnly - This function is meant for use from the debugger. It works
959 /// just like viewCFG, but it does not include the contents of basic blocks
960 /// into the nodes, just the label. If you are only interested in the CFG
961 /// this can make the graph smaller.
962 ///
963 void viewCFGOnly() const;
964
965 /// viewCFG - This function is meant for use from the debugger. It works just
966 /// like viewCFGOnly(), but generates the dot file with the given file name.
967 void viewCFGOnly(const char *OutputFileName) const;
968
969 /// Extended form to print edge weights.
970 void viewCFGOnly(const BlockFrequencyInfo *BFI,
971 const BranchProbabilityInfo *BPI) const;
972
973 /// Methods for support type inquiry through isa, cast, and dyn_cast:
974 static bool classof(const Value *V) {
975 return V->getValueID() == Value::FunctionVal;
976 }
977
978 /// dropAllReferences() - This method causes all the subinstructions to "let
979 /// go" of all references that they are maintaining. This allows one to
980 /// 'delete' a whole module at a time, even though there may be circular
981 /// references... first all references are dropped, and all use counts go to
982 /// zero. Then everything is deleted for real. Note that no operations are
983 /// valid on an object that has "dropped all references", except operator
984 /// delete.
985 ///
986 /// Since no other object in the module can have references into the body of a
987 /// function, dropping all references deletes the entire body of the function,
988 /// including any contained basic blocks.
989 ///
991 deleteBodyImpl(/*ShouldDrop=*/true);
992 }
993
994 /// hasAddressTaken - returns true if there are any uses of this function
995 /// other than direct calls or invokes to it, or blockaddress expressions.
996 /// Optionally passes back an offending user for diagnostic purposes,
997 /// ignores callback uses, assume like pointer annotation calls, references in
998 /// llvm.used and llvm.compiler.used variables, operand bundle
999 /// "clang.arc.attachedcall", and direct calls with a different call site
1000 /// signature (the function is implicitly casted).
1001 bool hasAddressTaken(const User ** = nullptr, bool IgnoreCallbackUses = false,
1002 bool IgnoreAssumeLikeCalls = true,
1003 bool IngoreLLVMUsed = false,
1004 bool IgnoreARCAttachedCall = false,
1005 bool IgnoreCastedDirectCall = false) const;
1006
1007 /// isDefTriviallyDead - Return true if it is trivially safe to remove
1008 /// this function definition from the module (because it isn't externally
1009 /// visible, does not have its address taken, and has no callers). To make
1010 /// this more accurate, call removeDeadConstantUsers first.
1011 bool isDefTriviallyDead() const;
1012
1013 /// callsFunctionThatReturnsTwice - Return true if the function has a call to
1014 /// setjmp or other function that gcc recognizes as "returning twice".
1015 bool callsFunctionThatReturnsTwice() const;
1016
1017 /// Set the attached subprogram.
1018 ///
1019 /// Calls \a setMetadata() with \a LLVMContext::MD_dbg.
1020 void setSubprogram(DISubprogram *SP);
1021
1022 /// Get the attached subprogram.
1023 ///
1024 /// Calls \a getMetadata() with \a LLVMContext::MD_dbg and casts the result
1025 /// to \a DISubprogram.
1026 DISubprogram *getSubprogram() const;
1027
1028 /// Returns true if we should emit debug info for profiling.
1029 bool shouldEmitDebugInfoForProfiling() const;
1030
1031 /// Check if null pointer dereferencing is considered undefined behavior for
1032 /// the function.
1033 /// Return value: false => null pointer dereference is undefined.
1034 /// Return value: true => null pointer dereference is not undefined.
1035 bool nullPointerIsDefined() const;
1036
1037 /// Returns the alignment of the given function.
1038 ///
1039 /// Note that this is the alignment of the code, not the alignment of a
1040 /// function pointer.
1042
1043 /// Sets the alignment attribute of the Function.
1045
1046 /// Sets the alignment attribute of the Function.
1047 ///
1048 /// This method will be deprecated as the alignment property should always be
1049 /// defined.
1051
1052 /// Return the value for vscale based on the vscale_range attribute or 0 when
1053 /// unknown.
1054 unsigned getVScaleValue() const;
1055
1056private:
1057 void allocHungoffUselist();
1058 template<int Idx> void setHungoffOperand(Constant *C);
1059
1060 /// Shadow Value::setValueSubclassData with a private forwarding method so
1061 /// that subclasses cannot accidentally use it.
1062 void setValueSubclassData(unsigned short D) {
1064 }
1065 void setValueSubclassDataBit(unsigned Bit, bool On);
1066};
1067
1068namespace CallingConv {
1069
1070// TODO: Need similar function for support of argument in position. General
1071// version on FunctionType + Attributes + CallingConv::ID?
1073} // namespace CallingConv
1074
1075/// Check whether null pointer dereferencing is considered undefined behavior
1076/// for a given function or an address space.
1077/// Null pointer access in non-zero address space is not considered undefined.
1078/// Return value: false => null pointer dereference is undefined.
1079/// Return value: true => null pointer dereference is not undefined.
1080LLVM_ABI bool NullPointerIsDefined(const Function *F, unsigned AS = 0);
1081
1082template <> struct OperandTraits<Function> : public HungoffOperandTraits {};
1083
1085
1086} // end namespace llvm
1087
1088#endif // LLVM_IR_FUNCTION_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
aarch64 promote const
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
This file contains the simple types necessary to represent the attributes associated with functions a...
static bool setDoesNotAccessMemory(Function &F)
static bool setMemoryEffects(Function &F, MemoryEffects ME)
static bool setOnlyAccessesInaccessibleMemOrArgMem(Function &F)
static bool setOnlyAccessesInaccessibleMemory(Function &F)
static bool setOnlyAccessesArgMemory(Function &F)
static bool setOnlyWritesMemory(Function &F)
static bool setOnlyReadsMemory(Function &F)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static void viewCFG(Function &F, const BlockFrequencyInfo *BFI, const BranchProbabilityInfo *BPI, uint64_t MaxFreq, bool CFGOnly=false)
#define LLVM_READNONE
Definition Compiler.h:315
#define LLVM_ABI
Definition Compiler.h:213
#define LLVM_READONLY
Definition Compiler.h:322
SmallVector< BasicBlock *, 8 > BasicBlockListType
Definition DDG.cpp:184
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&...Args)
DXIL Finalize Linkage
This file defines the DenseSet and SmallDenseSet classes.
#define F(x, y, z)
Definition MD5.cpp:54
II addRangeRetAttr(Range)
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
static Type * getValueType(Value *V)
Returns the type of the given value/instruction V.
This class represents an incoming formal argument to a Function.
Definition Argument.h:32
This class stores enough information to efficiently remove some attributes from an existing AttrBuild...
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:103
static LLVM_ABI Attribute getWithUWTableKind(LLVMContext &Context, UWTableKind Kind)
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition Attributes.h:122
LLVM Basic Block Representation.
Definition BasicBlock.h:62
const Instruction & back() const
Definition BasicBlock.h:495
friend void Instruction::removeFromParent()
friend BasicBlock::iterator Instruction::eraseFromParent()
const Instruction & front() const
Definition BasicBlock.h:493
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Analysis providing branch probability information.
This class represents a range of values.
This is an important base class in LLVM.
Definition Constant.h:43
Subprogram description. Uses SubclassData1.
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
Implements a dense probed hash-table based set.
Definition DenseSet.h:279
Class to represent function types.
uint64_t getCount() const
Definition Function.h:305
ProfileCount(uint64_t Count, ProfileCountType PCT)
Definition Function.h:303
ProfileCountType getType() const
Definition Function.h:306
void deleteBody()
deleteBody - This method deletes the body of the function, and converts the linkage to external.
Definition Function.h:736
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
Definition Function.cpp:639
const ValueSymbolTable * getValueSymbolTable() const
Definition Function.h:822
bool isConvergent() const
Determine if the call is convergent.
Definition Function.h:616
void setCoroDestroyOnlyWhenComplete()
Definition Function.h:554
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Definition Function.h:166
BasicBlock & getEntryBlock()
Definition Function.h:814
SymbolTableList< BasicBlock > BasicBlockListType
Definition Function.h:66
void setAlignment(MaybeAlign Align)
Sets the alignment attribute of the Function.
Definition Function.h:1050
void splice(Function::iterator ToIt, Function *FromF)
Transfer all blocks from FromF to this function at ToIt.
Definition Function.h:765
const BasicBlock & getEntryBlock() const
Definition Function.h:813
BasicBlockListType::iterator iterator
Definition Function.h:69
bool hasOptSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
Definition Function.h:712
Argument * arg_iterator
Definition Function.h:72
void splice(Function::iterator ToIt, Function *FromF, Function::iterator FromIt)
Transfer one BasicBlock from FromF at FromIt to this function at ToIt.
Definition Function.h:771
bool empty() const
Definition Function.h:863
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition Function.h:209
bool isMaterializable() const
Definition Function.h:229
MaybeAlign getAlign() const
Returns the alignment of the given function.
Definition Function.h:1041
MaybeAlign getFnStackAlign() const
Return the stack alignment for the function.
Definition Function.h:469
iterator_range< const_arg_iterator > args() const
Definition Function.h:899
bool arg_empty() const
Definition Function.h:906
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition Function.h:974
const BasicBlock & front() const
Definition Function.h:864
const_arg_iterator arg_end() const
Definition Function.h:885
const_arg_iterator arg_begin() const
Definition Function.h:876
bool mustProgress() const
Determine if the function is required to make forward progress.
Definition Function.h:660
bool returnDoesNotAlias() const
Determine if the parameter or return value is marked with NoAlias attribute.
Definition Function.h:700
bool cannotDuplicate() const
Determine if the call cannot be duplicated.
Definition Function.h:608
const BasicBlock & back() const
Definition Function.h:866
unsigned getMaxBlockNumber() const
Return a value larger than the largest block number.
Definition Function.h:832
void setWillReturn()
Definition Function.h:668
bool willReturn() const
Determine if the function will return.
Definition Function.h:667
iterator_range< arg_iterator > args()
Definition Function.h:896
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Definition Function.h:244
friend class TargetLibraryInfoImpl
Definition Function.h:129
bool doesNotRecurse() const
Determine if the function is known not to recurse, directly or indirectly.
Definition Function.h:652
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
Definition Function.h:709
void setDoesNotReturn()
Definition Function.h:592
bool doesNoCfCheck() const
Determine if the function should not perform indirect branch tracking.
Definition Function.h:597
void setIsMaterializable(bool V)
Definition Function.h:232
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const
Extract the number of dereferenceable bytes for a parameter.
Definition Function.h:522
bool isSpeculatable() const
Determine if the call has sideeffects.
Definition Function.h:627
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
Definition Function.h:344
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Definition Function.h:270
Type * getParamByValType(unsigned ArgNo) const
Extract the byval type for a parameter.
Definition Function.h:496
FPClassTest getParamNoFPClass(unsigned ArgNo) const
Extract the nofpclass attribute for a parameter.
Definition Function.h:540
bool hasPrefixData() const
Check whether this function has prefix data.
Definition Function.h:918
void setReturnDoesNotAlias()
Definition Function.h:703
bool hasPersonalityFn() const
Check whether this function has a personality function.
Definition Function.h:909
void addRetAttr(Attribute::AttrKind Kind)
Add return value attributes to this function.
Definition Function.cpp:655
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
Definition Function.h:173
AttributeList getAttributes() const
Return the attribute list for this Function.
Definition Function.h:352
void dropAllReferences()
dropAllReferences() - This method causes all the subinstructions to "letgo" of all references that th...
Definition Function.h:990
unsigned getBlockNumberEpoch() const
Return the "epoch" of current block numbers.
Definition Function.h:846
void setUWTableKind(UWTableKind K)
Definition Function.h:680
BasicBlockListType::const_iterator const_iterator
Definition Function.h:70
UWTableKind getUWTableKind() const
Get what kind of unwind table entry to generate for this function.
Definition Function.h:671
Type * getParamByRefType(unsigned ArgNo) const
Extract the byref type for a parameter.
Definition Function.h:511
bool hasNoSync() const
Determine if the call can synchroize with other threads.
Definition Function.h:643
bool doesNotThrow() const
Determine if the function cannot unwind.
Definition Function.h:600
arg_iterator arg_end()
Definition Function.h:881
const Function & getFunction() const
Definition Function.h:164
iterator begin()
Definition Function.h:857
const_iterator end() const
Definition Function.h:860
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Extract the number of dereferenceable_or_null bytes for a parameter.
Definition Function.h:535
void removeFnAttr(Attribute::AttrKind Kind)
Remove function attributes from this function.
Definition Function.cpp:687
arg_iterator arg_begin()
Definition Function.h:872
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
Definition Function.h:249
bool hasProfileData(bool IncludeSynthetic=false) const
Return true if the function is annotated with profile data.
Definition Function.h:334
const_iterator begin() const
Definition Function.h:858
void setConvergent()
Definition Function.h:619
void setPresplitCoroutine()
Definition Function.h:548
size_t size() const
Definition Function.h:862
void setAlignment(Align Align)
Sets the alignment attribute of the Function.
Definition Function.h:1044
MaybeAlign getParamAlign(unsigned ArgNo) const
Definition Function.h:487
void setSpeculatable()
Definition Function.h:630
ValueSymbolTable * getValueSymbolTable()
getSymbolTable() - Return the symbol table if any, otherwise nullptr.
Definition Function.h:821
bool hasOptNone() const
Do not optimize this function (-O0).
Definition Function.h:706
void setCannotDuplicate()
Definition Function.h:611
Type * getParamPreallocatedType(unsigned ArgNo) const
Extract the preallocated type for a parameter.
Definition Function.h:516
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
Definition Function.h:355
bool isPresplitCoroutine() const
Determine if the function is presplit coroutine.
Definition Function.h:545
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Definition Function.cpp:358
BasicBlock & back()
Definition Function.h:867
bool hasKernelCallingConv() const
Does it have a kernel calling convention?
Definition Function.h:281
bool hasStructRetAttr() const
Determine if the function returns a structure through first or second pointer argument.
Definition Function.h:693
Function::iterator insert(Function::iterator Position, BasicBlock *BB)
Insert BB in the basic block list at Position.
Definition Function.h:759
void setNotConvergent()
Definition Function.h:622
bool doesNotFreeMemory() const
Determine if the call might deallocate memory.
Definition Function.h:635
Type * getParamInAllocaType(unsigned ArgNo) const
Extract the inalloca type for a parameter.
Definition Function.h:506
bool doesNotReturn() const
Determine if the function cannot return.
Definition Function.h:589
friend class InstIterator
Definition Function.h:795
BasicBlock & front()
Definition Function.h:865
bool isCoroOnlyDestroyWhenComplete() const
Definition Function.h:551
std::optional< ProfileCount > getEntryCount(bool AllowSynthetic=false) const
Get the entry count for this function.
void setSplittedCoroutine()
Definition Function.h:549
MaybeAlign getParamStackAlign(unsigned ArgNo) const
Definition Function.h:491
size_t arg_size() const
Definition Function.h:905
void setNoSync()
Definition Function.h:646
bool hasUWTable() const
True if the ABI mandates (or the user requested) that this function be in a unwind table.
Definition Function.h:677
void operator=(const Function &)=delete
Type * getReturnType() const
Returns the type of the ret val.
Definition Function.h:214
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
Definition Function.h:687
bool hasLazyArguments() const
hasLazyArguments/CheckLazyArguments - The argument list of a function is built on demand,...
Definition Function.h:118
iterator end()
Definition Function.h:859
void setCallingConv(CallingConv::ID CC)
Definition Function.h:274
Function(const Function &)=delete
bool hasPrologueData() const
Check whether this function has prologue data.
Definition Function.h:927
const Argument * const_arg_iterator
Definition Function.h:73
DeadOnReturnInfo getDeadOnReturnInfo(unsigned ArgNo) const
Extract the number of dead_on_return bytes for a parameter.
Definition Function.h:528
Type * getParamStructRetType(unsigned ArgNo) const
Extract the sret type for a parameter.
Definition Function.h:501
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
void setDoesNotRecurse()
Definition Function.h:655
Argument * getArg(unsigned i) const
Definition Function.h:890
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
Definition Function.h:227
unsigned getInstructionCount() const
Returns the number of non-debug IR instructions in this function.
Definition Function.cpp:366
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
Definition Function.cpp:890
void setMustProgress()
Definition Function.h:664
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition Function.cpp:729
void setDoesNotFreeMemory()
Definition Function.h:638
void setDoesNotThrow()
Definition Function.h:603
MaybeAlign getAlign() const
Returns the alignment of the given variable or function.
LLVM_ABI void setAlignment(Align Align)
Sets the alignment attribute of the GlobalObject.
Definition Globals.cpp:145
GlobalObject(Type *Ty, ValueTy VTy, AllocInfo AllocInfo, LinkageTypes Linkage, const Twine &Name, unsigned AddressSpace=0)
void setGlobalObjectSubClassData(unsigned Val)
unsigned getGlobalObjectSubClassData() const
Intrinsic::ID IntID
The intrinsic ID for this subclass (which must be a Function).
unsigned HasLLVMReservedName
True if the function's name starts with "llvm.".
void setLinkage(LinkageTypes LT)
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition GlobalValue.h:52
@ ExternalLinkage
Externally visible function.
Definition GlobalValue.h:53
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
List that automatically updates parent links and symbol tables.
Implementation of the target library information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
This class provides a symbol table of name/value pairs.
LLVM Value Representation.
Definition Value.h:75
unsigned short getSubclassDataFromValue() const
Definition Value.h:889
void setValueSubclassData(unsigned short D)
Definition Value.h:890
An ilist node that can access its parent list.
Definition ilist_node.h:316
typename base_list_type::iterator iterator
Definition ilist.h:121
typename base_list_type::const_iterator const_iterator
Definition ilist.h:122
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This file defines the ilist_node class template, which is a convenient base class for creating classe...
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
CallingConv Namespace - This namespace contains an enum with a value for the well-known calling conve...
Definition CallingConv.h:21
LLVM_ABI LLVM_READNONE bool supportsNonVoidReturnType(CallingConv::ID CC)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ AMDGPU_KERNEL
Used for AMDGPU code object kernels.
@ MaxID
The highest possible ID. Must be some 2^k - 1.
@ SPIR_KERNEL
Used for SPIR kernel functions.
@ PTX_Kernel
Call to a PTX kernel. Passes all arguments in parameter space.
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
Definition ModRef.h:301
void erase(Container &C, ValueType V)
Wrapper function to remove a value from a container:
Definition STLExtras.h:2190
UWTableKind
Definition CodeGen.h:154
@ None
No unwind table requested.
Definition CodeGen.h:155
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
LLVM_ABI bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
FunctionAddr VTableAddr Count
Definition InstrProf.h:139
Function::ProfileCount ProfileCount
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
@ Default
The result values are uniform if and only if all operands are uniform.
Definition Uniformity.h:20
#define N
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
Represent subnormal handling kind for floating point instruction inputs and outputs.
HungoffOperandTraits - determine the allocation regime of the Use array when it is not a prefix to th...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition Alignment.h:106
Compile-time customization of User operands.
Definition User.h:42
Indicates this User has operands "hung off" in another allocation.
Definition User.h:57