File indexing completed on 2026-05-10 08:44:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef LLVM_IR_FUNCTION_H
0018 #define LLVM_IR_FUNCTION_H
0019
0020 #include "llvm/ADT/DenseSet.h"
0021 #include "llvm/ADT/StringRef.h"
0022 #include "llvm/ADT/Twine.h"
0023 #include "llvm/ADT/ilist_node.h"
0024 #include "llvm/ADT/iterator_range.h"
0025 #include "llvm/IR/Argument.h"
0026 #include "llvm/IR/Attributes.h"
0027 #include "llvm/IR/BasicBlock.h"
0028 #include "llvm/IR/CallingConv.h"
0029 #include "llvm/IR/DerivedTypes.h"
0030 #include "llvm/IR/GlobalObject.h"
0031 #include "llvm/IR/GlobalValue.h"
0032 #include "llvm/IR/OperandTraits.h"
0033 #include "llvm/IR/SymbolTableListTraits.h"
0034 #include "llvm/IR/Value.h"
0035 #include <cassert>
0036 #include <cstddef>
0037 #include <cstdint>
0038 #include <memory>
0039 #include <string>
0040
0041 namespace llvm {
0042
0043 namespace Intrinsic {
0044 typedef unsigned ID;
0045 }
0046
0047 class AssemblyAnnotationWriter;
0048 class Constant;
0049 class ConstantRange;
0050 class DataLayout;
0051 struct DenormalMode;
0052 class DISubprogram;
0053 enum LibFunc : unsigned;
0054 class LLVMContext;
0055 class Module;
0056 class raw_ostream;
0057 class TargetLibraryInfoImpl;
0058 class Type;
0059 class User;
0060 class BranchProbabilityInfo;
0061 class BlockFrequencyInfo;
0062
0063 class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
0064 public:
0065 using BasicBlockListType = SymbolTableList<BasicBlock>;
0066
0067
0068 using iterator = BasicBlockListType::iterator;
0069 using const_iterator = BasicBlockListType::const_iterator;
0070
0071 using arg_iterator = Argument *;
0072 using const_arg_iterator = const Argument *;
0073
0074 private:
0075 constexpr static HungOffOperandsAllocMarker AllocMarker{};
0076
0077
0078 BasicBlockListType BasicBlocks;
0079
0080
0081 friend void BasicBlock::setParent(Function *);
0082 unsigned NextBlockNum = 0;
0083
0084 unsigned BlockNumEpoch = 0;
0085
0086 mutable Argument *Arguments = nullptr;
0087 size_t NumArgs;
0088 std::unique_ptr<ValueSymbolTable>
0089 SymTab;
0090 AttributeList AttributeSets;
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105 enum {
0106
0107 IsMaterializableBit = 0,
0108 };
0109
0110 friend class SymbolTableListTraits<Function>;
0111
0112 public:
0113
0114
0115
0116 bool IsNewDbgInfoFormat;
0117
0118
0119
0120
0121
0122 bool hasLazyArguments() const {
0123 return getSubclassDataFromValue() & (1<<0);
0124 }
0125
0126
0127 void convertToNewDbgValues();
0128
0129
0130 void convertFromNewDbgValues();
0131
0132 void setIsNewDbgInfoFormat(bool NewVal);
0133 void setNewDbgInfoFormatFlag(bool NewVal);
0134
0135 private:
0136 friend class TargetLibraryInfoImpl;
0137
0138 static constexpr LibFunc UnknownLibFunc = LibFunc(-1);
0139
0140
0141
0142
0143 mutable LibFunc LibFuncCache = UnknownLibFunc;
0144
0145 void CheckLazyArguments() const {
0146 if (hasLazyArguments())
0147 BuildLazyArguments();
0148 }
0149
0150 void BuildLazyArguments() const;
0151
0152 void clearArguments();
0153
0154 void deleteBodyImpl(bool ShouldDrop);
0155
0156
0157
0158
0159
0160 Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace,
0161 const Twine &N = "", Module *M = nullptr);
0162
0163 public:
0164 Function(const Function&) = delete;
0165 void operator=(const Function&) = delete;
0166 ~Function();
0167
0168
0169
0170
0171 const Function &getFunction() const { return *this; }
0172
0173 static Function *Create(FunctionType *Ty, LinkageTypes Linkage,
0174 unsigned AddrSpace, const Twine &N = "",
0175 Module *M = nullptr) {
0176 return new (AllocMarker) Function(Ty, Linkage, AddrSpace, N, M);
0177 }
0178
0179
0180 static Function *Create(FunctionType *Ty, LinkageTypes Linkage,
0181 const Twine &N = "", Module *M = nullptr) {
0182 return new (AllocMarker)
0183 Function(Ty, Linkage, static_cast<unsigned>(-1), N, M);
0184 }
0185
0186
0187
0188
0189
0190 static Function *Create(FunctionType *Ty, LinkageTypes Linkage,
0191 const Twine &N, Module &M);
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202 static Function *createWithDefaultAttr(FunctionType *Ty, LinkageTypes Linkage,
0203 unsigned AddrSpace,
0204 const Twine &N = "",
0205 Module *M = nullptr);
0206
0207
0208 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
0209
0210
0211
0212
0213 unsigned getInstructionCount() const;
0214
0215
0216 FunctionType *getFunctionType() const {
0217 return cast<FunctionType>(getValueType());
0218 }
0219
0220
0221 Type *getReturnType() const { return getFunctionType()->getReturnType(); }
0222
0223
0224
0225 LLVMContext &getContext() const;
0226
0227
0228
0229
0230 const DataLayout &getDataLayout() const;
0231
0232
0233
0234 bool isVarArg() const { return getFunctionType()->isVarArg(); }
0235
0236 bool isMaterializable() const {
0237 return getGlobalObjectSubClassData() & (1 << IsMaterializableBit);
0238 }
0239 void setIsMaterializable(bool V) {
0240 unsigned Mask = 1 << IsMaterializableBit;
0241 setGlobalObjectSubClassData((~Mask & getGlobalObjectSubClassData()) |
0242 (V ? Mask : 0u));
0243 }
0244
0245
0246
0247
0248
0249
0250
0251 Intrinsic::ID getIntrinsicID() const LLVM_READONLY { return IntID; }
0252
0253
0254
0255
0256 bool isIntrinsic() const { return HasLLVMReservedName; }
0257
0258
0259
0260
0261 bool isTargetIntrinsic() const;
0262
0263
0264
0265
0266 bool isConstrainedFPIntrinsic() const;
0267
0268
0269
0270
0271
0272 void updateAfterNameChange();
0273
0274
0275
0276
0277 CallingConv::ID getCallingConv() const {
0278 return static_cast<CallingConv::ID>((getSubclassDataFromValue() >> 4) &
0279 CallingConv::MaxID);
0280 }
0281 void setCallingConv(CallingConv::ID CC) {
0282 auto ID = static_cast<unsigned>(CC);
0283 assert(!(ID & ~CallingConv::MaxID) && "Unsupported calling convention");
0284 setValueSubclassData((getSubclassDataFromValue() & 0xc00f) | (ID << 4));
0285 }
0286
0287 enum ProfileCountType { PCT_Real, PCT_Synthetic };
0288
0289
0290
0291
0292 class ProfileCount {
0293 private:
0294 uint64_t Count = 0;
0295 ProfileCountType PCT = PCT_Real;
0296
0297 public:
0298 ProfileCount(uint64_t Count, ProfileCountType PCT)
0299 : Count(Count), PCT(PCT) {}
0300 uint64_t getCount() const { return Count; }
0301 ProfileCountType getType() const { return PCT; }
0302 bool isSynthetic() const { return PCT == PCT_Synthetic; }
0303 };
0304
0305
0306
0307
0308
0309
0310
0311 void setEntryCount(ProfileCount Count,
0312 const DenseSet<GlobalValue::GUID> *Imports = nullptr);
0313
0314
0315 void setEntryCount(uint64_t Count, ProfileCountType Type = PCT_Real,
0316 const DenseSet<GlobalValue::GUID> *Imports = nullptr);
0317
0318
0319
0320
0321
0322 std::optional<ProfileCount> getEntryCount(bool AllowSynthetic = false) const;
0323
0324
0325
0326
0327
0328
0329 bool hasProfileData(bool IncludeSynthetic = false) const {
0330 return getEntryCount(IncludeSynthetic).has_value();
0331 }
0332
0333
0334
0335 DenseSet<GlobalValue::GUID> getImportGUIDs() const;
0336
0337
0338 void setSectionPrefix(StringRef Prefix);
0339
0340
0341 std::optional<StringRef> getSectionPrefix() const;
0342
0343
0344
0345 bool hasGC() const {
0346 return getSubclassDataFromValue() & (1<<14);
0347 }
0348 const std::string &getGC() const;
0349 void setGC(std::string Str);
0350 void clearGC();
0351
0352
0353 AttributeList getAttributes() const { return AttributeSets; }
0354
0355
0356 void setAttributes(AttributeList Attrs) { AttributeSets = Attrs; }
0357
0358
0359
0360 void addAttributeAtIndex(unsigned i, Attribute Attr);
0361
0362
0363 void addFnAttr(Attribute::AttrKind Kind);
0364
0365
0366 void addFnAttr(StringRef Kind, StringRef Val = StringRef());
0367
0368
0369 void addFnAttr(Attribute Attr);
0370
0371
0372 void addFnAttrs(const AttrBuilder &Attrs);
0373
0374
0375 void addRetAttr(Attribute::AttrKind Kind);
0376
0377
0378 void addRetAttr(Attribute Attr);
0379
0380
0381 void addRetAttrs(const AttrBuilder &Attrs);
0382
0383
0384 void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind);
0385
0386
0387 void addParamAttr(unsigned ArgNo, Attribute Attr);
0388
0389
0390 void addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs);
0391
0392
0393 void removeAttributeAtIndex(unsigned i, Attribute::AttrKind Kind);
0394
0395
0396 void removeAttributeAtIndex(unsigned i, StringRef Kind);
0397
0398
0399 void removeFnAttr(Attribute::AttrKind Kind);
0400
0401
0402 void removeFnAttr(StringRef Kind);
0403
0404 void removeFnAttrs(const AttributeMask &Attrs);
0405
0406
0407 void removeRetAttr(Attribute::AttrKind Kind);
0408
0409
0410 void removeRetAttr(StringRef Kind);
0411
0412
0413 void removeRetAttrs(const AttributeMask &Attrs);
0414
0415
0416 void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind);
0417
0418
0419 void removeParamAttr(unsigned ArgNo, StringRef Kind);
0420
0421
0422 void removeParamAttrs(unsigned ArgNo, const AttributeMask &Attrs);
0423
0424
0425 bool hasFnAttribute(Attribute::AttrKind Kind) const;
0426
0427
0428 bool hasFnAttribute(StringRef Kind) const;
0429
0430
0431 bool hasRetAttribute(Attribute::AttrKind Kind) const;
0432
0433
0434 bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const;
0435
0436
0437 bool hasParamAttribute(unsigned ArgNo, StringRef Kind) const;
0438
0439
0440 Attribute getAttributeAtIndex(unsigned i, Attribute::AttrKind Kind) const;
0441
0442
0443 Attribute getAttributeAtIndex(unsigned i, StringRef Kind) const;
0444
0445
0446 bool hasAttributeAtIndex(unsigned Idx, Attribute::AttrKind Kind) const;
0447
0448
0449 Attribute getFnAttribute(Attribute::AttrKind Kind) const;
0450
0451
0452 Attribute getFnAttribute(StringRef Kind) const;
0453
0454
0455 Attribute getRetAttribute(Attribute::AttrKind Kind) const;
0456
0457
0458
0459
0460
0461
0462
0463 uint64_t getFnAttributeAsParsedInteger(StringRef Kind,
0464 uint64_t Default = 0) const;
0465
0466
0467 Attribute getParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const;
0468
0469
0470 MaybeAlign getFnStackAlign() const {
0471 return AttributeSets.getFnStackAlignment();
0472 }
0473
0474
0475 bool hasStackProtectorFnAttr() const;
0476
0477
0478
0479 void addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes);
0480
0481
0482
0483 void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes);
0484
0485
0486 void addRangeRetAttr(const ConstantRange &CR);
0487
0488 MaybeAlign getParamAlign(unsigned ArgNo) const {
0489 return AttributeSets.getParamAlignment(ArgNo);
0490 }
0491
0492 MaybeAlign getParamStackAlign(unsigned ArgNo) const {
0493 return AttributeSets.getParamStackAlignment(ArgNo);
0494 }
0495
0496
0497 Type *getParamByValType(unsigned ArgNo) const {
0498 return AttributeSets.getParamByValType(ArgNo);
0499 }
0500
0501
0502 Type *getParamStructRetType(unsigned ArgNo) const {
0503 return AttributeSets.getParamStructRetType(ArgNo);
0504 }
0505
0506
0507 Type *getParamInAllocaType(unsigned ArgNo) const {
0508 return AttributeSets.getParamInAllocaType(ArgNo);
0509 }
0510
0511
0512 Type *getParamByRefType(unsigned ArgNo) const {
0513 return AttributeSets.getParamByRefType(ArgNo);
0514 }
0515
0516
0517 Type *getParamPreallocatedType(unsigned ArgNo) const {
0518 return AttributeSets.getParamPreallocatedType(ArgNo);
0519 }
0520
0521
0522
0523 uint64_t getParamDereferenceableBytes(unsigned ArgNo) const {
0524 return AttributeSets.getParamDereferenceableBytes(ArgNo);
0525 }
0526
0527
0528
0529
0530 uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const {
0531 return AttributeSets.getParamDereferenceableOrNullBytes(ArgNo);
0532 }
0533
0534
0535 FPClassTest getParamNoFPClass(unsigned ArgNo) const {
0536 return AttributeSets.getParamNoFPClass(ArgNo);
0537 }
0538
0539
0540 bool isPresplitCoroutine() const {
0541 return hasFnAttribute(Attribute::PresplitCoroutine);
0542 }
0543 void setPresplitCoroutine() { addFnAttr(Attribute::PresplitCoroutine); }
0544 void setSplittedCoroutine() { removeFnAttr(Attribute::PresplitCoroutine); }
0545
0546 bool isCoroOnlyDestroyWhenComplete() const {
0547 return hasFnAttribute(Attribute::CoroDestroyOnlyWhenComplete);
0548 }
0549 void setCoroDestroyOnlyWhenComplete() {
0550 addFnAttr(Attribute::CoroDestroyOnlyWhenComplete);
0551 }
0552
0553 MemoryEffects getMemoryEffects() const;
0554 void setMemoryEffects(MemoryEffects ME);
0555
0556
0557 bool doesNotAccessMemory() const;
0558 void setDoesNotAccessMemory();
0559
0560
0561 bool onlyReadsMemory() const;
0562 void setOnlyReadsMemory();
0563
0564
0565 bool onlyWritesMemory() const;
0566 void setOnlyWritesMemory();
0567
0568
0569
0570 bool onlyAccessesArgMemory() const;
0571 void setOnlyAccessesArgMemory();
0572
0573
0574
0575 bool onlyAccessesInaccessibleMemory() const;
0576 void setOnlyAccessesInaccessibleMemory();
0577
0578
0579
0580 bool onlyAccessesInaccessibleMemOrArgMem() const;
0581 void setOnlyAccessesInaccessibleMemOrArgMem();
0582
0583
0584 bool doesNotReturn() const {
0585 return hasFnAttribute(Attribute::NoReturn);
0586 }
0587 void setDoesNotReturn() {
0588 addFnAttr(Attribute::NoReturn);
0589 }
0590
0591
0592 bool doesNoCfCheck() const { return hasFnAttribute(Attribute::NoCfCheck); }
0593
0594
0595 bool doesNotThrow() const {
0596 return hasFnAttribute(Attribute::NoUnwind);
0597 }
0598 void setDoesNotThrow() {
0599 addFnAttr(Attribute::NoUnwind);
0600 }
0601
0602
0603 bool cannotDuplicate() const {
0604 return hasFnAttribute(Attribute::NoDuplicate);
0605 }
0606 void setCannotDuplicate() {
0607 addFnAttr(Attribute::NoDuplicate);
0608 }
0609
0610
0611 bool isConvergent() const {
0612 return hasFnAttribute(Attribute::Convergent);
0613 }
0614 void setConvergent() {
0615 addFnAttr(Attribute::Convergent);
0616 }
0617 void setNotConvergent() {
0618 removeFnAttr(Attribute::Convergent);
0619 }
0620
0621
0622 bool isSpeculatable() const {
0623 return hasFnAttribute(Attribute::Speculatable);
0624 }
0625 void setSpeculatable() {
0626 addFnAttr(Attribute::Speculatable);
0627 }
0628
0629
0630 bool doesNotFreeMemory() const {
0631 return onlyReadsMemory() || hasFnAttribute(Attribute::NoFree);
0632 }
0633 void setDoesNotFreeMemory() {
0634 addFnAttr(Attribute::NoFree);
0635 }
0636
0637
0638 bool hasNoSync() const {
0639 return hasFnAttribute(Attribute::NoSync);
0640 }
0641 void setNoSync() {
0642 addFnAttr(Attribute::NoSync);
0643 }
0644
0645
0646
0647 bool doesNotRecurse() const {
0648 return hasFnAttribute(Attribute::NoRecurse);
0649 }
0650 void setDoesNotRecurse() {
0651 addFnAttr(Attribute::NoRecurse);
0652 }
0653
0654
0655 bool mustProgress() const {
0656 return hasFnAttribute(Attribute::MustProgress) ||
0657 hasFnAttribute(Attribute::WillReturn);
0658 }
0659 void setMustProgress() { addFnAttr(Attribute::MustProgress); }
0660
0661
0662 bool willReturn() const { return hasFnAttribute(Attribute::WillReturn); }
0663 void setWillReturn() { addFnAttr(Attribute::WillReturn); }
0664
0665
0666 UWTableKind getUWTableKind() const {
0667 return AttributeSets.getUWTableKind();
0668 }
0669
0670
0671
0672 bool hasUWTable() const {
0673 return getUWTableKind() != UWTableKind::None;
0674 }
0675 void setUWTableKind(UWTableKind K) {
0676 if (K == UWTableKind::None)
0677 removeFnAttr(Attribute::UWTable);
0678 else
0679 addFnAttr(Attribute::getWithUWTableKind(getContext(), K));
0680 }
0681
0682 bool needsUnwindTableEntry() const {
0683 return hasUWTable() || !doesNotThrow() || hasPersonalityFn();
0684 }
0685
0686
0687
0688 bool hasStructRetAttr() const {
0689 return AttributeSets.hasParamAttr(0, Attribute::StructRet) ||
0690 AttributeSets.hasParamAttr(1, Attribute::StructRet);
0691 }
0692
0693
0694
0695 bool returnDoesNotAlias() const {
0696 return AttributeSets.hasRetAttr(Attribute::NoAlias);
0697 }
0698 void setReturnDoesNotAlias() { addRetAttr(Attribute::NoAlias); }
0699
0700
0701 bool hasOptNone() const { return hasFnAttribute(Attribute::OptimizeNone); }
0702
0703
0704 bool hasMinSize() const { return hasFnAttribute(Attribute::MinSize); }
0705
0706
0707 bool hasOptSize() const {
0708 return hasFnAttribute(Attribute::OptimizeForSize) || hasMinSize();
0709 }
0710
0711
0712
0713 DenormalMode getDenormalMode(const fltSemantics &FPType) const;
0714
0715
0716
0717 DenormalMode getDenormalModeRaw() const;
0718
0719
0720
0721
0722 DenormalMode getDenormalModeF32Raw() const;
0723
0724
0725
0726 void copyAttributesFrom(const Function *Src);
0727
0728
0729
0730
0731 void deleteBody() {
0732 deleteBodyImpl(false);
0733 setLinkage(ExternalLinkage);
0734 }
0735
0736
0737
0738
0739 void removeFromParent();
0740
0741
0742
0743
0744 void eraseFromParent();
0745
0746
0747
0748
0749
0750 void stealArgumentListFrom(Function &Src);
0751
0752
0753
0754 Function::iterator insert(Function::iterator Position, BasicBlock *BB) {
0755 Function::iterator FIt = BasicBlocks.insert(Position, BB);
0756 BB->setIsNewDbgInfoFormat(IsNewDbgInfoFormat);
0757 return FIt;
0758 }
0759
0760
0761 void splice(Function::iterator ToIt, Function *FromF) {
0762 splice(ToIt, FromF, FromF->begin(), FromF->end());
0763 }
0764
0765
0766
0767 void splice(Function::iterator ToIt, Function *FromF,
0768 Function::iterator FromIt) {
0769 auto FromItNext = std::next(FromIt);
0770
0771 if (ToIt == FromIt || ToIt == FromItNext)
0772 return;
0773 splice(ToIt, FromF, FromIt, FromItNext);
0774 }
0775
0776
0777
0778 void splice(Function::iterator ToIt, Function *FromF,
0779 Function::iterator FromBeginIt,
0780 Function::iterator FromEndIt);
0781
0782
0783
0784 Function::iterator erase(Function::iterator FromIt, Function::iterator ToIt);
0785
0786 private:
0787
0788 friend void BasicBlock::removeFromParent();
0789 friend iplist<BasicBlock>::iterator BasicBlock::eraseFromParent();
0790 template <class BB_t, class BB_i_t, class BI_t, class II_t>
0791 friend class InstIterator;
0792 friend class llvm::SymbolTableListTraits<llvm::BasicBlock>;
0793 friend class llvm::ilist_node_with_parent<llvm::BasicBlock, llvm::Function>;
0794
0795
0796
0797
0798
0799
0800
0801 const BasicBlockListType &getBasicBlockList() const { return BasicBlocks; }
0802 BasicBlockListType &getBasicBlockList() { return BasicBlocks; }
0803
0804 static BasicBlockListType Function::*getSublistAccess(BasicBlock*) {
0805 return &Function::BasicBlocks;
0806 }
0807
0808 public:
0809 const BasicBlock &getEntryBlock() const { return front(); }
0810 BasicBlock &getEntryBlock() { return front(); }
0811
0812
0813
0814
0815
0816
0817 inline ValueSymbolTable *getValueSymbolTable() { return SymTab.get(); }
0818 inline const ValueSymbolTable *getValueSymbolTable() const {
0819 return SymTab.get();
0820 }
0821
0822
0823
0824
0825
0826
0827
0828 unsigned getMaxBlockNumber() const { return NextBlockNum; }
0829
0830
0831
0832
0833 void renumberBlocks();
0834
0835
0836
0837
0838
0839
0840
0841
0842 unsigned getBlockNumberEpoch() const { return BlockNumEpoch; }
0843
0844 private:
0845
0846
0847 void validateBlockNumbers() const;
0848
0849 public:
0850
0851
0852
0853 iterator begin() { return BasicBlocks.begin(); }
0854 const_iterator begin() const { return BasicBlocks.begin(); }
0855 iterator end () { return BasicBlocks.end(); }
0856 const_iterator end () const { return BasicBlocks.end(); }
0857
0858 size_t size() const { return BasicBlocks.size(); }
0859 bool empty() const { return BasicBlocks.empty(); }
0860 const BasicBlock &front() const { return BasicBlocks.front(); }
0861 BasicBlock &front() { return BasicBlocks.front(); }
0862 const BasicBlock &back() const { return BasicBlocks.back(); }
0863 BasicBlock &back() { return BasicBlocks.back(); }
0864
0865
0866
0867
0868 arg_iterator arg_begin() {
0869 CheckLazyArguments();
0870 return Arguments;
0871 }
0872 const_arg_iterator arg_begin() const {
0873 CheckLazyArguments();
0874 return Arguments;
0875 }
0876
0877 arg_iterator arg_end() {
0878 CheckLazyArguments();
0879 return Arguments + NumArgs;
0880 }
0881 const_arg_iterator arg_end() const {
0882 CheckLazyArguments();
0883 return Arguments + NumArgs;
0884 }
0885
0886 Argument* getArg(unsigned i) const {
0887 assert (i < NumArgs && "getArg() out of range!");
0888 CheckLazyArguments();
0889 return Arguments + i;
0890 }
0891
0892 iterator_range<arg_iterator> args() {
0893 return make_range(arg_begin(), arg_end());
0894 }
0895 iterator_range<const_arg_iterator> args() const {
0896 return make_range(arg_begin(), arg_end());
0897 }
0898
0899
0900
0901 size_t arg_size() const { return NumArgs; }
0902 bool arg_empty() const { return arg_size() == 0; }
0903
0904
0905 bool hasPersonalityFn() const {
0906 return getSubclassDataFromValue() & (1<<3);
0907 }
0908
0909
0910 Constant *getPersonalityFn() const;
0911 void setPersonalityFn(Constant *Fn);
0912
0913
0914 bool hasPrefixData() const {
0915 return getSubclassDataFromValue() & (1<<1);
0916 }
0917
0918
0919 Constant *getPrefixData() const;
0920 void setPrefixData(Constant *PrefixData);
0921
0922
0923 bool hasPrologueData() const {
0924 return getSubclassDataFromValue() & (1<<2);
0925 }
0926
0927
0928 Constant *getPrologueData() const;
0929 void setPrologueData(Constant *PrologueData);
0930
0931
0932
0933 void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW = nullptr,
0934 bool ShouldPreserveUseListOrder = false,
0935 bool IsForDebug = false) const;
0936
0937
0938
0939
0940
0941
0942
0943 void viewCFG() const;
0944
0945
0946
0947 void viewCFG(const char *OutputFileName) const;
0948
0949
0950 void viewCFG(bool ViewCFGOnly, const BlockFrequencyInfo *BFI,
0951 const BranchProbabilityInfo *BPI,
0952 const char *OutputFileName = nullptr) const;
0953
0954
0955
0956
0957
0958
0959 void viewCFGOnly() const;
0960
0961
0962
0963 void viewCFGOnly(const char *OutputFileName) const;
0964
0965
0966 void viewCFGOnly(const BlockFrequencyInfo *BFI,
0967 const BranchProbabilityInfo *BPI) const;
0968
0969
0970 static bool classof(const Value *V) {
0971 return V->getValueID() == Value::FunctionVal;
0972 }
0973
0974
0975
0976
0977
0978
0979
0980
0981
0982
0983
0984
0985
0986 void dropAllReferences() {
0987 deleteBodyImpl(true);
0988 }
0989
0990
0991
0992
0993
0994
0995
0996
0997 bool hasAddressTaken(const User ** = nullptr, bool IgnoreCallbackUses = false,
0998 bool IgnoreAssumeLikeCalls = true,
0999 bool IngoreLLVMUsed = false,
1000 bool IgnoreARCAttachedCall = false,
1001 bool IgnoreCastedDirectCall = false) const;
1002
1003
1004
1005
1006
1007 bool isDefTriviallyDead() const;
1008
1009
1010
1011 bool callsFunctionThatReturnsTwice() const;
1012
1013
1014
1015
1016 void setSubprogram(DISubprogram *SP);
1017
1018
1019
1020
1021
1022 DISubprogram *getSubprogram() const;
1023
1024
1025 bool shouldEmitDebugInfoForProfiling() const;
1026
1027
1028
1029
1030
1031 bool nullPointerIsDefined() const;
1032
1033 private:
1034 void allocHungoffUselist();
1035 template<int Idx> void setHungoffOperand(Constant *C);
1036
1037
1038
1039 void setValueSubclassData(unsigned short D) {
1040 Value::setValueSubclassData(D);
1041 }
1042 void setValueSubclassDataBit(unsigned Bit, bool On);
1043 };
1044
1045
1046
1047
1048
1049
1050 bool NullPointerIsDefined(const Function *F, unsigned AS = 0);
1051
1052 template <> struct OperandTraits<Function> : public HungoffOperandTraits {};
1053
1054 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(Function, Value)
1055
1056 }
1057
1058 #endif