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