1a42414bcf6c04da34da107dd20c88f6f1965ad40Chris Lattner//===-- llvm/Function.h - Class to represent a single function --*- C++ -*-===// 29769ab22265b313171d201b5928688524a01bd87Misha Brukman// 36fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// The LLVM Compiler Infrastructure 46fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// 57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source 67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// License. See LICENSE.TXT for details. 79769ab22265b313171d201b5928688524a01bd87Misha Brukman// 86fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//===----------------------------------------------------------------------===// 9009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner// 109769ab22265b313171d201b5928688524a01bd87Misha Brukman// This file contains the declaration of the Function class, which represents a 11a42414bcf6c04da34da107dd20c88f6f1965ad40Chris Lattner// single function/procedure in LLVM. 12009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner// 13a42414bcf6c04da34da107dd20c88f6f1965ad40Chris Lattner// A function basically consists of a list of basic blocks, a list of arguments, 14a42414bcf6c04da34da107dd20c88f6f1965ad40Chris Lattner// and a symbol table. 15009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner// 16009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner//===----------------------------------------------------------------------===// 17009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner 1879cc5bc9126928dfbca70ec1b09843467ff3d399Chris Lattner#ifndef LLVM_FUNCTION_H 1979cc5bc9126928dfbca70ec1b09843467ff3d399Chris Lattner#define LLVM_FUNCTION_H 20009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner 21ef9c23f2812322ae5c5f3140bfbcf92629d7ff47Chris Lattner#include "llvm/GlobalValue.h" 2265c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel#include "llvm/CallingConv.h" 2318961504fc2b299578dba817900a0696cf3ccc4dChris Lattner#include "llvm/BasicBlock.h" 2418961504fc2b299578dba817900a0696cf3ccc4dChris Lattner#include "llvm/Argument.h" 25eaf42abab6d465c38891345d999255871cf03943Devang Patel#include "llvm/Attributes.h" 265415127330d3b3ccb91cc6fef196f066563740a9Chris Lattner#include "llvm/Support/Compiler.h" 27009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner 28d0fde30ce850b78371fd1386338350591f9ff494Brian Gaekenamespace llvm { 29d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke 300edcc41253410eb3bdafa8e341704f4be5bef552Chris Lattnerclass FunctionType; 3112ddd409535b52a7fa5157ded9a4cedd161fedb6Benjamin Kramerclass LLVMContext; 32009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner 331f3bd7a2ee3e866d7196aca10d334777bb99f677Gabor Greif// Traits for intrusive list of basic blocks... 3418961504fc2b299578dba817900a0696cf3ccc4dChris Lattnertemplate<> struct ilist_traits<BasicBlock> 3517fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattner : public SymbolTableListTraits<BasicBlock, Function> { 3618961504fc2b299578dba817900a0696cf3ccc4dChris Lattner 37abd6f28a74e74303725ec123bdfe9202617115c8Gabor Greif // createSentinel is used to get hold of the node that marks the end of the 38abd6f28a74e74303725ec123bdfe9202617115c8Gabor Greif // list... (same trick used here as in ilist_traits<Instruction>) 39abd6f28a74e74303725ec123bdfe9202617115c8Gabor Greif BasicBlock *createSentinel() const { 401012919ed8b3e2cd4b421c104ce9d8f4e20ced9dGabor Greif return static_cast<BasicBlock*>(&Sentinel); 41abd6f28a74e74303725ec123bdfe9202617115c8Gabor Greif } 42abd6f28a74e74303725ec123bdfe9202617115c8Gabor Greif static void destroySentinel(BasicBlock*) {} 43c23b8719ef9d6b1220e854b37d40e9e1c48a82bcGabor Greif 44c23b8719ef9d6b1220e854b37d40e9e1c48a82bcGabor Greif BasicBlock *provideInitialHead() const { return createSentinel(); } 45c23b8719ef9d6b1220e854b37d40e9e1c48a82bcGabor Greif BasicBlock *ensureHead(BasicBlock*) const { return createSentinel(); } 46f3841fcbd587c31aa9842b3f33bd57de40c9f443Gabor Greif static void noteHead(BasicBlock*, BasicBlock*) {} 47c23b8719ef9d6b1220e854b37d40e9e1c48a82bcGabor Greif 4817fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattner static ValueSymbolTable *getSymTab(Function *ItemParent); 49abd6f28a74e74303725ec123bdfe9202617115c8Gabor Greifprivate: 507309be6735666143bd9835b275dc8501617a2591Gabor Greif mutable ilist_half_node<BasicBlock> Sentinel; 5118961504fc2b299578dba817900a0696cf3ccc4dChris Lattner}; 5218961504fc2b299578dba817900a0696cf3ccc4dChris Lattner 5318961504fc2b299578dba817900a0696cf3ccc4dChris Lattnertemplate<> struct ilist_traits<Argument> 5417fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattner : public SymbolTableListTraits<Argument, Function> { 5518961504fc2b299578dba817900a0696cf3ccc4dChris Lattner 565e7d4d643d691f6169eaaf60b13dc54ba2b69232Gabor Greif Argument *createSentinel() const { 571012919ed8b3e2cd4b421c104ce9d8f4e20ced9dGabor Greif return static_cast<Argument*>(&Sentinel); 585e7d4d643d691f6169eaaf60b13dc54ba2b69232Gabor Greif } 595e7d4d643d691f6169eaaf60b13dc54ba2b69232Gabor Greif static void destroySentinel(Argument*) {} 60c23b8719ef9d6b1220e854b37d40e9e1c48a82bcGabor Greif 61c23b8719ef9d6b1220e854b37d40e9e1c48a82bcGabor Greif Argument *provideInitialHead() const { return createSentinel(); } 62c23b8719ef9d6b1220e854b37d40e9e1c48a82bcGabor Greif Argument *ensureHead(Argument*) const { return createSentinel(); } 63f3841fcbd587c31aa9842b3f33bd57de40c9f443Gabor Greif static void noteHead(Argument*, Argument*) {} 64c23b8719ef9d6b1220e854b37d40e9e1c48a82bcGabor Greif 6517fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattner static ValueSymbolTable *getSymTab(Function *ItemParent); 665e7d4d643d691f6169eaaf60b13dc54ba2b69232Gabor Greifprivate: 677309be6735666143bd9835b275dc8501617a2591Gabor Greif mutable ilist_half_node<Argument> Sentinel; 6818961504fc2b299578dba817900a0696cf3ccc4dChris Lattner}; 6918961504fc2b299578dba817900a0696cf3ccc4dChris Lattner 70ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohmanclass Function : public GlobalValue, 71fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman public ilist_node<Function> { 72009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattnerpublic: 7318961504fc2b299578dba817900a0696cf3ccc4dChris Lattner typedef iplist<Argument> ArgumentListType; 7418961504fc2b299578dba817900a0696cf3ccc4dChris Lattner typedef iplist<BasicBlock> BasicBlockListType; 751020b3982c9eae15844c5612b0cf251917931b1dChris Lattner 761020b3982c9eae15844c5612b0cf251917931b1dChris Lattner // BasicBlock iterators... 7718961504fc2b299578dba817900a0696cf3ccc4dChris Lattner typedef BasicBlockListType::iterator iterator; 7818961504fc2b299578dba817900a0696cf3ccc4dChris Lattner typedef BasicBlockListType::const_iterator const_iterator; 791020b3982c9eae15844c5612b0cf251917931b1dChris Lattner 802427c9dfb3d76f7c71fcc7e9291464d8e6eb1cc2Chris Lattner typedef ArgumentListType::iterator arg_iterator; 812427c9dfb3d76f7c71fcc7e9291464d8e6eb1cc2Chris Lattner typedef ArgumentListType::const_iterator const_arg_iterator; 8218961504fc2b299578dba817900a0696cf3ccc4dChris Lattner 83009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattnerprivate: 848c310c75489a94c6e02b779ae0f611dfd3d63619Chris Lattner // Important things that make up a function! 850162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner BasicBlockListType BasicBlocks; ///< The basic blocks 860162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner mutable ArgumentListType ArgumentList; ///< The formal arguments 870162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner ValueSymbolTable *SymTab; ///< Symbol table of args/instructions 88e940f3e6bbce1575d137df97f26e4df00a3877b7Chris Lattner AttrListPtr AttributeList; ///< Parameter attributes 8921dbb99964f0568d2d3d3fc7e2bd5967e7577bd1Devang Patel 90cafe9bba32aeed16e8e3db28b4cd4ff13160438fChris Lattner // HasLazyArguments is stored in Value::SubclassData. 91cafe9bba32aeed16e8e3db28b4cd4ff13160438fChris Lattner /*bool HasLazyArguments;*/ 92cafe9bba32aeed16e8e3db28b4cd4ff13160438fChris Lattner 9318feb92e917a029b72a338e91b5b93f74d26f406Chris Lattner // The Calling Convention is stored in Value::SubclassData. 9465c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel /*CallingConv::ID CallingConvention;*/ 959769ab22265b313171d201b5928688524a01bd87Misha Brukman 9617fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattner friend class SymbolTableListTraits<Function, Module>; 9718961504fc2b299578dba817900a0696cf3ccc4dChris Lattner 98009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner void setParent(Module *parent); 99a80e1181b78183dc36ec6568559d38faa86981f0Anton Korobeynikov 1000162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner /// hasLazyArguments/CheckLazyArguments - The argument list of a function is 1010162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner /// built on demand, so that the list isn't allocated until the first client 1020162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner /// needs it. The hasLazyArguments predicate returns true if the arg list 1030162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner /// hasn't been set up yet. 1040162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner bool hasLazyArguments() const { 105cafe9bba32aeed16e8e3db28b4cd4ff13160438fChris Lattner return getSubclassDataFromValue() & 1; 1060162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner } 1070162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner void CheckLazyArguments() const { 1080162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner if (hasLazyArguments()) 1090162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner BuildLazyArguments(); 1100162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner } 1110162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner void BuildLazyArguments() const; 11249269d9e7eb5ce6e1a84a10ca0bdeab044d0db3dChris Lattner 11349269d9e7eb5ce6e1a84a10ca0bdeab044d0db3dChris Lattner Function(const Function&); // DO NOT IMPLEMENT 11449269d9e7eb5ce6e1a84a10ca0bdeab044d0db3dChris Lattner void operator=(const Function&); // DO NOT IMPLEMENT 115051a950000e21935165db56695e35bade668193bGabor Greif 116a42414bcf6c04da34da107dd20c88f6f1965ad40Chris Lattner /// Function ctor - If the (optional) Module argument is specified, the 117a42414bcf6c04da34da107dd20c88f6f1965ad40Chris Lattner /// function is automatically inserted into the end of the function list for 118a42414bcf6c04da34da107dd20c88f6f1965ad40Chris Lattner /// the module. 119a42414bcf6c04da34da107dd20c88f6f1965ad40Chris Lattner /// 120db125cfaf57cc83e7dd7453de2d509bc8efd0e5eChris Lattner Function(FunctionType *Ty, LinkageTypes Linkage, 1216e0d1cb30957a636c53158d3089e6fb88348a57aDaniel Dunbar const Twine &N = "", Module *M = 0); 122051a950000e21935165db56695e35bade668193bGabor Greif 123051a950000e21935165db56695e35bade668193bGabor Greifpublic: 124db125cfaf57cc83e7dd7453de2d509bc8efd0e5eChris Lattner static Function *Create(FunctionType *Ty, LinkageTypes Linkage, 1256e0d1cb30957a636c53158d3089e6fb88348a57aDaniel Dunbar const Twine &N = "", Module *M = 0) { 126051a950000e21935165db56695e35bade668193bGabor Greif return new(0) Function(Ty, Linkage, N, M); 127051a950000e21935165db56695e35bade668193bGabor Greif } 128051a950000e21935165db56695e35bade668193bGabor Greif 129afba8fe662d65b25b4baf46bb26cc18e1f9cc0a5Gordon Henriksen ~Function(); 130009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner 1311afcace3a3a138b1b18e5c6270caa8dae2261ae2Chris Lattner Type *getReturnType() const; // Return the type of the ret val 1321afcace3a3a138b1b18e5c6270caa8dae2261ae2Chris Lattner FunctionType *getFunctionType() const; // Return the FunctionType for me 133009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner 13462fabf5faba70c507c8fbe298260e9b3749fdd79Owen Anderson /// getContext - Return a pointer to the LLVMContext associated with this 13562fabf5faba70c507c8fbe298260e9b3749fdd79Owen Anderson /// function, or NULL if this function is not bound to a context yet. 136e922c0201916e0b980ab3cfe91e1413e68d55647Owen Anderson LLVMContext &getContext() const; 13762fabf5faba70c507c8fbe298260e9b3749fdd79Owen Anderson 138fe59d36c4510b9b3df6deab2fe269ef19db4d193Chris Lattner /// isVarArg - Return true if this function takes a variable number of 139fe59d36c4510b9b3df6deab2fe269ef19db4d193Chris Lattner /// arguments. 140fe59d36c4510b9b3df6deab2fe269ef19db4d193Chris Lattner bool isVarArg() const; 141fe59d36c4510b9b3df6deab2fe269ef19db4d193Chris Lattner 1424804824047a7a3b87022541eb143063fffad7ddcChris Lattner /// getIntrinsicID - This method returns the ID number of the specified 143d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke /// function, or Intrinsic::not_intrinsic if the function is not an 1444804824047a7a3b87022541eb143063fffad7ddcChris Lattner /// instrinsic, or if the pointer is null. This value is always defined to be 1454804824047a7a3b87022541eb143063fffad7ddcChris Lattner /// zero to allow easy checking for whether a function is intrinsic or not. 1464804824047a7a3b87022541eb143063fffad7ddcChris Lattner /// The particular intrinsic functions which correspond to this value are 1474804824047a7a3b87022541eb143063fffad7ddcChris Lattner /// defined in llvm/Intrinsics.h. 1484804824047a7a3b87022541eb143063fffad7ddcChris Lattner /// 14975c0d8e0d8f4e10587985b950f2c0752e45e099eDaniel Dunbar unsigned getIntrinsicID() const LLVM_READONLY; 1504804824047a7a3b87022541eb143063fffad7ddcChris Lattner bool isIntrinsic() const { return getIntrinsicID() != 0; } 1514804824047a7a3b87022541eb143063fffad7ddcChris Lattner 15265c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel /// getCallingConv()/setCallingConv(CC) - These method get and set the 1533340ffe85431f705e91aa4d4b64207f80d0d8c2fChris Lattner /// calling convention of this function. The enum values for the known 1543340ffe85431f705e91aa4d4b64207f80d0d8c2fChris Lattner /// calling conventions are defined in CallingConv.h. 15565c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel CallingConv::ID getCallingConv() const { 156cafe9bba32aeed16e8e3db28b4cd4ff13160438fChris Lattner return static_cast<CallingConv::ID>(getSubclassDataFromValue() >> 1); 15765c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel } 15865c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel void setCallingConv(CallingConv::ID CC) { 159cafe9bba32aeed16e8e3db28b4cd4ff13160438fChris Lattner setValueSubclassData((getSubclassDataFromValue() & 1) | 160cafe9bba32aeed16e8e3db28b4cd4ff13160438fChris Lattner (static_cast<unsigned>(CC) << 1)); 1610162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner } 162f38a33cd0aafff87a8f48debccb09971d2b82dd9Jim Grosbach 163e940f3e6bbce1575d137df97f26e4df00a3877b7Chris Lattner /// getAttributes - Return the attribute list for this Function. 164041221c0972ff575b07f76808c504833d629ae1fChris Lattner /// 1650598866c052147c31b808391f58434ce3dbfb838Devang Patel const AttrListPtr &getAttributes() const { return AttributeList; } 16658d74910c6b82e622ecbb57d6644d48fec5a5c0fChris Lattner 167e940f3e6bbce1575d137df97f26e4df00a3877b7Chris Lattner /// setAttributes - Set the attribute list for this Function. 168041221c0972ff575b07f76808c504833d629ae1fChris Lattner /// 1690598866c052147c31b808391f58434ce3dbfb838Devang Patel void setAttributes(const AttrListPtr &attrs) { AttributeList = attrs; } 170dc024674ff96820d6020757b48d47f46d4c07db2Duncan Sands 171c580144f41393217f928a0f8a99ff2cb066d460aDevang Patel /// hasFnAttr - Return true if this function has the given attribute. 1722c9c3e73682749016d5885b67ff719f634b37d58Devang Patel bool hasFnAttr(Attributes N) const { 1732c9c3e73682749016d5885b67ff719f634b37d58Devang Patel // Function Attributes are stored at ~0 index 1742c9c3e73682749016d5885b67ff719f634b37d58Devang Patel return AttributeList.paramHasAttr(~0U, N); 175f3ba70861ccf00b1072ae1b6ade3ebe2da6cff40Devang Patel } 176f3ba70861ccf00b1072ae1b6ade3ebe2da6cff40Devang Patel 177e940f3e6bbce1575d137df97f26e4df00a3877b7Chris Lattner /// addFnAttr - Add function attributes to this function. 17821dbb99964f0568d2d3d3fc7e2bd5967e7577bd1Devang Patel /// 179e940f3e6bbce1575d137df97f26e4df00a3877b7Chris Lattner void addFnAttr(Attributes N) { 1802c9c3e73682749016d5885b67ff719f634b37d58Devang Patel // Function Attributes are stored at ~0 index 181bde84d2fca4217043eb8c2ba447ae2797813ca54Eric Christopher addAttribute(~0U, N); 182d9b4a5f859188cbb168c223071b413e58c53c925Devang Patel } 18321dbb99964f0568d2d3d3fc7e2bd5967e7577bd1Devang Patel 18430b64129f5bf03521665115023c9a360a4e67218Nick Lewycky /// removeFnAttr - Remove function attributes from this function. 18530b64129f5bf03521665115023c9a360a4e67218Nick Lewycky /// 18630b64129f5bf03521665115023c9a360a4e67218Nick Lewycky void removeFnAttr(Attributes N) { 18730b64129f5bf03521665115023c9a360a4e67218Nick Lewycky // Function Attributes are stored at ~0 index 18830b64129f5bf03521665115023c9a360a4e67218Nick Lewycky removeAttribute(~0U, N); 18930b64129f5bf03521665115023c9a360a4e67218Nick Lewycky } 19030b64129f5bf03521665115023c9a360a4e67218Nick Lewycky 1915eca075b74d62c621b160aa216b4cd50829a2cc7Gordon Henriksen /// hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm 1925eca075b74d62c621b160aa216b4cd50829a2cc7Gordon Henriksen /// to use during code generation. 1935eca075b74d62c621b160aa216b4cd50829a2cc7Gordon Henriksen bool hasGC() const; 1945eca075b74d62c621b160aa216b4cd50829a2cc7Gordon Henriksen const char *getGC() const; 1955eca075b74d62c621b160aa216b4cd50829a2cc7Gordon Henriksen void setGC(const char *Str); 1965eca075b74d62c621b160aa216b4cd50829a2cc7Gordon Henriksen void clearGC(); 19780a75bfae980df96f969f1c05b0c4a80ce975240Gordon Henriksen 198afa3b6da11bc05281bcf09e45de9e037e0ee5011Duncan Sands /// @brief Determine whether the function has the given attribute. 199eaf42abab6d465c38891345d999255871cf03943Devang Patel bool paramHasAttr(unsigned i, Attributes attr) const { 2000598866c052147c31b808391f58434ce3dbfb838Devang Patel return AttributeList.paramHasAttr(i, attr); 201d5d94df73f2af639a4cffc7e4f3491001817df08Chris Lattner } 2020bf7b414ae0bb6699cadc3a210d18cfec44e9354Eric Christopher 2030598866c052147c31b808391f58434ce3dbfb838Devang Patel /// addAttribute - adds the attribute to the list of attributes. 2040598866c052147c31b808391f58434ce3dbfb838Devang Patel void addAttribute(unsigned i, Attributes attr); 20550ee9ddc8f0633af6cb0a5693a2c706e98f944daChris Lattner 2060598866c052147c31b808391f58434ce3dbfb838Devang Patel /// removeAttribute - removes the attribute from the list of attributes. 2070598866c052147c31b808391f58434ce3dbfb838Devang Patel void removeAttribute(unsigned i, Attributes attr); 208cfa3c236b23aff80e48df11ef5833b7e63fab802Duncan Sands 20908e78b18b8ef2c939ee95469662c98e23846d860Dale Johannesen /// @brief Extract the alignment for a call or parameter (0=unknown). 210d5d94df73f2af639a4cffc7e4f3491001817df08Chris Lattner unsigned getParamAlignment(unsigned i) const { 2110598866c052147c31b808391f58434ce3dbfb838Devang Patel return AttributeList.getParamAlignment(i); 212d5d94df73f2af639a4cffc7e4f3491001817df08Chris Lattner } 21308e78b18b8ef2c939ee95469662c98e23846d860Dale Johannesen 214a3355ffb3d30d19d226bbb75707991c60f236e37Duncan Sands /// @brief Determine if the function does not access memory. 215d5d94df73f2af639a4cffc7e4f3491001817df08Chris Lattner bool doesNotAccessMemory() const { 21630b64129f5bf03521665115023c9a360a4e67218Nick Lewycky return hasFnAttr(Attribute::ReadNone); 217d5d94df73f2af639a4cffc7e4f3491001817df08Chris Lattner } 21898fd7f6b2f109e16abf3e4279c971f8d3703b8a6Bill Wendling void setDoesNotAccessMemory(bool DoesNotAccessMemory = true) { 21930b64129f5bf03521665115023c9a360a4e67218Nick Lewycky if (DoesNotAccessMemory) addFnAttr(Attribute::ReadNone); 22030b64129f5bf03521665115023c9a360a4e67218Nick Lewycky else removeFnAttr(Attribute::ReadNone); 221cfa3c236b23aff80e48df11ef5833b7e63fab802Duncan Sands } 222a3355ffb3d30d19d226bbb75707991c60f236e37Duncan Sands 223a3355ffb3d30d19d226bbb75707991c60f236e37Duncan Sands /// @brief Determine if the function does not access or only reads memory. 224d5d94df73f2af639a4cffc7e4f3491001817df08Chris Lattner bool onlyReadsMemory() const { 22530b64129f5bf03521665115023c9a360a4e67218Nick Lewycky return doesNotAccessMemory() || hasFnAttr(Attribute::ReadOnly); 226d5d94df73f2af639a4cffc7e4f3491001817df08Chris Lattner } 22798fd7f6b2f109e16abf3e4279c971f8d3703b8a6Bill Wendling void setOnlyReadsMemory(bool OnlyReadsMemory = true) { 22830b64129f5bf03521665115023c9a360a4e67218Nick Lewycky if (OnlyReadsMemory) addFnAttr(Attribute::ReadOnly); 22930b64129f5bf03521665115023c9a360a4e67218Nick Lewycky else removeFnAttr(Attribute::ReadOnly | Attribute::ReadNone); 230cfa3c236b23aff80e48df11ef5833b7e63fab802Duncan Sands } 231cfa3c236b23aff80e48df11ef5833b7e63fab802Duncan Sands 232cfa3c236b23aff80e48df11ef5833b7e63fab802Duncan Sands /// @brief Determine if the function cannot return. 233cfa3c236b23aff80e48df11ef5833b7e63fab802Duncan Sands bool doesNotReturn() const { 23430b64129f5bf03521665115023c9a360a4e67218Nick Lewycky return hasFnAttr(Attribute::NoReturn); 235cfa3c236b23aff80e48df11ef5833b7e63fab802Duncan Sands } 23698fd7f6b2f109e16abf3e4279c971f8d3703b8a6Bill Wendling void setDoesNotReturn(bool DoesNotReturn = true) { 23730b64129f5bf03521665115023c9a360a4e67218Nick Lewycky if (DoesNotReturn) addFnAttr(Attribute::NoReturn); 23830b64129f5bf03521665115023c9a360a4e67218Nick Lewycky else removeFnAttr(Attribute::NoReturn); 239cfa3c236b23aff80e48df11ef5833b7e63fab802Duncan Sands } 240cfa3c236b23aff80e48df11ef5833b7e63fab802Duncan Sands 241cfa3c236b23aff80e48df11ef5833b7e63fab802Duncan Sands /// @brief Determine if the function cannot unwind. 242cfa3c236b23aff80e48df11ef5833b7e63fab802Duncan Sands bool doesNotThrow() const { 24330b64129f5bf03521665115023c9a360a4e67218Nick Lewycky return hasFnAttr(Attribute::NoUnwind); 244cfa3c236b23aff80e48df11ef5833b7e63fab802Duncan Sands } 24598fd7f6b2f109e16abf3e4279c971f8d3703b8a6Bill Wendling void setDoesNotThrow(bool DoesNotThrow = true) { 24630b64129f5bf03521665115023c9a360a4e67218Nick Lewycky if (DoesNotThrow) addFnAttr(Attribute::NoUnwind); 24730b64129f5bf03521665115023c9a360a4e67218Nick Lewycky else removeFnAttr(Attribute::NoUnwind); 248cfa3c236b23aff80e48df11ef5833b7e63fab802Duncan Sands } 249a3355ffb3d30d19d226bbb75707991c60f236e37Duncan Sands 25052f6a4de951edf890c3988c92318b13e45fd3b85Rafael Espindola /// @brief True if the ABI mandates (or the user requested) that this 25152f6a4de951edf890c3988c92318b13e45fd3b85Rafael Espindola /// function be in a unwind table. 252fc2bb8c4448fa884d79e437cc2d2627a7d7740a8Rafael Espindola bool hasUWTable() const { 253fc2bb8c4448fa884d79e437cc2d2627a7d7740a8Rafael Espindola return hasFnAttr(Attribute::UWTable); 254fc2bb8c4448fa884d79e437cc2d2627a7d7740a8Rafael Espindola } 255fc2bb8c4448fa884d79e437cc2d2627a7d7740a8Rafael Espindola void setHasUWTable(bool HasUWTable = true) { 256fc2bb8c4448fa884d79e437cc2d2627a7d7740a8Rafael Espindola if (HasUWTable) 257fc2bb8c4448fa884d79e437cc2d2627a7d7740a8Rafael Espindola addFnAttr(Attribute::UWTable); 258fc2bb8c4448fa884d79e437cc2d2627a7d7740a8Rafael Espindola else 259fc2bb8c4448fa884d79e437cc2d2627a7d7740a8Rafael Espindola removeFnAttr(Attribute::UWTable); 260fc2bb8c4448fa884d79e437cc2d2627a7d7740a8Rafael Espindola } 261fc2bb8c4448fa884d79e437cc2d2627a7d7740a8Rafael Espindola 26252f6a4de951edf890c3988c92318b13e45fd3b85Rafael Espindola /// @brief True if this function needs an unwind table. 263fc2bb8c4448fa884d79e437cc2d2627a7d7740a8Rafael Espindola bool needsUnwindTableEntry() const { 264fc2bb8c4448fa884d79e437cc2d2627a7d7740a8Rafael Espindola return hasUWTable() || !doesNotThrow(); 265fc2bb8c4448fa884d79e437cc2d2627a7d7740a8Rafael Espindola } 266fc2bb8c4448fa884d79e437cc2d2627a7d7740a8Rafael Espindola 26741e2397b720bc5d917ef614a7a6c257e8a3c8e42Devang Patel /// @brief Determine if the function returns a structure through first 26841e2397b720bc5d917ef614a7a6c257e8a3c8e42Devang Patel /// pointer argument. 269d5d94df73f2af639a4cffc7e4f3491001817df08Chris Lattner bool hasStructRetAttr() const { 2700598866c052147c31b808391f58434ce3dbfb838Devang Patel return paramHasAttr(1, Attribute::StructRet); 271d5d94df73f2af639a4cffc7e4f3491001817df08Chris Lattner } 2724746ecf16eeb5ff920672fdff1c0dd85594437edReid Spencer 27330b64129f5bf03521665115023c9a360a4e67218Nick Lewycky /// @brief Determine if the parameter does not alias other parameters. 27430b64129f5bf03521665115023c9a360a4e67218Nick Lewycky /// @param n The parameter to check. 1 is the first parameter, 0 is the return 27530b64129f5bf03521665115023c9a360a4e67218Nick Lewycky bool doesNotAlias(unsigned n) const { 27630b64129f5bf03521665115023c9a360a4e67218Nick Lewycky return paramHasAttr(n, Attribute::NoAlias); 27730b64129f5bf03521665115023c9a360a4e67218Nick Lewycky } 27830b64129f5bf03521665115023c9a360a4e67218Nick Lewycky void setDoesNotAlias(unsigned n, bool DoesNotAlias = true) { 27930b64129f5bf03521665115023c9a360a4e67218Nick Lewycky if (DoesNotAlias) addAttribute(n, Attribute::NoAlias); 28030b64129f5bf03521665115023c9a360a4e67218Nick Lewycky else removeAttribute(n, Attribute::NoAlias); 28130b64129f5bf03521665115023c9a360a4e67218Nick Lewycky } 28230b64129f5bf03521665115023c9a360a4e67218Nick Lewycky 28330b64129f5bf03521665115023c9a360a4e67218Nick Lewycky /// @brief Determine if the parameter can be captured. 28430b64129f5bf03521665115023c9a360a4e67218Nick Lewycky /// @param n The parameter to check. 1 is the first parameter, 0 is the return 28530b64129f5bf03521665115023c9a360a4e67218Nick Lewycky bool doesNotCapture(unsigned n) const { 28630b64129f5bf03521665115023c9a360a4e67218Nick Lewycky return paramHasAttr(n, Attribute::NoCapture); 28730b64129f5bf03521665115023c9a360a4e67218Nick Lewycky } 28830b64129f5bf03521665115023c9a360a4e67218Nick Lewycky void setDoesNotCapture(unsigned n, bool DoesNotCapture = true) { 28930b64129f5bf03521665115023c9a360a4e67218Nick Lewycky if (DoesNotCapture) addAttribute(n, Attribute::NoCapture); 29030b64129f5bf03521665115023c9a360a4e67218Nick Lewycky else removeAttribute(n, Attribute::NoCapture); 29130b64129f5bf03521665115023c9a360a4e67218Nick Lewycky } 29230b64129f5bf03521665115023c9a360a4e67218Nick Lewycky 29328c3cff8250b3fe2adc6479306fe7dbdb48a1bdbDuncan Sands /// copyAttributesFrom - copy all additional attributes (those not needed to 29428c3cff8250b3fe2adc6479306fe7dbdb48a1bdbDuncan Sands /// create a Function) from the Function Src to this one. 29528c3cff8250b3fe2adc6479306fe7dbdb48a1bdbDuncan Sands void copyAttributesFrom(const GlobalValue *Src); 29628c3cff8250b3fe2adc6479306fe7dbdb48a1bdbDuncan Sands 2970c448e58d346201d91767ee27423931101132c9dChris Lattner /// deleteBody - This method deletes the body of the function, and converts 2980c448e58d346201d91767ee27423931101132c9dChris Lattner /// the linkage to external. 29958ae9c7290ff7a639a55784f2362f1e52626c2eeMisha Brukman /// 3000c448e58d346201d91767ee27423931101132c9dChris Lattner void deleteBody() { 3010c448e58d346201d91767ee27423931101132c9dChris Lattner dropAllReferences(); 3020c448e58d346201d91767ee27423931101132c9dChris Lattner setLinkage(ExternalLinkage); 3030c448e58d346201d91767ee27423931101132c9dChris Lattner } 3040c448e58d346201d91767ee27423931101132c9dChris Lattner 305b92f50fe6091a7a12f54f9884529b1127b1a14e5Chris Lattner /// removeFromParent - This method unlinks 'this' from the containing module, 306b92f50fe6091a7a12f54f9884529b1127b1a14e5Chris Lattner /// but does not delete it. 307b92f50fe6091a7a12f54f9884529b1127b1a14e5Chris Lattner /// 30871c8c175fb2a477b90efe745aaf48ed9265300a9Daniel Dunbar virtual void removeFromParent(); 309b92f50fe6091a7a12f54f9884529b1127b1a14e5Chris Lattner 310b92f50fe6091a7a12f54f9884529b1127b1a14e5Chris Lattner /// eraseFromParent - This method unlinks 'this' from the containing module 311b92f50fe6091a7a12f54f9884529b1127b1a14e5Chris Lattner /// and deletes it. 312b92f50fe6091a7a12f54f9884529b1127b1a14e5Chris Lattner /// 31371c8c175fb2a477b90efe745aaf48ed9265300a9Daniel Dunbar virtual void eraseFromParent(); 314b92f50fe6091a7a12f54f9884529b1127b1a14e5Chris Lattner 315b92f50fe6091a7a12f54f9884529b1127b1a14e5Chris Lattner 316fbe3ecdb2cabae81525db3ad8d2d88d584b73fb2Chris Lattner /// Get the underlying elements of the Function... the basic block list is 317fbe3ecdb2cabae81525db3ad8d2d88d584b73fb2Chris Lattner /// empty for external functions. 31826199059268a05739c84ebf465fcdbf7ded861dfChris Lattner /// 3190162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner const ArgumentListType &getArgumentList() const { 3200162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner CheckLazyArguments(); 3210162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner return ArgumentList; 3220162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner } 3230162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner ArgumentListType &getArgumentList() { 3240162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner CheckLazyArguments(); 3250162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner return ArgumentList; 3260162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner } 327b547a181005cc255fa57c61c1c0dbafca5375fb4Gabor Greif static iplist<Argument> Function::*getSublistAccess(Argument*) { 328b547a181005cc255fa57c61c1c0dbafca5375fb4Gabor Greif return &Function::ArgumentList; 329b547a181005cc255fa57c61c1c0dbafca5375fb4Gabor Greif } 3301020b3982c9eae15844c5612b0cf251917931b1dChris Lattner 33118961504fc2b299578dba817900a0696cf3ccc4dChris Lattner const BasicBlockListType &getBasicBlockList() const { return BasicBlocks; } 33218961504fc2b299578dba817900a0696cf3ccc4dChris Lattner BasicBlockListType &getBasicBlockList() { return BasicBlocks; } 333b547a181005cc255fa57c61c1c0dbafca5375fb4Gabor Greif static iplist<BasicBlock> Function::*getSublistAccess(BasicBlock*) { 334b547a181005cc255fa57c61c1c0dbafca5375fb4Gabor Greif return &Function::BasicBlocks; 335b547a181005cc255fa57c61c1c0dbafca5375fb4Gabor Greif } 336009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner 337894707117e718b38cdd5fbbf7b2d2ccfcbafe98bChris Lattner const BasicBlock &getEntryBlock() const { return front(); } 338894707117e718b38cdd5fbbf7b2d2ccfcbafe98bChris Lattner BasicBlock &getEntryBlock() { return front(); } 3398c310c75489a94c6e02b779ae0f611dfd3d63619Chris Lattner 3408c310c75489a94c6e02b779ae0f611dfd3d63619Chris Lattner //===--------------------------------------------------------------------===// 3418c310c75489a94c6e02b779ae0f611dfd3d63619Chris Lattner // Symbol Table Accessing functions... 3428c310c75489a94c6e02b779ae0f611dfd3d63619Chris Lattner 3432c08dcc276e218193beffbddf2a30f4d88e8af58Chris Lattner /// getSymbolTable() - Return the symbol table... 34426199059268a05739c84ebf465fcdbf7ded861dfChris Lattner /// 345ef9b9a793949469cdaa4ab6d0173136229dcab7bReid Spencer inline ValueSymbolTable &getValueSymbolTable() { return *SymTab; } 346ef9b9a793949469cdaa4ab6d0173136229dcab7bReid Spencer inline const ValueSymbolTable &getValueSymbolTable() const { return *SymTab; } 3478c310c75489a94c6e02b779ae0f611dfd3d63619Chris Lattner 3489769ab22265b313171d201b5928688524a01bd87Misha Brukman 3491020b3982c9eae15844c5612b0cf251917931b1dChris Lattner //===--------------------------------------------------------------------===// 3501020b3982c9eae15844c5612b0cf251917931b1dChris Lattner // BasicBlock iterator forwarding functions 3511020b3982c9eae15844c5612b0cf251917931b1dChris Lattner // 35218961504fc2b299578dba817900a0696cf3ccc4dChris Lattner iterator begin() { return BasicBlocks.begin(); } 35318961504fc2b299578dba817900a0696cf3ccc4dChris Lattner const_iterator begin() const { return BasicBlocks.begin(); } 35418961504fc2b299578dba817900a0696cf3ccc4dChris Lattner iterator end () { return BasicBlocks.end(); } 35518961504fc2b299578dba817900a0696cf3ccc4dChris Lattner const_iterator end () const { return BasicBlocks.end(); } 35618961504fc2b299578dba817900a0696cf3ccc4dChris Lattner 357c063502e326fe0206942192773b263a3d88d93f5Chris Lattner size_t size() const { return BasicBlocks.size(); } 35818961504fc2b299578dba817900a0696cf3ccc4dChris Lattner bool empty() const { return BasicBlocks.empty(); } 35918961504fc2b299578dba817900a0696cf3ccc4dChris Lattner const BasicBlock &front() const { return BasicBlocks.front(); } 36018961504fc2b299578dba817900a0696cf3ccc4dChris Lattner BasicBlock &front() { return BasicBlocks.front(); } 3617e302d2f5f6c9b53d0c5017ac3325420b1c8e3d9Misha Brukman const BasicBlock &back() const { return BasicBlocks.back(); } 3627e302d2f5f6c9b53d0c5017ac3325420b1c8e3d9Misha Brukman BasicBlock &back() { return BasicBlocks.back(); } 36318961504fc2b299578dba817900a0696cf3ccc4dChris Lattner 36418961504fc2b299578dba817900a0696cf3ccc4dChris Lattner //===--------------------------------------------------------------------===// 36518961504fc2b299578dba817900a0696cf3ccc4dChris Lattner // Argument iterator forwarding functions 36618961504fc2b299578dba817900a0696cf3ccc4dChris Lattner // 3670162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner arg_iterator arg_begin() { 3680162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner CheckLazyArguments(); 3690162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner return ArgumentList.begin(); 3700162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner } 3710162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner const_arg_iterator arg_begin() const { 3720162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner CheckLazyArguments(); 3730162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner return ArgumentList.begin(); 3740162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner } 3750162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner arg_iterator arg_end() { 3760162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner CheckLazyArguments(); 3770162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner return ArgumentList.end(); 3780162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner } 3790162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner const_arg_iterator arg_end() const { 3800162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner CheckLazyArguments(); 3810162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner return ArgumentList.end(); 3820162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner } 3832427c9dfb3d76f7c71fcc7e9291464d8e6eb1cc2Chris Lattner 3840162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner size_t arg_size() const; 3850162c1815e5a1b33750d313c49f707bc446ea946Chris Lattner bool arg_empty() const; 3862427c9dfb3d76f7c71fcc7e9291464d8e6eb1cc2Chris Lattner 387c149c47d1f98afe504ad69c3456a4de6803015efChris Lattner /// viewCFG - This function is meant for use from the debugger. You can just 388c149c47d1f98afe504ad69c3456a4de6803015efChris Lattner /// say 'call F->viewCFG()' and a ghostview window should pop up from the 389c149c47d1f98afe504ad69c3456a4de6803015efChris Lattner /// program, displaying the CFG of the current function with the code for each 390c149c47d1f98afe504ad69c3456a4de6803015efChris Lattner /// basic block inside. This depends on there being a 'dot' and 'gv' program 391c149c47d1f98afe504ad69c3456a4de6803015efChris Lattner /// in your path. 392c149c47d1f98afe504ad69c3456a4de6803015efChris Lattner /// 393c149c47d1f98afe504ad69c3456a4de6803015efChris Lattner void viewCFG() const; 3949769ab22265b313171d201b5928688524a01bd87Misha Brukman 395c149c47d1f98afe504ad69c3456a4de6803015efChris Lattner /// viewCFGOnly - This function is meant for use from the debugger. It works 396c149c47d1f98afe504ad69c3456a4de6803015efChris Lattner /// just like viewCFG, but it does not include the contents of basic blocks 39758ae9c7290ff7a639a55784f2362f1e52626c2eeMisha Brukman /// into the nodes, just the label. If you are only interested in the CFG 39858ae9c7290ff7a639a55784f2362f1e52626c2eeMisha Brukman /// this can make the graph smaller. 399c149c47d1f98afe504ad69c3456a4de6803015efChris Lattner /// 400c149c47d1f98afe504ad69c3456a4de6803015efChris Lattner void viewCFGOnly() const; 401c149c47d1f98afe504ad69c3456a4de6803015efChris Lattner 40226199059268a05739c84ebf465fcdbf7ded861dfChris Lattner /// Methods for support type inquiry through isa, cast, and dyn_cast: 40379cc5bc9126928dfbca70ec1b09843467ff3d399Chris Lattner static inline bool classof(const Function *) { return true; } 404b00c582b6d40e6b9ff2d1ed4f5eaf7930e792aceChris Lattner static inline bool classof(const Value *V) { 405a1a702cdd23221e6e3f36632be91150138958e9dDan Gohman return V->getValueID() == Value::FunctionVal; 4069636a91649f168f41b477cba705287665e054f79Chris Lattner } 407009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner 4080c448e58d346201d91767ee27423931101132c9dChris Lattner /// dropAllReferences() - This method causes all the subinstructions to "let 40926199059268a05739c84ebf465fcdbf7ded861dfChris Lattner /// go" of all references that they are maintaining. This allows one to 4100c448e58d346201d91767ee27423931101132c9dChris Lattner /// 'delete' a whole module at a time, even though there may be circular 41126199059268a05739c84ebf465fcdbf7ded861dfChris Lattner /// references... first all references are dropped, and all use counts go to 41258ae9c7290ff7a639a55784f2362f1e52626c2eeMisha Brukman /// zero. Then everything is deleted for real. Note that no operations are 4139769ab22265b313171d201b5928688524a01bd87Misha Brukman /// valid on an object that has "dropped all references", except operator 41426199059268a05739c84ebf465fcdbf7ded861dfChris Lattner /// delete. 41526199059268a05739c84ebf465fcdbf7ded861dfChris Lattner /// 4160c448e58d346201d91767ee27423931101132c9dChris Lattner /// Since no other object in the module can have references into the body of a 4170c448e58d346201d91767ee27423931101132c9dChris Lattner /// function, dropping all references deletes the entire body of the function, 4180c448e58d346201d91767ee27423931101132c9dChris Lattner /// including any contained basic blocks. 4190c448e58d346201d91767ee27423931101132c9dChris Lattner /// 420009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner void dropAllReferences(); 421757068f3bad425fb126fe16ab7b8a82a636e6bbdJay Foad 422757068f3bad425fb126fe16ab7b8a82a636e6bbdJay Foad /// hasAddressTaken - returns true if there are any uses of this function 423c9f7500d1752feac7cece26d20007a99d21f677cGabor Greif /// other than direct calls or invokes to it. Optionally passes back the 424c9f7500d1752feac7cece26d20007a99d21f677cGabor Greif /// offending user for diagnostic purposes. 425c9f7500d1752feac7cece26d20007a99d21f677cGabor Greif /// 426c9f7500d1752feac7cece26d20007a99d21f677cGabor Greif bool hasAddressTaken(const User** = 0) const; 427c9f7500d1752feac7cece26d20007a99d21f677cGabor Greif 428c66330504c3f433430a28cd7f7f981e555c51bceEli Friedman /// isDefTriviallyDead - Return true if it is trivially safe to remove 429c66330504c3f433430a28cd7f7f981e555c51bceEli Friedman /// this function definition from the module (because it isn't externally 430c66330504c3f433430a28cd7f7f981e555c51bceEli Friedman /// visible, does not have its address taken, and has no callers). To make 431c66330504c3f433430a28cd7f7f981e555c51bceEli Friedman /// this more accurate, call removeDeadConstantUsers first. 432c66330504c3f433430a28cd7f7f981e555c51bceEli Friedman bool isDefTriviallyDead() const; 433c66330504c3f433430a28cd7f7f981e555c51bceEli Friedman 4343c5e60994f53eef2808a33b5ca6c3dffc2168054Bill Wendling /// callsFunctionThatReturnsTwice - Return true if the function has a call to 4353c5e60994f53eef2808a33b5ca6c3dffc2168054Bill Wendling /// setjmp or other function that gcc recognizes as "returning twice". 4363c5e60994f53eef2808a33b5ca6c3dffc2168054Bill Wendling bool callsFunctionThatReturnsTwice() const; 4373c5e60994f53eef2808a33b5ca6c3dffc2168054Bill Wendling 438cafe9bba32aeed16e8e3db28b4cd4ff13160438fChris Lattnerprivate: 439cafe9bba32aeed16e8e3db28b4cd4ff13160438fChris Lattner // Shadow Value::setValueSubclassData with a private forwarding method so that 440cafe9bba32aeed16e8e3db28b4cd4ff13160438fChris Lattner // subclasses cannot accidentally use it. 441cafe9bba32aeed16e8e3db28b4cd4ff13160438fChris Lattner void setValueSubclassData(unsigned short D) { 442cafe9bba32aeed16e8e3db28b4cd4ff13160438fChris Lattner Value::setValueSubclassData(D); 443cafe9bba32aeed16e8e3db28b4cd4ff13160438fChris Lattner } 4443ff4387113d7e74a8aa73f80c3518cb95f09a64bChris Lattner}; 4453ff4387113d7e74a8aa73f80c3518cb95f09a64bChris Lattner 44617fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattnerinline ValueSymbolTable * 44717fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattnerilist_traits<BasicBlock>::getSymTab(Function *F) { 44817fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattner return F ? &F->getValueSymbolTable() : 0; 44917fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattner} 45017fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattner 45117fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattnerinline ValueSymbolTable * 45217fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattnerilist_traits<Argument>::getSymTab(Function *F) { 45317fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattner return F ? &F->getValueSymbolTable() : 0; 45417fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattner} 45517fcdd5e1b78b829068ca657c97357a39d6e768bChris Lattner 456d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke} // End llvm namespace 457d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke 458009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner#endif 459