1 //===-- Function.cpp - Implement the Global object classes ----------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the Function class for the IR library.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/IR/Function.h"
15 #include "LLVMContextImpl.h"
16 #include "SymbolTableListTraitsImpl.h"
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/ADT/StringExtras.h"
20 #include "llvm/CodeGen/ValueTypes.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"
26 #include "llvm/Support/InstIterator.h"
27 #include "llvm/Support/LeakDetector.h"
28 #include "llvm/Support/ManagedStatic.h"
29 #include "llvm/Support/RWMutex.h"
30 #include "llvm/Support/StringPool.h"
31 #include "llvm/Support/Threading.h"
34 // Explicit instantiations of SymbolTableListTraits since some of the methods
35 // are not in the public header file...
36 template class llvm::SymbolTableListTraits<Argument, Function>;
37 template class llvm::SymbolTableListTraits<BasicBlock, Function>;
39 //===----------------------------------------------------------------------===//
40 // Argument Implementation
41 //===----------------------------------------------------------------------===//
43 void Argument::anchor() { }
45 Argument::Argument(Type *Ty, const Twine &Name, Function *Par)
46 : Value(Ty, Value::ArgumentVal) {
49 // Make sure that we get added to a function
50 LeakDetector::addGarbageObject(this);
53 Par->getArgumentList().push_back(this);
57 void Argument::setParent(Function *parent) {
59 LeakDetector::addGarbageObject(this);
62 LeakDetector::removeGarbageObject(this);
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");
71 Function::const_arg_iterator AI = F->arg_begin();
73 for (; &*AI != this; ++AI)
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);
87 /// \brief Return true if this argument has the inalloca attribute on it in
88 /// its containing function.
89 bool Argument::hasInAllocaAttr() const {
90 if (!getType()->isPointerTy()) return false;
91 return getParent()->getAttributes().
92 hasAttribute(getArgNo()+1, Attribute::InAlloca);
95 unsigned Argument::getParamAlignment() const {
96 assert(getType()->isPointerTy() && "Only pointers have alignments");
97 return getParent()->getParamAlignment(getArgNo()+1);
101 /// hasNestAttr - Return true if this argument has the nest attribute on
102 /// it in its containing function.
103 bool Argument::hasNestAttr() const {
104 if (!getType()->isPointerTy()) return false;
105 return getParent()->getAttributes().
106 hasAttribute(getArgNo()+1, Attribute::Nest);
109 /// hasNoAliasAttr - Return true if this argument has the noalias attribute on
110 /// it in its containing function.
111 bool Argument::hasNoAliasAttr() const {
112 if (!getType()->isPointerTy()) return false;
113 return getParent()->getAttributes().
114 hasAttribute(getArgNo()+1, Attribute::NoAlias);
117 /// hasNoCaptureAttr - Return true if this argument has the nocapture attribute
118 /// on it in its containing function.
119 bool Argument::hasNoCaptureAttr() const {
120 if (!getType()->isPointerTy()) return false;
121 return getParent()->getAttributes().
122 hasAttribute(getArgNo()+1, Attribute::NoCapture);
125 /// hasSRetAttr - Return true if this argument has the sret attribute on
126 /// it in its containing function.
127 bool Argument::hasStructRetAttr() const {
128 if (!getType()->isPointerTy()) return false;
129 if (this != getParent()->arg_begin())
130 return false; // StructRet param must be first param
131 return getParent()->getAttributes().
132 hasAttribute(1, Attribute::StructRet);
135 /// hasReturnedAttr - Return true if this argument has the returned attribute on
136 /// it in its containing function.
137 bool Argument::hasReturnedAttr() const {
138 return getParent()->getAttributes().
139 hasAttribute(getArgNo()+1, Attribute::Returned);
142 /// Return true if this argument has the readonly or readnone attribute on it
143 /// in its containing function.
144 bool Argument::onlyReadsMemory() const {
145 return getParent()->getAttributes().
146 hasAttribute(getArgNo()+1, Attribute::ReadOnly) ||
147 getParent()->getAttributes().
148 hasAttribute(getArgNo()+1, Attribute::ReadNone);
151 /// addAttr - Add attributes to an argument.
152 void Argument::addAttr(AttributeSet AS) {
153 assert(AS.getNumSlots() <= 1 &&
154 "Trying to add more than one attribute set to an argument!");
155 AttrBuilder B(AS, AS.getSlotIndex(0));
156 getParent()->addAttributes(getArgNo() + 1,
157 AttributeSet::get(Parent->getContext(),
161 /// removeAttr - Remove attributes from an argument.
162 void Argument::removeAttr(AttributeSet AS) {
163 assert(AS.getNumSlots() <= 1 &&
164 "Trying to remove more than one attribute set from an argument!");
165 AttrBuilder B(AS, AS.getSlotIndex(0));
166 getParent()->removeAttributes(getArgNo() + 1,
167 AttributeSet::get(Parent->getContext(),
171 //===----------------------------------------------------------------------===//
172 // Helper Methods in Function
173 //===----------------------------------------------------------------------===//
175 LLVMContext &Function::getContext() const {
176 return getType()->getContext();
179 FunctionType *Function::getFunctionType() const {
180 return cast<FunctionType>(getType()->getElementType());
183 bool Function::isVarArg() const {
184 return getFunctionType()->isVarArg();
187 Type *Function::getReturnType() const {
188 return getFunctionType()->getReturnType();
191 void Function::removeFromParent() {
192 getParent()->getFunctionList().remove(this);
195 void Function::eraseFromParent() {
196 getParent()->getFunctionList().erase(this);
199 //===----------------------------------------------------------------------===//
200 // Function Implementation
201 //===----------------------------------------------------------------------===//
203 Function::Function(FunctionType *Ty, LinkageTypes Linkage,
204 const Twine &name, Module *ParentModule)
205 : GlobalValue(PointerType::getUnqual(Ty),
206 Value::FunctionVal, 0, 0, Linkage, name) {
207 assert(FunctionType::isValidReturnType(getReturnType()) &&
208 "invalid return type");
209 SymTab = new ValueSymbolTable();
211 // If the function has arguments, mark them as lazily built.
212 if (Ty->getNumParams())
213 setValueSubclassData(1); // Set the "has lazy arguments" bit.
215 // Make sure that we get added to a function
216 LeakDetector::addGarbageObject(this);
219 ParentModule->getFunctionList().push_back(this);
221 // Ensure intrinsics have the right parameter attributes.
222 if (unsigned IID = getIntrinsicID())
223 setAttributes(Intrinsic::getAttributes(getContext(), Intrinsic::ID(IID)));
227 Function::~Function() {
228 dropAllReferences(); // After this it is safe to delete instructions.
230 // Delete all of the method arguments and unlink from symbol table...
231 ArgumentList.clear();
234 // Remove the function from the on-the-side GC table.
237 // Remove the intrinsicID from the Cache.
238 if (getValueName() && isIntrinsic())
239 getContext().pImpl->IntrinsicIDCache.erase(this);
242 void Function::BuildLazyArguments() const {
243 // Create the arguments vector, all arguments start out unnamed.
244 FunctionType *FT = getFunctionType();
245 for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
246 assert(!FT->getParamType(i)->isVoidTy() &&
247 "Cannot have void typed arguments!");
248 ArgumentList.push_back(new Argument(FT->getParamType(i)));
251 // Clear the lazy arguments bit.
252 unsigned SDC = getSubclassDataFromValue();
253 const_cast<Function*>(this)->setValueSubclassData(SDC &= ~1);
256 size_t Function::arg_size() const {
257 return getFunctionType()->getNumParams();
259 bool Function::arg_empty() const {
260 return getFunctionType()->getNumParams() == 0;
263 void Function::setParent(Module *parent) {
265 LeakDetector::addGarbageObject(this);
268 LeakDetector::removeGarbageObject(this);
271 // dropAllReferences() - This function causes all the subinstructions to "let
272 // go" of all references that they are maintaining. This allows one to
273 // 'delete' a whole class at a time, even though there may be circular
274 // references... first all references are dropped, and all use counts go to
275 // zero. Then everything is deleted for real. Note that no operations are
276 // valid on an object that has "dropped all references", except operator
279 void Function::dropAllReferences() {
280 for (iterator I = begin(), E = end(); I != E; ++I)
281 I->dropAllReferences();
283 // Delete all basic blocks. They are now unused, except possibly by
284 // blockaddresses, but BasicBlock's destructor takes care of those.
285 while (!BasicBlocks.empty())
286 BasicBlocks.begin()->eraseFromParent();
288 // Prefix data is stored in a side table.
292 void Function::addAttribute(unsigned i, Attribute::AttrKind attr) {
293 AttributeSet PAL = getAttributes();
294 PAL = PAL.addAttribute(getContext(), i, attr);
298 void Function::addAttributes(unsigned i, AttributeSet attrs) {
299 AttributeSet PAL = getAttributes();
300 PAL = PAL.addAttributes(getContext(), i, attrs);
304 void Function::removeAttributes(unsigned i, AttributeSet attrs) {
305 AttributeSet PAL = getAttributes();
306 PAL = PAL.removeAttributes(getContext(), i, attrs);
310 // Maintain the GC name for each function in an on-the-side table. This saves
311 // allocating an additional word in Function for programs which do not use GC
312 // (i.e., most programs) at the cost of increased overhead for clients which do
314 static DenseMap<const Function*,PooledStringPtr> *GCNames;
315 static StringPool *GCNamePool;
316 static ManagedStatic<sys::SmartRWMutex<true> > GCLock;
318 bool Function::hasGC() const {
319 sys::SmartScopedReader<true> Reader(*GCLock);
320 return GCNames && GCNames->count(this);
323 const char *Function::getGC() const {
324 assert(hasGC() && "Function has no collector");
325 sys::SmartScopedReader<true> Reader(*GCLock);
326 return *(*GCNames)[this];
329 void Function::setGC(const char *Str) {
330 sys::SmartScopedWriter<true> Writer(*GCLock);
332 GCNamePool = new StringPool();
334 GCNames = new DenseMap<const Function*,PooledStringPtr>();
335 (*GCNames)[this] = GCNamePool->intern(Str);
338 void Function::clearGC() {
339 sys::SmartScopedWriter<true> Writer(*GCLock);
341 GCNames->erase(this);
342 if (GCNames->empty()) {
345 if (GCNamePool->empty()) {
353 /// copyAttributesFrom - copy all additional attributes (those not needed to
354 /// create a Function) from the Function Src to this one.
355 void Function::copyAttributesFrom(const GlobalValue *Src) {
356 assert(isa<Function>(Src) && "Expected a Function!");
357 GlobalValue::copyAttributesFrom(Src);
358 const Function *SrcF = cast<Function>(Src);
359 setCallingConv(SrcF->getCallingConv());
360 setAttributes(SrcF->getAttributes());
362 setGC(SrcF->getGC());
365 if (SrcF->hasPrefixData())
366 setPrefixData(SrcF->getPrefixData());
371 /// getIntrinsicID - This method returns the ID number of the specified
372 /// function, or Intrinsic::not_intrinsic if the function is not an
373 /// intrinsic, or if the pointer is null. This value is always defined to be
374 /// zero to allow easy checking for whether a function is intrinsic or not. The
375 /// particular intrinsic functions which correspond to this value are defined in
376 /// llvm/Intrinsics.h. Results are cached in the LLVM context, subsequent
377 /// requests for the same ID return results much faster from the cache.
379 unsigned Function::getIntrinsicID() const {
380 const ValueName *ValName = this->getValueName();
381 if (!ValName || !isIntrinsic())
384 LLVMContextImpl::IntrinsicIDCacheTy &IntrinsicIDCache =
385 getContext().pImpl->IntrinsicIDCache;
386 if (!IntrinsicIDCache.count(this)) {
387 unsigned Id = lookupIntrinsicID();
388 IntrinsicIDCache[this]=Id;
391 return IntrinsicIDCache[this];
394 /// This private method does the actual lookup of an intrinsic ID when the query
395 /// could not be answered from the cache.
396 unsigned Function::lookupIntrinsicID() const {
397 const ValueName *ValName = this->getValueName();
398 unsigned Len = ValName->getKeyLength();
399 const char *Name = ValName->getKeyData();
401 #define GET_FUNCTION_RECOGNIZER
402 #include "llvm/IR/Intrinsics.gen"
403 #undef GET_FUNCTION_RECOGNIZER
408 std::string Intrinsic::getName(ID id, ArrayRef<Type*> Tys) {
409 assert(id < num_intrinsics && "Invalid intrinsic ID!");
410 static const char * const Table[] = {
412 #define GET_INTRINSIC_NAME_TABLE
413 #include "llvm/IR/Intrinsics.gen"
414 #undef GET_INTRINSIC_NAME_TABLE
418 std::string Result(Table[id]);
419 for (unsigned i = 0; i < Tys.size(); ++i) {
420 if (PointerType* PTyp = dyn_cast<PointerType>(Tys[i])) {
421 Result += ".p" + llvm::utostr(PTyp->getAddressSpace()) +
422 EVT::getEVT(PTyp->getElementType()).getEVTString();
425 Result += "." + EVT::getEVT(Tys[i]).getEVTString();
431 /// IIT_Info - These are enumerators that describe the entries returned by the
432 /// getIntrinsicInfoTableEntries function.
434 /// NOTE: This must be kept in synch with the copy in TblGen/IntrinsicEmitter!
436 // Common values should be encoded with 0-15.
454 // Values from 16+ are only encodable with the inefficient encoding.
457 IIT_EMPTYSTRUCT = 18,
462 IIT_EXTEND_VEC_ARG = 23,
463 IIT_TRUNC_VEC_ARG = 24,
470 static void DecodeIITType(unsigned &NextElt, ArrayRef<unsigned char> Infos,
471 SmallVectorImpl<Intrinsic::IITDescriptor> &OutputTable) {
472 IIT_Info Info = IIT_Info(Infos[NextElt++]);
473 unsigned StructElts = 2;
474 using namespace Intrinsic;
478 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Void, 0));
481 OutputTable.push_back(IITDescriptor::get(IITDescriptor::VarArg, 0));
484 OutputTable.push_back(IITDescriptor::get(IITDescriptor::MMX, 0));
487 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Metadata, 0));
490 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Half, 0));
493 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Float, 0));
496 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Double, 0));
499 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 1));
502 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 8));
505 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer,16));
508 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 32));
511 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 64));
514 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 1));
515 DecodeIITType(NextElt, Infos, OutputTable);
518 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 2));
519 DecodeIITType(NextElt, Infos, OutputTable);
522 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 4));
523 DecodeIITType(NextElt, Infos, OutputTable);
526 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 8));
527 DecodeIITType(NextElt, Infos, OutputTable);
530 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 16));
531 DecodeIITType(NextElt, Infos, OutputTable);
534 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 32));
535 DecodeIITType(NextElt, Infos, OutputTable);
538 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Pointer, 0));
539 DecodeIITType(NextElt, Infos, OutputTable);
541 case IIT_ANYPTR: { // [ANYPTR addrspace, subtype]
542 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Pointer,
544 DecodeIITType(NextElt, Infos, OutputTable);
548 unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
549 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Argument, ArgInfo));
552 case IIT_EXTEND_VEC_ARG: {
553 unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
554 OutputTable.push_back(IITDescriptor::get(IITDescriptor::ExtendVecArgument,
558 case IIT_TRUNC_VEC_ARG: {
559 unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
560 OutputTable.push_back(IITDescriptor::get(IITDescriptor::TruncVecArgument,
564 case IIT_EMPTYSTRUCT:
565 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Struct, 0));
567 case IIT_STRUCT5: ++StructElts; // FALL THROUGH.
568 case IIT_STRUCT4: ++StructElts; // FALL THROUGH.
569 case IIT_STRUCT3: ++StructElts; // FALL THROUGH.
571 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Struct,StructElts));
573 for (unsigned i = 0; i != StructElts; ++i)
574 DecodeIITType(NextElt, Infos, OutputTable);
578 llvm_unreachable("unhandled");
582 #define GET_INTRINSIC_GENERATOR_GLOBAL
583 #include "llvm/IR/Intrinsics.gen"
584 #undef GET_INTRINSIC_GENERATOR_GLOBAL
586 void Intrinsic::getIntrinsicInfoTableEntries(ID id,
587 SmallVectorImpl<IITDescriptor> &T){
588 // Check to see if the intrinsic's type was expressible by the table.
589 unsigned TableVal = IIT_Table[id-1];
591 // Decode the TableVal into an array of IITValues.
592 SmallVector<unsigned char, 8> IITValues;
593 ArrayRef<unsigned char> IITEntries;
594 unsigned NextElt = 0;
595 if ((TableVal >> 31) != 0) {
596 // This is an offset into the IIT_LongEncodingTable.
597 IITEntries = IIT_LongEncodingTable;
599 // Strip sentinel bit.
600 NextElt = (TableVal << 1) >> 1;
602 // Decode the TableVal into an array of IITValues. If the entry was encoded
603 // into a single word in the table itself, decode it now.
605 IITValues.push_back(TableVal & 0xF);
609 IITEntries = IITValues;
613 // Okay, decode the table into the output vector of IITDescriptors.
614 DecodeIITType(NextElt, IITEntries, T);
615 while (NextElt != IITEntries.size() && IITEntries[NextElt] != 0)
616 DecodeIITType(NextElt, IITEntries, T);
620 static Type *DecodeFixedType(ArrayRef<Intrinsic::IITDescriptor> &Infos,
621 ArrayRef<Type*> Tys, LLVMContext &Context) {
622 using namespace Intrinsic;
623 IITDescriptor D = Infos.front();
624 Infos = Infos.slice(1);
627 case IITDescriptor::Void: return Type::getVoidTy(Context);
628 case IITDescriptor::VarArg: return Type::getVoidTy(Context);
629 case IITDescriptor::MMX: return Type::getX86_MMXTy(Context);
630 case IITDescriptor::Metadata: return Type::getMetadataTy(Context);
631 case IITDescriptor::Half: return Type::getHalfTy(Context);
632 case IITDescriptor::Float: return Type::getFloatTy(Context);
633 case IITDescriptor::Double: return Type::getDoubleTy(Context);
635 case IITDescriptor::Integer:
636 return IntegerType::get(Context, D.Integer_Width);
637 case IITDescriptor::Vector:
638 return VectorType::get(DecodeFixedType(Infos, Tys, Context),D.Vector_Width);
639 case IITDescriptor::Pointer:
640 return PointerType::get(DecodeFixedType(Infos, Tys, Context),
641 D.Pointer_AddressSpace);
642 case IITDescriptor::Struct: {
644 assert(D.Struct_NumElements <= 5 && "Can't handle this yet");
645 for (unsigned i = 0, e = D.Struct_NumElements; i != e; ++i)
646 Elts[i] = DecodeFixedType(Infos, Tys, Context);
647 return StructType::get(Context, ArrayRef<Type*>(Elts,D.Struct_NumElements));
650 case IITDescriptor::Argument:
651 return Tys[D.getArgumentNumber()];
652 case IITDescriptor::ExtendVecArgument:
653 return VectorType::getExtendedElementVectorType(cast<VectorType>(
654 Tys[D.getArgumentNumber()]));
656 case IITDescriptor::TruncVecArgument:
657 return VectorType::getTruncatedElementVectorType(cast<VectorType>(
658 Tys[D.getArgumentNumber()]));
660 llvm_unreachable("unhandled");
665 FunctionType *Intrinsic::getType(LLVMContext &Context,
666 ID id, ArrayRef<Type*> Tys) {
667 SmallVector<IITDescriptor, 8> Table;
668 getIntrinsicInfoTableEntries(id, Table);
670 ArrayRef<IITDescriptor> TableRef = Table;
671 Type *ResultTy = DecodeFixedType(TableRef, Tys, Context);
673 SmallVector<Type*, 8> ArgTys;
674 while (!TableRef.empty())
675 ArgTys.push_back(DecodeFixedType(TableRef, Tys, Context));
677 return FunctionType::get(ResultTy, ArgTys, false);
680 bool Intrinsic::isOverloaded(ID id) {
681 #define GET_INTRINSIC_OVERLOAD_TABLE
682 #include "llvm/IR/Intrinsics.gen"
683 #undef GET_INTRINSIC_OVERLOAD_TABLE
686 /// This defines the "Intrinsic::getAttributes(ID id)" method.
687 #define GET_INTRINSIC_ATTRIBUTES
688 #include "llvm/IR/Intrinsics.gen"
689 #undef GET_INTRINSIC_ATTRIBUTES
691 Function *Intrinsic::getDeclaration(Module *M, ID id, ArrayRef<Type*> Tys) {
692 // There can never be multiple globals with the same name of different types,
693 // because intrinsics must be a specific type.
695 cast<Function>(M->getOrInsertFunction(getName(id, Tys),
696 getType(M->getContext(), id, Tys)));
699 // This defines the "Intrinsic::getIntrinsicForGCCBuiltin()" method.
700 #define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
701 #include "llvm/IR/Intrinsics.gen"
702 #undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
704 /// hasAddressTaken - returns true if there are any uses of this function
705 /// other than direct calls or invokes to it.
706 bool Function::hasAddressTaken(const User* *PutOffender) const {
707 for (Value::const_use_iterator I = use_begin(), E = use_end(); I != E; ++I) {
709 if (isa<BlockAddress>(U))
711 if (!isa<CallInst>(U) && !isa<InvokeInst>(U))
712 return PutOffender ? (*PutOffender = U, true) : true;
713 ImmutableCallSite CS(cast<Instruction>(U));
715 return PutOffender ? (*PutOffender = U, true) : true;
720 bool Function::isDefTriviallyDead() const {
722 if (!hasLinkOnceLinkage() && !hasLocalLinkage() &&
723 !hasAvailableExternallyLinkage())
726 // Check if the function is used by anything other than a blockaddress.
727 for (Value::const_use_iterator I = use_begin(), E = use_end(); I != E; ++I)
728 if (!isa<BlockAddress>(*I))
734 /// callsFunctionThatReturnsTwice - Return true if the function has a call to
735 /// setjmp or other function that gcc recognizes as "returning twice".
736 bool Function::callsFunctionThatReturnsTwice() const {
737 for (const_inst_iterator
738 I = inst_begin(this), E = inst_end(this); I != E; ++I) {
739 const CallInst* callInst = dyn_cast<CallInst>(&*I);
742 if (callInst->canReturnTwice())
749 Constant *Function::getPrefixData() const {
750 assert(hasPrefixData());
751 const LLVMContextImpl::PrefixDataMapTy &PDMap =
752 getContext().pImpl->PrefixDataMap;
753 assert(PDMap.find(this) != PDMap.end());
754 return cast<Constant>(PDMap.find(this)->second->getReturnValue());
757 void Function::setPrefixData(Constant *PrefixData) {
758 if (!PrefixData && !hasPrefixData())
761 unsigned SCData = getSubclassDataFromValue();
762 LLVMContextImpl::PrefixDataMapTy &PDMap = getContext().pImpl->PrefixDataMap;
763 ReturnInst *&PDHolder = PDMap[this];
766 PDHolder->setOperand(0, PrefixData);
768 PDHolder = ReturnInst::Create(getContext(), PrefixData);
775 setValueSubclassData(SCData);