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