LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Function.cpp
Go to the documentation of this file.
1 //===-- Function.cpp - Implement the Global object classes ----------------===//
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 implements the Function class for the IR library.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "llvm/IR/Function.h"
15 #include "LLVMContextImpl.h"
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/ADT/StringExtras.h"
21 #include "llvm/IR/DerivedTypes.h"
22 #include "llvm/IR/IntrinsicInst.h"
23 #include "llvm/IR/LLVMContext.h"
24 #include "llvm/IR/Module.h"
25 #include "llvm/Support/CallSite.h"
29 #include "llvm/Support/RWMutex.h"
31 #include "llvm/Support/Threading.h"
32 using namespace llvm;
33 
34 // Explicit instantiations of SymbolTableListTraits since some of the methods
35 // are not in the public header file...
38 
39 //===----------------------------------------------------------------------===//
40 // Argument Implementation
41 //===----------------------------------------------------------------------===//
42 
43 void Argument::anchor() { }
44 
46  : Value(Ty, Value::ArgumentVal) {
47  Parent = 0;
48 
49  // Make sure that we get added to a function
51 
52  if (Par)
53  Par->getArgumentList().push_back(this);
54  setName(Name);
55 }
56 
57 void Argument::setParent(Function *parent) {
58  if (getParent())
60  Parent = parent;
61  if (getParent())
63 }
64 
65 /// getArgNo - Return the index of this formal argument in its containing
66 /// function. For example in "void foo(int a, float b)" a is 0 and b is 1.
67 unsigned Argument::getArgNo() const {
68  const Function *F = getParent();
69  assert(F && "Argument is not in a function");
70 
72  unsigned ArgIdx = 0;
73  for (; &*AI != this; ++AI)
74  ++ArgIdx;
75 
76  return ArgIdx;
77 }
78 
79 /// hasByValAttr - Return true if this argument has the byval attribute on it
80 /// in its containing function.
81 bool Argument::hasByValAttr() const {
82  if (!getType()->isPointerTy()) return false;
83  return getParent()->getAttributes().
84  hasAttribute(getArgNo()+1, Attribute::ByVal);
85 }
86 
87 unsigned Argument::getParamAlignment() const {
88  assert(getType()->isPointerTy() && "Only pointers have alignments");
89  return getParent()->getParamAlignment(getArgNo()+1);
90 
91 }
92 
93 /// hasNestAttr - Return true if this argument has the nest attribute on
94 /// it in its containing function.
95 bool Argument::hasNestAttr() const {
96  if (!getType()->isPointerTy()) return false;
97  return getParent()->getAttributes().
98  hasAttribute(getArgNo()+1, Attribute::Nest);
99 }
100 
101 /// hasNoAliasAttr - Return true if this argument has the noalias attribute on
102 /// it in its containing function.
104  if (!getType()->isPointerTy()) return false;
105  return getParent()->getAttributes().
106  hasAttribute(getArgNo()+1, Attribute::NoAlias);
107 }
108 
109 /// hasNoCaptureAttr - Return true if this argument has the nocapture attribute
110 /// on it in its containing function.
112  if (!getType()->isPointerTy()) return false;
113  return getParent()->getAttributes().
114  hasAttribute(getArgNo()+1, Attribute::NoCapture);
115 }
116 
117 /// hasSRetAttr - Return true if this argument has the sret attribute on
118 /// it in its containing function.
120  if (!getType()->isPointerTy()) return false;
121  if (this != getParent()->arg_begin())
122  return false; // StructRet param must be first param
123  return getParent()->getAttributes().
124  hasAttribute(1, Attribute::StructRet);
125 }
126 
127 /// hasReturnedAttr - Return true if this argument has the returned attribute on
128 /// it in its containing function.
130  return getParent()->getAttributes().
131  hasAttribute(getArgNo()+1, Attribute::Returned);
132 }
133 
134 /// Return true if this argument has the readonly or readnone attribute on it
135 /// in its containing function.
137  return getParent()->getAttributes().
138  hasAttribute(getArgNo()+1, Attribute::ReadOnly) ||
140  hasAttribute(getArgNo()+1, Attribute::ReadNone);
141 }
142 
143 /// addAttr - Add attributes to an argument.
145  assert(AS.getNumSlots() <= 1 &&
146  "Trying to add more than one attribute set to an argument!");
147  AttrBuilder B(AS, AS.getSlotIndex(0));
149  AttributeSet::get(Parent->getContext(),
150  getArgNo() + 1, B));
151 }
152 
153 /// removeAttr - Remove attributes from an argument.
155  assert(AS.getNumSlots() <= 1 &&
156  "Trying to remove more than one attribute set from an argument!");
157  AttrBuilder B(AS, AS.getSlotIndex(0));
159  AttributeSet::get(Parent->getContext(),
160  getArgNo() + 1, B));
161 }
162 
163 //===----------------------------------------------------------------------===//
164 // Helper Methods in Function
165 //===----------------------------------------------------------------------===//
166 
168  return getType()->getContext();
169 }
170 
172  return cast<FunctionType>(getType()->getElementType());
173 }
174 
175 bool Function::isVarArg() const {
176  return getFunctionType()->isVarArg();
177 }
178 
180  return getFunctionType()->getReturnType();
181 }
182 
184  getParent()->getFunctionList().remove(this);
185 }
186 
188  getParent()->getFunctionList().erase(this);
189 }
190 
191 //===----------------------------------------------------------------------===//
192 // Function Implementation
193 //===----------------------------------------------------------------------===//
194 
195 Function::Function(FunctionType *Ty, LinkageTypes Linkage,
196  const Twine &name, Module *ParentModule)
197  : GlobalValue(PointerType::getUnqual(Ty),
198  Value::FunctionVal, 0, 0, Linkage, name) {
200  "invalid return type");
201  SymTab = new ValueSymbolTable();
202 
203  // If the function has arguments, mark them as lazily built.
204  if (Ty->getNumParams())
205  setValueSubclassData(1); // Set the "has lazy arguments" bit.
206 
207  // Make sure that we get added to a function
209 
210  if (ParentModule)
211  ParentModule->getFunctionList().push_back(this);
212 
213  // Ensure intrinsics have the right parameter attributes.
214  if (unsigned IID = getIntrinsicID())
216 
217 }
218 
220  dropAllReferences(); // After this it is safe to delete instructions.
221 
222  // Delete all of the method arguments and unlink from symbol table...
223  ArgumentList.clear();
224  delete SymTab;
225 
226  // Remove the function from the on-the-side GC table.
227  clearGC();
228 
229  // Remove the intrinsicID from the Cache.
230  if (getValueName() && isIntrinsic())
232 }
233 
234 void Function::BuildLazyArguments() const {
235  // Create the arguments vector, all arguments start out unnamed.
237  for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
238  assert(!FT->getParamType(i)->isVoidTy() &&
239  "Cannot have void typed arguments!");
240  ArgumentList.push_back(new Argument(FT->getParamType(i)));
241  }
242 
243  // Clear the lazy arguments bit.
244  unsigned SDC = getSubclassDataFromValue();
245  const_cast<Function*>(this)->setValueSubclassData(SDC &= ~1);
246 }
247 
248 size_t Function::arg_size() const {
249  return getFunctionType()->getNumParams();
250 }
251 bool Function::arg_empty() const {
252  return getFunctionType()->getNumParams() == 0;
253 }
254 
255 void Function::setParent(Module *parent) {
256  if (getParent())
258  Parent = parent;
259  if (getParent())
261 }
262 
263 // dropAllReferences() - This function causes all the subinstructions to "let
264 // go" of all references that they are maintaining. This allows one to
265 // 'delete' a whole class at a time, even though there may be circular
266 // references... first all references are dropped, and all use counts go to
267 // zero. Then everything is deleted for real. Note that no operations are
268 // valid on an object that has "dropped all references", except operator
269 // delete.
270 //
272  for (iterator I = begin(), E = end(); I != E; ++I)
273  I->dropAllReferences();
274 
275  // Delete all basic blocks. They are now unused, except possibly by
276  // blockaddresses, but BasicBlock's destructor takes care of those.
277  while (!BasicBlocks.empty())
278  BasicBlocks.begin()->eraseFromParent();
279 
280  // Prefix data is stored in a side table.
281  setPrefixData(0);
282 }
283 
285  AttributeSet PAL = getAttributes();
286  PAL = PAL.addAttribute(getContext(), i, attr);
287  setAttributes(PAL);
288 }
289 
290 void Function::addAttributes(unsigned i, AttributeSet attrs) {
291  AttributeSet PAL = getAttributes();
292  PAL = PAL.addAttributes(getContext(), i, attrs);
293  setAttributes(PAL);
294 }
295 
296 void Function::removeAttributes(unsigned i, AttributeSet attrs) {
297  AttributeSet PAL = getAttributes();
298  PAL = PAL.removeAttributes(getContext(), i, attrs);
299  setAttributes(PAL);
300 }
301 
302 // Maintain the GC name for each function in an on-the-side table. This saves
303 // allocating an additional word in Function for programs which do not use GC
304 // (i.e., most programs) at the cost of increased overhead for clients which do
305 // use GC.
309 
310 bool Function::hasGC() const {
312  return GCNames && GCNames->count(this);
313 }
314 
315 const char *Function::getGC() const {
316  assert(hasGC() && "Function has no collector");
318  return *(*GCNames)[this];
319 }
320 
321 void Function::setGC(const char *Str) {
323  if (!GCNamePool)
324  GCNamePool = new StringPool();
325  if (!GCNames)
327  (*GCNames)[this] = GCNamePool->intern(Str);
328 }
329 
332  if (GCNames) {
333  GCNames->erase(this);
334  if (GCNames->empty()) {
335  delete GCNames;
336  GCNames = 0;
337  if (GCNamePool->empty()) {
338  delete GCNamePool;
339  GCNamePool = 0;
340  }
341  }
342  }
343 }
344 
345 /// copyAttributesFrom - copy all additional attributes (those not needed to
346 /// create a Function) from the Function Src to this one.
348  assert(isa<Function>(Src) && "Expected a Function!");
350  const Function *SrcF = cast<Function>(Src);
352  setAttributes(SrcF->getAttributes());
353  if (SrcF->hasGC())
354  setGC(SrcF->getGC());
355  else
356  clearGC();
357  if (SrcF->hasPrefixData())
358  setPrefixData(SrcF->getPrefixData());
359  else
360  setPrefixData(0);
361 }
362 
363 /// getIntrinsicID - This method returns the ID number of the specified
364 /// function, or Intrinsic::not_intrinsic if the function is not an
365 /// intrinsic, or if the pointer is null. This value is always defined to be
366 /// zero to allow easy checking for whether a function is intrinsic or not. The
367 /// particular intrinsic functions which correspond to this value are defined in
368 /// llvm/Intrinsics.h. Results are cached in the LLVM context, subsequent
369 /// requests for the same ID return results much faster from the cache.
370 ///
371 unsigned Function::getIntrinsicID() const {
372  const ValueName *ValName = this->getValueName();
373  if (!ValName || !isIntrinsic())
374  return 0;
375 
376  LLVMContextImpl::IntrinsicIDCacheTy &IntrinsicIDCache =
378  if (!IntrinsicIDCache.count(this)) {
379  unsigned Id = lookupIntrinsicID();
380  IntrinsicIDCache[this]=Id;
381  return Id;
382  }
383  return IntrinsicIDCache[this];
384 }
385 
386 /// This private method does the actual lookup of an intrinsic ID when the query
387 /// could not be answered from the cache.
388 unsigned Function::lookupIntrinsicID() const {
389  const ValueName *ValName = this->getValueName();
390  unsigned Len = ValName->getKeyLength();
391  const char *Name = ValName->getKeyData();
392 
393 #define GET_FUNCTION_RECOGNIZER
394 #include "llvm/IR/Intrinsics.gen"
395 #undef GET_FUNCTION_RECOGNIZER
396 
397  return 0;
398 }
399 
400 std::string Intrinsic::getName(ID id, ArrayRef<Type*> Tys) {
401  assert(id < num_intrinsics && "Invalid intrinsic ID!");
402  static const char * const Table[] = {
403  "not_intrinsic",
404 #define GET_INTRINSIC_NAME_TABLE
405 #include "llvm/IR/Intrinsics.gen"
406 #undef GET_INTRINSIC_NAME_TABLE
407  };
408  if (Tys.empty())
409  return Table[id];
410  std::string Result(Table[id]);
411  for (unsigned i = 0; i < Tys.size(); ++i) {
412  if (PointerType* PTyp = dyn_cast<PointerType>(Tys[i])) {
413  Result += ".p" + llvm::utostr(PTyp->getAddressSpace()) +
414  EVT::getEVT(PTyp->getElementType()).getEVTString();
415  }
416  else if (Tys[i])
417  Result += "." + EVT::getEVT(Tys[i]).getEVTString();
418  }
419  return Result;
420 }
421 
422 
423 /// IIT_Info - These are enumerators that describe the entries returned by the
424 /// getIntrinsicInfoTableEntries function.
425 ///
426 /// NOTE: This must be kept in synch with the copy in TblGen/IntrinsicEmitter!
427 enum IIT_Info {
428  // Common values should be encoded with 0-15.
429  IIT_Done = 0,
430  IIT_I1 = 1,
431  IIT_I8 = 2,
432  IIT_I16 = 3,
433  IIT_I32 = 4,
434  IIT_I64 = 5,
435  IIT_F16 = 6,
436  IIT_F32 = 7,
437  IIT_F64 = 8,
438  IIT_V2 = 9,
439  IIT_V4 = 10,
440  IIT_V8 = 11,
441  IIT_V16 = 12,
442  IIT_V32 = 13,
443  IIT_PTR = 14,
444  IIT_ARG = 15,
445 
446  // Values from 16+ are only encodable with the inefficient encoding.
447  IIT_MMX = 16,
457  IIT_V1 = 26,
459 };
460 
461 
462 static void DecodeIITType(unsigned &NextElt, ArrayRef<unsigned char> Infos,
464  IIT_Info Info = IIT_Info(Infos[NextElt++]);
465  unsigned StructElts = 2;
466  using namespace Intrinsic;
467 
468  switch (Info) {
469  case IIT_Done:
471  return;
472  case IIT_VARARG:
474  return;
475  case IIT_MMX:
477  return;
478  case IIT_METADATA:
480  return;
481  case IIT_F16:
483  return;
484  case IIT_F32:
486  return;
487  case IIT_F64:
489  return;
490  case IIT_I1:
492  return;
493  case IIT_I8:
495  return;
496  case IIT_I16:
498  return;
499  case IIT_I32:
501  return;
502  case IIT_I64:
504  return;
505  case IIT_V1:
507  DecodeIITType(NextElt, Infos, OutputTable);
508  return;
509  case IIT_V2:
511  DecodeIITType(NextElt, Infos, OutputTable);
512  return;
513  case IIT_V4:
515  DecodeIITType(NextElt, Infos, OutputTable);
516  return;
517  case IIT_V8:
519  DecodeIITType(NextElt, Infos, OutputTable);
520  return;
521  case IIT_V16:
523  DecodeIITType(NextElt, Infos, OutputTable);
524  return;
525  case IIT_V32:
527  DecodeIITType(NextElt, Infos, OutputTable);
528  return;
529  case IIT_PTR:
531  DecodeIITType(NextElt, Infos, OutputTable);
532  return;
533  case IIT_ANYPTR: { // [ANYPTR addrspace, subtype]
535  Infos[NextElt++]));
536  DecodeIITType(NextElt, Infos, OutputTable);
537  return;
538  }
539  case IIT_ARG: {
540  unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
542  return;
543  }
544  case IIT_EXTEND_VEC_ARG: {
545  unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
547  ArgInfo));
548  return;
549  }
550  case IIT_TRUNC_VEC_ARG: {
551  unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
553  ArgInfo));
554  return;
555  }
556  case IIT_EMPTYSTRUCT:
558  return;
559  case IIT_STRUCT5: ++StructElts; // FALL THROUGH.
560  case IIT_STRUCT4: ++StructElts; // FALL THROUGH.
561  case IIT_STRUCT3: ++StructElts; // FALL THROUGH.
562  case IIT_STRUCT2: {
563  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Struct,StructElts));
564 
565  for (unsigned i = 0; i != StructElts; ++i)
566  DecodeIITType(NextElt, Infos, OutputTable);
567  return;
568  }
569  }
570  llvm_unreachable("unhandled");
571 }
572 
573 
574 #define GET_INTRINSIC_GENERATOR_GLOBAL
575 #include "llvm/IR/Intrinsics.gen"
576 #undef GET_INTRINSIC_GENERATOR_GLOBAL
577 
580  // Check to see if the intrinsic's type was expressible by the table.
581  unsigned TableVal = IIT_Table[id-1];
582 
583  // Decode the TableVal into an array of IITValues.
585  ArrayRef<unsigned char> IITEntries;
586  unsigned NextElt = 0;
587  if ((TableVal >> 31) != 0) {
588  // This is an offset into the IIT_LongEncodingTable.
589  IITEntries = IIT_LongEncodingTable;
590 
591  // Strip sentinel bit.
592  NextElt = (TableVal << 1) >> 1;
593  } else {
594  // Decode the TableVal into an array of IITValues. If the entry was encoded
595  // into a single word in the table itself, decode it now.
596  do {
597  IITValues.push_back(TableVal & 0xF);
598  TableVal >>= 4;
599  } while (TableVal);
600 
601  IITEntries = IITValues;
602  NextElt = 0;
603  }
604 
605  // Okay, decode the table into the output vector of IITDescriptors.
606  DecodeIITType(NextElt, IITEntries, T);
607  while (NextElt != IITEntries.size() && IITEntries[NextElt] != 0)
608  DecodeIITType(NextElt, IITEntries, T);
609 }
610 
611 
613  ArrayRef<Type*> Tys, LLVMContext &Context) {
614  using namespace Intrinsic;
615  IITDescriptor D = Infos.front();
616  Infos = Infos.slice(1);
617 
618  switch (D.Kind) {
619  case IITDescriptor::Void: return Type::getVoidTy(Context);
620  case IITDescriptor::VarArg: return Type::getVoidTy(Context);
621  case IITDescriptor::MMX: return Type::getX86_MMXTy(Context);
622  case IITDescriptor::Metadata: return Type::getMetadataTy(Context);
623  case IITDescriptor::Half: return Type::getHalfTy(Context);
624  case IITDescriptor::Float: return Type::getFloatTy(Context);
625  case IITDescriptor::Double: return Type::getDoubleTy(Context);
626 
628  return IntegerType::get(Context, D.Integer_Width);
630  return VectorType::get(DecodeFixedType(Infos, Tys, Context),D.Vector_Width);
632  return PointerType::get(DecodeFixedType(Infos, Tys, Context),
633  D.Pointer_AddressSpace);
634  case IITDescriptor::Struct: {
635  Type *Elts[5];
636  assert(D.Struct_NumElements <= 5 && "Can't handle this yet");
637  for (unsigned i = 0, e = D.Struct_NumElements; i != e; ++i)
638  Elts[i] = DecodeFixedType(Infos, Tys, Context);
639  return StructType::get(Context, ArrayRef<Type*>(Elts,D.Struct_NumElements));
640  }
641 
643  return Tys[D.getArgumentNumber()];
645  return VectorType::getExtendedElementVectorType(cast<VectorType>(
646  Tys[D.getArgumentNumber()]));
647 
649  return VectorType::getTruncatedElementVectorType(cast<VectorType>(
650  Tys[D.getArgumentNumber()]));
651  }
652  llvm_unreachable("unhandled");
653 }
654 
655 
656 
658  ID id, ArrayRef<Type*> Tys) {
660  getIntrinsicInfoTableEntries(id, Table);
661 
662  ArrayRef<IITDescriptor> TableRef = Table;
663  Type *ResultTy = DecodeFixedType(TableRef, Tys, Context);
664 
665  SmallVector<Type*, 8> ArgTys;
666  while (!TableRef.empty())
667  ArgTys.push_back(DecodeFixedType(TableRef, Tys, Context));
668 
669  return FunctionType::get(ResultTy, ArgTys, false);
670 }
671 
673 #define GET_INTRINSIC_OVERLOAD_TABLE
674 #include "llvm/IR/Intrinsics.gen"
675 #undef GET_INTRINSIC_OVERLOAD_TABLE
676 }
677 
678 /// This defines the "Intrinsic::getAttributes(ID id)" method.
679 #define GET_INTRINSIC_ATTRIBUTES
680 #include "llvm/IR/Intrinsics.gen"
681 #undef GET_INTRINSIC_ATTRIBUTES
682 
684  // There can never be multiple globals with the same name of different types,
685  // because intrinsics must be a specific type.
686  return
687  cast<Function>(M->getOrInsertFunction(getName(id, Tys),
688  getType(M->getContext(), id, Tys)));
689 }
690 
691 // This defines the "Intrinsic::getIntrinsicForGCCBuiltin()" method.
692 #define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
693 #include "llvm/IR/Intrinsics.gen"
694 #undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
695 
696 /// hasAddressTaken - returns true if there are any uses of this function
697 /// other than direct calls or invokes to it.
698 bool Function::hasAddressTaken(const User* *PutOffender) const {
699  for (Value::const_use_iterator I = use_begin(), E = use_end(); I != E; ++I) {
700  const User *U = *I;
701  if (isa<BlockAddress>(U))
702  continue;
703  if (!isa<CallInst>(U) && !isa<InvokeInst>(U))
704  return PutOffender ? (*PutOffender = U, true) : true;
705  ImmutableCallSite CS(cast<Instruction>(U));
706  if (!CS.isCallee(I))
707  return PutOffender ? (*PutOffender = U, true) : true;
708  }
709  return false;
710 }
711 
713  // Check the linkage
714  if (!hasLinkOnceLinkage() && !hasLocalLinkage() &&
716  return false;
717 
718  // Check if the function is used by anything other than a blockaddress.
719  for (Value::const_use_iterator I = use_begin(), E = use_end(); I != E; ++I)
720  if (!isa<BlockAddress>(*I))
721  return false;
722 
723  return true;
724 }
725 
726 /// callsFunctionThatReturnsTwice - Return true if the function has a call to
727 /// setjmp or other function that gcc recognizes as "returning twice".
730  I = inst_begin(this), E = inst_end(this); I != E; ++I) {
731  const CallInst* callInst = dyn_cast<CallInst>(&*I);
732  if (!callInst)
733  continue;
734  if (callInst->canReturnTwice())
735  return true;
736  }
737 
738  return false;
739 }
740 
742  assert(hasPrefixData());
743  const LLVMContextImpl::PrefixDataMapTy &PDMap =
745  assert(PDMap.find(this) != PDMap.end());
746  return cast<Constant>(PDMap.find(this)->second->getReturnValue());
747 }
748 
750  if (!PrefixData && !hasPrefixData())
751  return;
752 
753  unsigned SCData = getSubclassDataFromValue();
755  ReturnInst *&PDHolder = PDMap[this];
756  if (PrefixData) {
757  if (PDHolder)
758  PDHolder->setOperand(0, PrefixData);
759  else
760  PDHolder = ReturnInst::Create(getContext(), PrefixData);
761  SCData |= 2;
762  } else {
763  delete PDHolder;
764  PDMap.erase(this);
765  SCData &= ~2;
766  }
767  setValueSubclassData(SCData);
768 }
bool hasNoCaptureAttr() const
Return true if this argument has the nocapture attribute on it in its containing function.
Definition: Function.cpp:111
bool hasNoAliasAttr() const
Return true if this argument has the noalias attribute on it in its containing function.
Definition: Function.cpp:103
bool isDefTriviallyDead() const
Definition: Function.cpp:712
use_iterator use_end()
Definition: Value.h:152
static Type * getDoubleTy(LLVMContext &C)
Definition: Type.cpp:231
PooledStringPtr intern(StringRef Str)
Definition: StringPool.cpp:25
LLVMContext & getContext() const
Definition: Function.cpp:167
virtual void copyAttributesFrom(const GlobalValue *Src)
Definition: Globals.cpp:51
LLVM Argument representation.
Definition: Argument.h:35
bool onlyReadsMemory() const
Return true if this argument has the readonly or readnone attribute on it in its containing function...
Definition: Function.cpp:136
The main container class for the LLVM Intermediate Representation.
Definition: Module.h:112
unsigned getNumParams() const
Definition: DerivedTypes.h:133
iterator end()
Definition: Function.h:397
PrefixDataMapTy PrefixDataMap
const T & front() const
front - Get the first element.
Definition: ArrayRef.h:112
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:266
Nested function static chain.
Definition: Attributes.h:79
void clearGC()
Definition: Function.cpp:330
const char * getGC() const
Definition: Function.cpp:315
bool isIntrinsic() const
Definition: Function.h:156
static PointerType * get(Type *ElementType, unsigned AddressSpace)
Definition: Type.cpp:730
bool isOverloaded(ID id)
Definition: Function.cpp:672
bool hasAvailableExternallyLinkage() const
Definition: GlobalValue.h:195
Type * getReturnType() const
Definition: Function.cpp:179
F(f)
static bool isValidReturnType(Type *RetTy)
Definition: Type.cpp:388
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Definition: Function.cpp:657
iterator begin()
Definition: ilist.h:359
static Type * getMetadataTy(LLVMContext &C)
Definition: Type.cpp:232
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
Definition: DerivedTypes.h:395
static Type * getX86_MMXTy(LLVMContext &C)
Definition: Type.cpp:236
virtual void removeFromParent()
Definition: Function.cpp:183
CallingConv::ID getCallingConv() const
Definition: Function.h:161
size_t arg_size() const
Definition: Function.cpp:248
void addAttr(AttributeSet AS)
Add a Attribute to an argument.
Definition: Function.cpp:144
bool empty() const
Definition: StringPool.h:71
static void removeGarbageObject(void *Object)
Definition: LeakDetector.h:47
void push_back(NodeTy *val)
Definition: ilist.h:554
std::string getEVTString() const
getEVTString - This function returns value type as a string, e.g. "i32".
Definition: ValueTypes.cpp:106
inst_iterator inst_begin(Function *F)
Definition: InstIterator.h:128
static Type * getFloatTy(LLVMContext &C)
Definition: Type.cpp:230
static DenseMap< const Function *, PooledStringPtr > * GCNames
Definition: Function.cpp:306
#define llvm_unreachable(msg)
void setName(const Twine &Name)
Definition: Value.cpp:175
void copyAttributesFrom(const GlobalValue *Src)
Definition: Function.cpp:347
ScopedReader - RAII acquisition of a reader lock.
Definition: RWMutex.h:144
Function does not access memory.
Definition: Attributes.h:93
Hidden pointer to structure to return.
Definition: Attributes.h:105
Function creates no aliases of pointer.
Definition: Attributes.h:82
void clear()
Definition: ilist.h:550
void removeAttr(AttributeSet AS)
Remove a Attribute from an argument.
Definition: Function.cpp:154
ScopedWriter - RAII acquisition of a writer lock.
Definition: RWMutex.h:159
IIT_Info
Definition: Function.cpp:427
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
Definition: Type.h:128
bool hasStructRetAttr() const
Return true if this argument has the sret attribute on it in its containing function.
Definition: Function.cpp:119
ArrayRef< T > slice(unsigned N) const
slice(n) - Chop off the first N elements of the array.
Definition: ArrayRef.h:134
static StringPool * GCNamePool
Definition: Function.cpp:307
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
Definition: Type.cpp:361
static std::string utostr(uint64_t X, bool isNeg=false)
Definition: StringExtras.h:88
Pass structure by value.
Definition: Attributes.h:73
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Definition: Function.cpp:683
ValueName * getValueName() const
Definition: Value.h:118
bool hasNestAttr() const
Return true if this argument has the nest attribute on it in its containing function.
Definition: Function.cpp:95
void removeAttributes(unsigned i, AttributeSet attr)
removes the attributes from the list of attributes.
Definition: Function.cpp:296
iterator begin()
Definition: Function.h:395
Type * getElementType() const
Definition: DerivedTypes.h:319
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:109
Considered to not alias after call.
Definition: Attributes.h:80
bool hasAddressTaken(const User **=0) const
Definition: Function.cpp:698
void setCallingConv(CallingConv::ID CC)
Definition: Function.h:164
unsigned getNumSlots() const
Return the number of slots used in this attribute list. This is the number of arguments that have an ...
Definition: Attributes.cpp:906
Type * getParamType(unsigned i) const
Parameter type accessors.
Definition: DerivedTypes.h:128
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeSet AttributeList)
Definition: Module.cpp:138
const Function * getParent() const
Definition: Argument.h:49
unsigned getIntrinsicID() const LLVM_READONLY
Definition: Function.cpp:371
LLVM Constant Representation.
Definition: Constant.h:41
unsigned getParamAlignment() const
If this is a byval argument, return its alignment.
Definition: Function.cpp:87
Return value is always equal to this argument.
Definition: Attributes.h:95
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:227
iterator end()
Definition: DenseMap.h:57
static IITDescriptor get(IITDescriptorKind K, unsigned Field)
Definition: Intrinsics.h:111
arg_iterator arg_begin()
Definition: Function.h:410
bool count(const KeyT &Val) const
count - Return true if the specified key is in the map.
Definition: DenseMap.h:103
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:104
IntrinsicIDCacheTy IntrinsicIDCache
iterator erase(iterator where)
Definition: ilist.h:465
LLVMContextImpl *const pImpl
Definition: LLVMContext.h:39
bool hasByValAttr() const
Return true if this argument has the byval attribute on it in its containing function.
Definition: Function.cpp:81
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
Definition: Module.h:492
static Type * getHalfTy(LLVMContext &C)
Definition: Type.cpp:229
static IntegerType * get(LLVMContext &C, unsigned NumBits)
Get or create an IntegerType instance.
Definition: Type.cpp:305
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
Definition: Type.cpp:405
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Definition: Function.cpp:578
Type * getType() const
Definition: Value.h:111
bool erase(const KeyT &Val)
Definition: DenseMap.h:190
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
Definition: ilist.h:385
void dropAllReferences()
Definition: Function.cpp:271
const char * getKeyData() const
Definition: StringMap.h:140
static VectorType * getExtendedElementVectorType(VectorType *VTy)
Definition: DerivedTypes.h:385
void setOperand(unsigned i, Value *Val)
Definition: User.h:92
AttributeSet getAttributes() const
Return the attribute list for this Function.
Definition: Function.h:170
AttributeSet removeAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Remove the specified attributes at the specified index from this attribute list. Since attribute list...
Definition: Attributes.cpp:739
bool arg_empty() const
Definition: Function.cpp:251
void addAttribute(unsigned i, Attribute::AttrKind attr)
adds the attribute to the list of attributes.
Definition: Function.cpp:284
static void addGarbageObject(void *Object)
Definition: LeakDetector.h:37
Function only reads from memory.
Definition: Attributes.h:94
bool hasGC() const
Definition: Function.cpp:310
void setGC(const char *Str)
Definition: Function.cpp:321
static void DecodeIITType(unsigned &NextElt, ArrayRef< unsigned char > Infos, SmallVectorImpl< Intrinsic::IITDescriptor > &OutputTable)
Definition: Function.cpp:462
use_iterator use_begin()
Definition: Value.h:150
bool hasLinkOnceLinkage() const
Definition: GlobalValue.h:198
PointerType * getType() const
getType - Global values are always pointers.
Definition: GlobalValue.h:107
AttributeSet addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Attr) const
Add an attribute to the attribute set at the given index. Since attribute sets are immutable...
Definition: Attributes.cpp:664
unsigned short getSubclassDataFromValue() const
Definition: Value.h:347
std::string getName(ID id, ArrayRef< Type * > Tys=None)
Definition: Function.cpp:400
unsigned getSlotIndex(unsigned Slot) const
Return the index for the given slot.
Definition: Attributes.cpp:910
ImmutableCallSite - establish a view to a call site for examination.
Definition: CallSite.h:318
#define I(x, y, z)
Definition: MD5.cpp:54
FunctionType * getFunctionType() const
Definition: Function.cpp:171
bool callsFunctionThatReturnsTwice() const
Definition: Function.cpp:728
unsigned getKeyLength() const
Definition: StringMap.h:48
bool hasPrefixData() const
Definition: Function.h:430
virtual void eraseFromParent()
Definition: Function.cpp:187
Constant * getPrefixData() const
Definition: Function.cpp:741
static EVT getEVT(Type *Ty, bool HandleUnknown=false)
Definition: ValueTypes.cpp:275
AttributeSet getAttributes(LLVMContext &C, ID id)
static ReturnInst * Create(LLVMContext &C, Value *retVal=0, Instruction *InsertBefore=0)
static ManagedStatic< sys::SmartRWMutex< true > > GCLock
Definition: Function.cpp:308
void setAttributes(AttributeSet attrs)
Set the attribute list for this Function.
Definition: Function.h:173
bool hasLocalLinkage() const
Definition: GlobalValue.h:211
bool isVarArg() const
Definition: DerivedTypes.h:120
Type * getReturnType() const
Definition: DerivedTypes.h:121
unsigned getParamAlignment(unsigned i) const
Extract the alignment for a call or parameter (0=unknown).
Definition: Function.h:232
static Type * DecodeFixedType(ArrayRef< Intrinsic::IITDescriptor > &Infos, ArrayRef< Type * > Tys, LLVMContext &Context)
Definition: Function.cpp:612
Module * getParent()
Definition: GlobalValue.h:286
LLVM Value Representation.
Definition: Value.h:66
const ArgumentListType & getArgumentList() const
Definition: Function.h:362
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
Definition: Function.cpp:67
static VectorType * get(Type *ElementType, unsigned NumElements)
Definition: Type.cpp:706
inst_iterator inst_end(Function *F)
Definition: InstIterator.h:129
Argument(Type *Ty, const Twine &Name="", Function *F=0)
Constructor.
Definition: Function.cpp:45
void addAttributes(unsigned i, AttributeSet attrs)
adds the attributes to the list of attributes.
Definition: Function.cpp:290
iterator find(const KeyT &Val)
Definition: DenseMap.h:108
AttributeSet addAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Add attributes to the attribute set at the given index. Since attribute sets are immutable, this returns a new set.
Definition: Attributes.cpp:684
bool isVarArg() const
Definition: Function.cpp:175
NodeTy * remove(iterator &IT)
Definition: ilist.h:435
bool hasReturnedAttr() const
Return true if this argument has the returned attribute on it in its containing function.
Definition: Function.cpp:129
friend class ValueSymbolTable
Definition: Value.h:85
bool canReturnTwice() const
Return true if the call can return twice.
LLVMContext & getContext() const
Definition: Module.h:249
bool isVoidTy() const
isVoidTy - Return true if this is 'void'.
Definition: Type.h:140
void setPrefixData(Constant *PrefixData)
Definition: Function.cpp:749