Function.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. //===-- llvm/Function.h - Class to represent a single function --*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file contains the declaration of the Function class, which represents a
  11. // single function/procedure in LLVM.
  12. //
  13. // A function basically consists of a list of basic blocks, a list of arguments,
  14. // and a symbol table.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_IR_FUNCTION_H
  18. #define LLVM_IR_FUNCTION_H
  19. #include "llvm/ADT/iterator_range.h"
  20. #include "llvm/ADT/Optional.h"
  21. #include "llvm/IR/Argument.h"
  22. #include "llvm/IR/Attributes.h"
  23. #include "llvm/IR/BasicBlock.h"
  24. #include "llvm/IR/CallingConv.h"
  25. #include "llvm/IR/GlobalObject.h"
  26. #include "llvm/IR/OperandTraits.h"
  27. #include "llvm/Support/Compiler.h"
  28. namespace llvm {
  29. class FunctionType;
  30. class LLVMContext;
  31. template<> struct ilist_traits<Argument>
  32. : public SymbolTableListTraits<Argument, Function> {
  33. Argument *createSentinel() const {
  34. return static_cast<Argument*>(&Sentinel);
  35. }
  36. static void destroySentinel(Argument*) {}
  37. Argument *provideInitialHead() const { return createSentinel(); }
  38. Argument *ensureHead(Argument*) const { return createSentinel(); }
  39. static void noteHead(Argument*, Argument*) {}
  40. static ValueSymbolTable *getSymTab(Function *ItemParent);
  41. private:
  42. mutable ilist_half_node<Argument> Sentinel;
  43. };
  44. class Function : public GlobalObject, public ilist_node<Function> {
  45. public:
  46. typedef iplist<Argument> ArgumentListType;
  47. typedef iplist<BasicBlock> BasicBlockListType;
  48. // BasicBlock iterators...
  49. typedef BasicBlockListType::iterator iterator;
  50. typedef BasicBlockListType::const_iterator const_iterator;
  51. typedef ArgumentListType::iterator arg_iterator;
  52. typedef ArgumentListType::const_iterator const_arg_iterator;
  53. private:
  54. // Important things that make up a function!
  55. BasicBlockListType BasicBlocks; ///< The basic blocks
  56. mutable ArgumentListType ArgumentList; ///< The formal arguments
  57. ValueSymbolTable *SymTab; ///< Symbol table of args/instructions
  58. AttributeSet AttributeSets; ///< Parameter attributes
  59. FunctionType *Ty;
  60. /*
  61. * Value::SubclassData
  62. *
  63. * bit 0 : HasLazyArguments
  64. * bit 1 : HasPrefixData
  65. * bit 2 : HasPrologueData
  66. * bit 3-6: CallingConvention
  67. */
  68. /// Bits from GlobalObject::GlobalObjectSubclassData.
  69. enum {
  70. /// Whether this function is materializable.
  71. IsMaterializableBit = 1 << 0,
  72. HasMetadataHashEntryBit = 1 << 1
  73. };
  74. void setGlobalObjectBit(unsigned Mask, bool Value) {
  75. setGlobalObjectSubClassData((~Mask & getGlobalObjectSubClassData()) |
  76. (Value ? Mask : 0u));
  77. }
  78. friend class SymbolTableListTraits<Function, Module>;
  79. void setParent(Module *parent);
  80. /// hasLazyArguments/CheckLazyArguments - The argument list of a function is
  81. /// built on demand, so that the list isn't allocated until the first client
  82. /// needs it. The hasLazyArguments predicate returns true if the arg list
  83. /// hasn't been set up yet.
  84. bool hasLazyArguments() const {
  85. return getSubclassDataFromValue() & (1<<0);
  86. }
  87. void CheckLazyArguments() const {
  88. if (hasLazyArguments())
  89. BuildLazyArguments();
  90. }
  91. void BuildLazyArguments() const;
  92. Function(const Function&) = delete;
  93. void operator=(const Function&) = delete;
  94. /// Function ctor - If the (optional) Module argument is specified, the
  95. /// function is automatically inserted into the end of the function list for
  96. /// the module.
  97. ///
  98. Function(FunctionType *Ty, LinkageTypes Linkage,
  99. const Twine &N = "", Module *M = nullptr);
  100. public:
  101. static Function *Create(FunctionType *Ty, LinkageTypes Linkage,
  102. const Twine &N = "", Module *M = nullptr) {
  103. return new(1) Function(Ty, Linkage, N, M);
  104. }
  105. ~Function() override;
  106. /// \brief Provide fast operand accessors
  107. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
  108. /// \brief Get the personality function associated with this function.
  109. bool hasPersonalityFn() const { return getNumOperands() != 0; }
  110. Constant *getPersonalityFn() const {
  111. assert(hasPersonalityFn());
  112. return cast<Constant>(Op<0>());
  113. }
  114. void setPersonalityFn(Constant *C);
  115. Type *getReturnType() const; // Return the type of the ret val
  116. FunctionType *getFunctionType() const; // Return the FunctionType for me
  117. /// getContext - Return a reference to the LLVMContext associated with this
  118. /// function.
  119. LLVMContext &getContext() const;
  120. /// isVarArg - Return true if this function takes a variable number of
  121. /// arguments.
  122. bool isVarArg() const;
  123. bool isMaterializable() const;
  124. void setIsMaterializable(bool V);
  125. /// getIntrinsicID - This method returns the ID number of the specified
  126. /// function, or Intrinsic::not_intrinsic if the function is not an
  127. /// intrinsic, or if the pointer is null. This value is always defined to be
  128. /// zero to allow easy checking for whether a function is intrinsic or not.
  129. /// The particular intrinsic functions which correspond to this value are
  130. /// defined in llvm/Intrinsics.h.
  131. Intrinsic::ID getIntrinsicID() const LLVM_READONLY { return IntID; }
  132. bool isIntrinsic() const { return getName().startswith("llvm."); }
  133. /// \brief Recalculate the ID for this function if it is an Intrinsic defined
  134. /// in llvm/Intrinsics.h. Sets the intrinsic ID to Intrinsic::not_intrinsic
  135. /// if the name of this function does not match an intrinsic in that header.
  136. /// Note, this method does not need to be called directly, as it is called
  137. /// from Value::setName() whenever the name of this function changes.
  138. void recalculateIntrinsicID();
  139. /// getCallingConv()/setCallingConv(CC) - These method get and set the
  140. /// calling convention of this function. The enum values for the known
  141. /// calling conventions are defined in CallingConv.h.
  142. CallingConv::ID getCallingConv() const {
  143. return static_cast<CallingConv::ID>(getSubclassDataFromValue() >> 3);
  144. }
  145. void setCallingConv(CallingConv::ID CC) {
  146. setValueSubclassData((getSubclassDataFromValue() & 7) |
  147. (static_cast<unsigned>(CC) << 3));
  148. }
  149. /// @brief Return the attribute list for this Function.
  150. AttributeSet getAttributes() const { return AttributeSets; }
  151. /// @brief Set the attribute list for this Function.
  152. void setAttributes(AttributeSet attrs) { AttributeSets = attrs; }
  153. /// @brief Add function attributes to this function.
  154. void addFnAttr(Attribute::AttrKind N) {
  155. setAttributes(AttributeSets.addAttribute(getContext(),
  156. AttributeSet::FunctionIndex, N));
  157. }
  158. /// @brief Remove function attributes from this function.
  159. void removeFnAttr(Attribute::AttrKind N) {
  160. setAttributes(AttributeSets.removeAttribute(
  161. getContext(), AttributeSet::FunctionIndex, N));
  162. }
  163. /// @brief Add function attributes to this function.
  164. void addFnAttr(StringRef Kind) {
  165. setAttributes(
  166. AttributeSets.addAttribute(getContext(),
  167. AttributeSet::FunctionIndex, Kind));
  168. }
  169. void addFnAttr(StringRef Kind, StringRef Value) {
  170. setAttributes(
  171. AttributeSets.addAttribute(getContext(),
  172. AttributeSet::FunctionIndex, Kind, Value));
  173. }
  174. /// Set the entry count for this function.
  175. void setEntryCount(uint64_t Count);
  176. /// Get the entry count for this function.
  177. Optional<uint64_t> getEntryCount() const;
  178. /// @brief Return true if the function has the attribute.
  179. bool hasFnAttribute(Attribute::AttrKind Kind) const {
  180. return AttributeSets.hasAttribute(AttributeSet::FunctionIndex, Kind);
  181. }
  182. bool hasFnAttribute(StringRef Kind) const {
  183. return AttributeSets.hasAttribute(AttributeSet::FunctionIndex, Kind);
  184. }
  185. /// @brief Return the attribute for the given attribute kind.
  186. Attribute getFnAttribute(Attribute::AttrKind Kind) const {
  187. return AttributeSets.getAttribute(AttributeSet::FunctionIndex, Kind);
  188. }
  189. Attribute getFnAttribute(StringRef Kind) const {
  190. return AttributeSets.getAttribute(AttributeSet::FunctionIndex, Kind);
  191. }
  192. /// \brief Return the stack alignment for the function.
  193. unsigned getFnStackAlignment() const {
  194. return AttributeSets.getStackAlignment(AttributeSet::FunctionIndex);
  195. }
  196. /// hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm
  197. /// to use during code generation.
  198. bool hasGC() const;
  199. const char *getGC() const;
  200. void setGC(const char *Str);
  201. void clearGC();
  202. /// @brief adds the attribute to the list of attributes.
  203. void addAttribute(unsigned i, Attribute::AttrKind attr);
  204. /// @brief adds the attributes to the list of attributes.
  205. void addAttributes(unsigned i, AttributeSet attrs);
  206. /// @brief removes the attributes from the list of attributes.
  207. void removeAttributes(unsigned i, AttributeSet attr);
  208. /// @brief adds the dereferenceable attribute to the list of attributes.
  209. void addDereferenceableAttr(unsigned i, uint64_t Bytes);
  210. /// @brief adds the dereferenceable_or_null attribute to the list of
  211. /// attributes.
  212. void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes);
  213. /// @brief Extract the alignment for a call or parameter (0=unknown).
  214. unsigned getParamAlignment(unsigned i) const {
  215. return AttributeSets.getParamAlignment(i);
  216. }
  217. /// @brief Extract the number of dereferenceable bytes for a call or
  218. /// parameter (0=unknown).
  219. uint64_t getDereferenceableBytes(unsigned i) const {
  220. return AttributeSets.getDereferenceableBytes(i);
  221. }
  222. /// @brief Extract the number of dereferenceable_or_null bytes for a call or
  223. /// parameter (0=unknown).
  224. uint64_t getDereferenceableOrNullBytes(unsigned i) const {
  225. return AttributeSets.getDereferenceableOrNullBytes(i);
  226. }
  227. /// @brief Determine if the function does not access memory.
  228. bool doesNotAccessMemory() const {
  229. return AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
  230. Attribute::ReadNone);
  231. }
  232. void setDoesNotAccessMemory() {
  233. addFnAttr(Attribute::ReadNone);
  234. }
  235. /// @brief Determine if the function does not access or only reads memory.
  236. bool onlyReadsMemory() const {
  237. return doesNotAccessMemory() ||
  238. AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
  239. Attribute::ReadOnly);
  240. }
  241. void setOnlyReadsMemory() {
  242. addFnAttr(Attribute::ReadOnly);
  243. }
  244. /// @brief Determine if the call can access memmory only using pointers based
  245. /// on its arguments.
  246. bool onlyAccessesArgMemory() const {
  247. return AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
  248. Attribute::ArgMemOnly);
  249. }
  250. void setOnlyAccessesArgMemory() {
  251. addFnAttr(Attribute::ArgMemOnly);
  252. }
  253. /// @brief Determine if the function cannot return.
  254. bool doesNotReturn() const {
  255. return AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
  256. Attribute::NoReturn);
  257. }
  258. void setDoesNotReturn() {
  259. addFnAttr(Attribute::NoReturn);
  260. }
  261. /// @brief Determine if the function cannot unwind.
  262. bool doesNotThrow() const {
  263. return AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
  264. Attribute::NoUnwind);
  265. }
  266. void setDoesNotThrow() {
  267. addFnAttr(Attribute::NoUnwind);
  268. }
  269. /// @brief Determine if the call cannot be duplicated.
  270. bool cannotDuplicate() const {
  271. return AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
  272. Attribute::NoDuplicate);
  273. }
  274. void setCannotDuplicate() {
  275. addFnAttr(Attribute::NoDuplicate);
  276. }
  277. /// @brief Determine if the call is convergent.
  278. bool isConvergent() const {
  279. return AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
  280. Attribute::Convergent);
  281. }
  282. void setConvergent() {
  283. addFnAttr(Attribute::Convergent);
  284. }
  285. /// @brief True if the ABI mandates (or the user requested) that this
  286. /// function be in a unwind table.
  287. bool hasUWTable() const {
  288. return AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
  289. Attribute::UWTable);
  290. }
  291. void setHasUWTable() {
  292. addFnAttr(Attribute::UWTable);
  293. }
  294. /// @brief True if this function needs an unwind table.
  295. bool needsUnwindTableEntry() const {
  296. return hasUWTable() || !doesNotThrow();
  297. }
  298. /// @brief Determine if the function returns a structure through first
  299. /// pointer argument.
  300. bool hasStructRetAttr() const {
  301. return AttributeSets.hasAttribute(1, Attribute::StructRet) ||
  302. AttributeSets.hasAttribute(2, Attribute::StructRet);
  303. }
  304. /// @brief Determine if the parameter does not alias other parameters.
  305. /// @param n The parameter to check. 1 is the first parameter, 0 is the return
  306. bool doesNotAlias(unsigned n) const {
  307. return AttributeSets.hasAttribute(n, Attribute::NoAlias);
  308. }
  309. void setDoesNotAlias(unsigned n) {
  310. addAttribute(n, Attribute::NoAlias);
  311. }
  312. /// @brief Determine if the parameter can be captured.
  313. /// @param n The parameter to check. 1 is the first parameter, 0 is the return
  314. bool doesNotCapture(unsigned n) const {
  315. return AttributeSets.hasAttribute(n, Attribute::NoCapture);
  316. }
  317. void setDoesNotCapture(unsigned n) {
  318. addAttribute(n, Attribute::NoCapture);
  319. }
  320. bool doesNotAccessMemory(unsigned n) const {
  321. return AttributeSets.hasAttribute(n, Attribute::ReadNone);
  322. }
  323. void setDoesNotAccessMemory(unsigned n) {
  324. addAttribute(n, Attribute::ReadNone);
  325. }
  326. bool onlyReadsMemory(unsigned n) const {
  327. return doesNotAccessMemory(n) ||
  328. AttributeSets.hasAttribute(n, Attribute::ReadOnly);
  329. }
  330. void setOnlyReadsMemory(unsigned n) {
  331. addAttribute(n, Attribute::ReadOnly);
  332. }
  333. /// copyAttributesFrom - copy all additional attributes (those not needed to
  334. /// create a Function) from the Function Src to this one.
  335. void copyAttributesFrom(const GlobalValue *Src) override;
  336. /// deleteBody - This method deletes the body of the function, and converts
  337. /// the linkage to external.
  338. ///
  339. void deleteBody() {
  340. dropAllReferences();
  341. setLinkage(ExternalLinkage);
  342. }
  343. /// removeFromParent - This method unlinks 'this' from the containing module,
  344. /// but does not delete it.
  345. ///
  346. void removeFromParent() override;
  347. /// eraseFromParent - This method unlinks 'this' from the containing module
  348. /// and deletes it.
  349. ///
  350. void eraseFromParent() override;
  351. /// Get the underlying elements of the Function... the basic block list is
  352. /// empty for external functions.
  353. ///
  354. const ArgumentListType &getArgumentList() const {
  355. CheckLazyArguments();
  356. return ArgumentList;
  357. }
  358. ArgumentListType &getArgumentList() {
  359. CheckLazyArguments();
  360. return ArgumentList;
  361. }
  362. static iplist<Argument> Function::*getSublistAccess(Argument*) {
  363. return &Function::ArgumentList;
  364. }
  365. const BasicBlockListType &getBasicBlockList() const { return BasicBlocks; }
  366. BasicBlockListType &getBasicBlockList() { return BasicBlocks; }
  367. static iplist<BasicBlock> Function::*getSublistAccess(BasicBlock*) {
  368. return &Function::BasicBlocks;
  369. }
  370. const BasicBlock &getEntryBlock() const { return front(); }
  371. BasicBlock &getEntryBlock() { return front(); }
  372. //===--------------------------------------------------------------------===//
  373. // Symbol Table Accessing functions...
  374. /// getSymbolTable() - Return the symbol table...
  375. ///
  376. inline ValueSymbolTable &getValueSymbolTable() { return *SymTab; }
  377. inline const ValueSymbolTable &getValueSymbolTable() const { return *SymTab; }
  378. //===--------------------------------------------------------------------===//
  379. // BasicBlock iterator forwarding functions
  380. //
  381. iterator begin() { return BasicBlocks.begin(); }
  382. const_iterator begin() const { return BasicBlocks.begin(); }
  383. iterator end () { return BasicBlocks.end(); }
  384. const_iterator end () const { return BasicBlocks.end(); }
  385. size_t size() const { return BasicBlocks.size(); }
  386. bool empty() const { return BasicBlocks.empty(); }
  387. const BasicBlock &front() const { return BasicBlocks.front(); }
  388. BasicBlock &front() { return BasicBlocks.front(); }
  389. const BasicBlock &back() const { return BasicBlocks.back(); }
  390. BasicBlock &back() { return BasicBlocks.back(); }
  391. /// @name Function Argument Iteration
  392. /// @{
  393. arg_iterator arg_begin() {
  394. CheckLazyArguments();
  395. return ArgumentList.begin();
  396. }
  397. const_arg_iterator arg_begin() const {
  398. CheckLazyArguments();
  399. return ArgumentList.begin();
  400. }
  401. arg_iterator arg_end() {
  402. CheckLazyArguments();
  403. return ArgumentList.end();
  404. }
  405. const_arg_iterator arg_end() const {
  406. CheckLazyArguments();
  407. return ArgumentList.end();
  408. }
  409. iterator_range<arg_iterator> args() {
  410. return iterator_range<arg_iterator>(arg_begin(), arg_end());
  411. }
  412. iterator_range<const_arg_iterator> args() const {
  413. return iterator_range<const_arg_iterator>(arg_begin(), arg_end());
  414. }
  415. /// @}
  416. size_t arg_size() const;
  417. bool arg_empty() const;
  418. bool hasPrefixData() const {
  419. return getSubclassDataFromValue() & (1<<1);
  420. }
  421. Constant *getPrefixData() const;
  422. void setPrefixData(Constant *PrefixData);
  423. bool hasPrologueData() const {
  424. return getSubclassDataFromValue() & (1<<2);
  425. }
  426. Constant *getPrologueData() const;
  427. void setPrologueData(Constant *PrologueData);
  428. /// Print the function to an output stream with an optional
  429. /// AssemblyAnnotationWriter.
  430. void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW = nullptr) const;
  431. /// viewCFG - This function is meant for use from the debugger. You can just
  432. /// say 'call F->viewCFG()' and a ghostview window should pop up from the
  433. /// program, displaying the CFG of the current function with the code for each
  434. /// basic block inside. This depends on there being a 'dot' and 'gv' program
  435. /// in your path.
  436. ///
  437. void viewCFG() const;
  438. /// viewCFGOnly - This function is meant for use from the debugger. It works
  439. /// just like viewCFG, but it does not include the contents of basic blocks
  440. /// into the nodes, just the label. If you are only interested in the CFG
  441. /// this can make the graph smaller.
  442. ///
  443. void viewCFGOnly() const;
  444. /// Methods for support type inquiry through isa, cast, and dyn_cast:
  445. static inline bool classof(const Value *V) {
  446. return V->getValueID() == Value::FunctionVal;
  447. }
  448. /// dropAllReferences() - This method causes all the subinstructions to "let
  449. /// go" of all references that they are maintaining. This allows one to
  450. /// 'delete' a whole module at a time, even though there may be circular
  451. /// references... first all references are dropped, and all use counts go to
  452. /// zero. Then everything is deleted for real. Note that no operations are
  453. /// valid on an object that has "dropped all references", except operator
  454. /// delete.
  455. ///
  456. /// Since no other object in the module can have references into the body of a
  457. /// function, dropping all references deletes the entire body of the function,
  458. /// including any contained basic blocks.
  459. ///
  460. void dropAllReferences();
  461. /// hasAddressTaken - returns true if there are any uses of this function
  462. /// other than direct calls or invokes to it, or blockaddress expressions.
  463. /// Optionally passes back an offending user for diagnostic purposes.
  464. ///
  465. bool hasAddressTaken(const User** = nullptr) const;
  466. /// isDefTriviallyDead - Return true if it is trivially safe to remove
  467. /// this function definition from the module (because it isn't externally
  468. /// visible, does not have its address taken, and has no callers). To make
  469. /// this more accurate, call removeDeadConstantUsers first.
  470. bool isDefTriviallyDead() const;
  471. /// callsFunctionThatReturnsTwice - Return true if the function has a call to
  472. /// setjmp or other function that gcc recognizes as "returning twice".
  473. bool callsFunctionThatReturnsTwice() const;
  474. /// \brief Check if this has any metadata.
  475. bool hasMetadata() const { return hasMetadataHashEntry(); }
  476. /// \brief Get the current metadata attachment, if any.
  477. ///
  478. /// Returns \c nullptr if such an attachment is missing.
  479. /// @{
  480. MDNode *getMetadata(unsigned KindID) const;
  481. MDNode *getMetadata(StringRef Kind) const;
  482. /// @}
  483. /// \brief Set a particular kind of metadata attachment.
  484. ///
  485. /// Sets the given attachment to \c MD, erasing it if \c MD is \c nullptr or
  486. /// replacing it if it already exists.
  487. /// @{
  488. void setMetadata(unsigned KindID, MDNode *MD);
  489. void setMetadata(StringRef Kind, MDNode *MD);
  490. /// @}
  491. /// \brief Get all current metadata attachments.
  492. void
  493. getAllMetadata(SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const;
  494. /// \brief Drop metadata not in the given list.
  495. ///
  496. /// Drop all metadata from \c this not included in \c KnownIDs.
  497. void dropUnknownMetadata(ArrayRef<unsigned> KnownIDs);
  498. private:
  499. // Shadow Value::setValueSubclassData with a private forwarding method so that
  500. // subclasses cannot accidentally use it.
  501. void setValueSubclassData(unsigned short D) {
  502. Value::setValueSubclassData(D);
  503. }
  504. bool hasMetadataHashEntry() const {
  505. return getGlobalObjectSubClassData() & HasMetadataHashEntryBit;
  506. }
  507. void setHasMetadataHashEntry(bool HasEntry) {
  508. setGlobalObjectBit(HasMetadataHashEntryBit, HasEntry);
  509. }
  510. void clearMetadata();
  511. };
  512. inline ValueSymbolTable *
  513. ilist_traits<BasicBlock>::getSymTab(Function *F) {
  514. return F ? &F->getValueSymbolTable() : nullptr;
  515. }
  516. inline ValueSymbolTable *
  517. ilist_traits<Argument>::getSymTab(Function *F) {
  518. return F ? &F->getValueSymbolTable() : nullptr;
  519. }
  520. template <>
  521. struct OperandTraits<Function> : public OptionalOperandTraits<Function> {};
  522. DEFINE_TRANSPARENT_OPERAND_ACCESSORS(Function, Value)
  523. } // End llvm namespace
  524. #endif