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