llvm.org GIT mirror llvm / 07aae2e
Add an enum for the return and function indexes into the AttrListPtr object. This gets rid of some magic numbers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165924 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 8 years ago
13 changed file(s) with 130 addition(s) and 84 deletion(s). Raw diff Collapse all Expand all
329329 /// AttrListPtr - This class manages the ref count for the opaque
330330 /// AttributeListImpl object and provides accessors for it.
331331 class AttrListPtr {
332 public:
333 enum AttrIndex {
334 ReturnIndex = 0U,
335 FunctionIndex = ~0U
336 };
337 private:
332338 /// AttrList - The attributes that we are managing. This can be null
333339 /// to represent the empty attributes list.
334340 AttributeListImpl *AttrList;
367373 /// getRetAttributes - The attributes for the ret value are
368374 /// returned.
369375 Attributes getRetAttributes() const {
370 return getAttributes(0);
376 return getAttributes(ReturnIndex);
371377 }
372378
373379 /// getFnAttributes - The function attributes are returned.
374380 Attributes getFnAttributes() const {
375 return getAttributes(~0U);
381 return getAttributes(FunctionIndex);
376382 }
377383
378384 /// paramHasAttr - Return true if the specified parameter index has the
12731273 void setIsNoInline() {
12741274 Attributes::Builder B;
12751275 B.addAttribute(Attributes::NoInline);
1276 addAttribute(~0, Attributes::get(getContext(), B));
1276 addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
12771277 }
12781278
12791279 /// @brief Return true if the call can return twice
12831283 void setCanReturnTwice() {
12841284 Attributes::Builder B;
12851285 B.addAttribute(Attributes::ReturnsTwice);
1286 addAttribute(~0U, Attributes::get(getContext(), B));
1286 addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
12871287 }
12881288
12891289 /// @brief Determine if the call does not access memory.
12931293 void setDoesNotAccessMemory() {
12941294 Attributes::Builder B;
12951295 B.addAttribute(Attributes::ReadNone);
1296 addAttribute(~0U, Attributes::get(getContext(), B));
1296 addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
12971297 }
12981298
12991299 /// @brief Determine if the call does not access or only reads memory.
13031303 void setOnlyReadsMemory() {
13041304 Attributes::Builder B;
13051305 B.addAttribute(Attributes::ReadOnly);
1306 addAttribute(~0, Attributes::get(getContext(), B));
1306 addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
13071307 }
13081308
13091309 /// @brief Determine if the call cannot return.
13111311 void setDoesNotReturn() {
13121312 Attributes::Builder B;
13131313 B.addAttribute(Attributes::NoReturn);
1314 addAttribute(~0, Attributes::get(getContext(), B));
1314 addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
13151315 }
13161316
13171317 /// @brief Determine if the call cannot unwind.
13191319 void setDoesNotThrow() {
13201320 Attributes::Builder B;
13211321 B.addAttribute(Attributes::NoUnwind);
1322 addAttribute(~0, Attributes::get(getContext(), B));
1322 addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
13231323 }
13241324
13251325 /// @brief Determine if the call returns a structure through first
30283028 void setIsNoInline() {
30293029 Attributes::Builder B;
30303030 B.addAttribute(Attributes::NoInline);
3031 addAttribute(~0, Attributes::get(getContext(), B));
3031 addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
30323032 }
30333033
30343034 /// @brief Determine if the call does not access memory.
30383038 void setDoesNotAccessMemory() {
30393039 Attributes::Builder B;
30403040 B.addAttribute(Attributes::ReadNone);
3041 addAttribute(~0, Attributes::get(getContext(), B));
3041 addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
30423042 }
30433043
30443044 /// @brief Determine if the call does not access or only reads memory.
30483048 void setOnlyReadsMemory() {
30493049 Attributes::Builder B;
30503050 B.addAttribute(Attributes::ReadOnly);
3051 addAttribute(~0, Attributes::get(getContext(), B));
3051 addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
30523052 }
30533053
30543054 /// @brief Determine if the call cannot return.
30563056 void setDoesNotReturn() {
30573057 Attributes::Builder B;
30583058 B.addAttribute(Attributes::NoReturn);
3059 addAttribute(~0, Attributes::get(getContext(), B));
3059 addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
30603060 }
30613061
30623062 /// @brief Determine if the call cannot unwind.
30643064 void setDoesNotThrow() {
30653065 Attributes::Builder B;
30663066 B.addAttribute(Attributes::NoUnwind);
3067 addAttribute(~0, Attributes::get(getContext(), B));
3067 addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
30683068 }
30693069
30703070 /// @brief Determine if the call returns a structure through first
27702770 SmallVector Attrs;
27712771
27722772 if (RetAttrs.hasAttributes())
2773 Attrs.push_back(AttributeWithIndex::get(0,
2774 Attributes::get(RetType->getContext(),
2775 RetAttrs)));
2773 Attrs.push_back(
2774 AttributeWithIndex::get(AttrListPtr::ReturnIndex,
2775 Attributes::get(RetType->getContext(),
2776 RetAttrs)));
27762777
27772778 for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
27782779 ParamTypeList.push_back(ArgList[i].Ty);
27812782 }
27822783
27832784 if (FuncAttrs.hasAttributes())
2784 Attrs.push_back(AttributeWithIndex::get(~0,
2785 Attributes::get(RetType->getContext(),
2786 FuncAttrs)));
2785 Attrs.push_back(
2786 AttributeWithIndex::get(AttrListPtr::FunctionIndex,
2787 Attributes::get(RetType->getContext(),
2788 FuncAttrs)));
27872789
27882790 AttrListPtr PAL = AttrListPtr::get(Attrs);
27892791
33053307 // Set up the Attributes for the function.
33063308 SmallVector Attrs;
33073309 if (RetAttrs.hasAttributes())
3308 Attrs.push_back(AttributeWithIndex::get(0,
3309 Attributes::get(Callee->getContext(),
3310 RetAttrs)));
3310 Attrs.push_back(
3311 AttributeWithIndex::get(AttrListPtr::ReturnIndex,
3312 Attributes::get(Callee->getContext(),
3313 RetAttrs)));
33113314
33123315 SmallVector Args;
33133316
33353338 return Error(CallLoc, "not enough parameters specified for call");
33363339
33373340 if (FnAttrs.hasAttributes())
3338 Attrs.push_back(AttributeWithIndex::get(~0,
3339 Attributes::get(Callee->getContext(),
3340 FnAttrs)));
3341 Attrs.push_back(
3342 AttributeWithIndex::get(AttrListPtr::FunctionIndex,
3343 Attributes::get(Callee->getContext(),
3344 FnAttrs)));
33413345
33423346 // Finish off the Attributes and check them
33433347 AttrListPtr PAL = AttrListPtr::get(Attrs);
37053709 // Set up the Attributes for the function.
37063710 SmallVector Attrs;
37073711 if (RetAttrs.hasAttributes())
3708 Attrs.push_back(AttributeWithIndex::get(0,
3709 Attributes::get(Callee->getContext(),
3710 RetAttrs)));
3712 Attrs.push_back(
3713 AttributeWithIndex::get(AttrListPtr::ReturnIndex,
3714 Attributes::get(Callee->getContext(),
3715 RetAttrs)));
37113716
37123717 SmallVector Args;
37133718
37353740 return Error(CallLoc, "not enough parameters specified for call");
37363741
37373742 if (FnAttrs.hasAttributes())
3738 Attrs.push_back(AttributeWithIndex::get(~0,
3739 Attributes::get(Callee->getContext(),
3740 FnAttrs)));
3743 Attrs.push_back(
3744 AttributeWithIndex::get(AttrListPtr::FunctionIndex,
3745 Attributes::get(Callee->getContext(),
3746 FnAttrs)));
37413747
37423748 // Finish off the Attributes and check them
37433749 AttrListPtr PAL = AttrListPtr::get(Attrs);
519519 // Add any return attributes.
520520 Attributes attrs = PAL.getRetAttributes();
521521 if (attrs.hasAttributes())
522 AttributesVec.push_back(AttributeWithIndex::get(0, attrs));
522 AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
523 attrs));
523524
524525 // First, determine the new argument list
525526 unsigned ArgIndex = 1;
591592 // Add any function attributes.
592593 attrs = PAL.getFnAttributes();
593594 if (attrs.hasAttributes())
594 AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));
595 AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
596 attrs));
595597
596598 Type *RetTy = FTy->getReturnType();
597599
638640 // Add any return attributes.
639641 Attributes attrs = CallPAL.getRetAttributes();
640642 if (attrs.hasAttributes())
641 AttributesVec.push_back(AttributeWithIndex::get(0, attrs));
643 AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
644 attrs));
642645
643646 // Loop over the operands, inserting GEP and loads in the caller as
644647 // appropriate.
719722 // Add any function attributes.
720723 attrs = CallPAL.getFnAttributes();
721724 if (attrs.hasAttributes())
722 AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));
725 AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
726 attrs));
723727
724728 Instruction *New;
725729 if (InvokeInst *II = dyn_cast(Call)) {
277277 AttributesVec.push_back(PAL.getSlot(i));
278278 Attributes FnAttrs = PAL.getFnAttributes();
279279 if (FnAttrs.hasAttributes())
280 AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
280 AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
281 FnAttrs));
281282 PAL = AttrListPtr::get(AttributesVec);
282283 }
283284
771772 "Return attributes no longer compatible?");
772773
773774 if (RAttrs.hasAttributes())
774 AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
775 AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
776 RAttrs));
775777
776778 // Remember which arguments are still alive.
777779 SmallVector ArgAlive(FTy->getNumParams(), false);
799801 }
800802
801803 if (FnAttrs.hasAttributes())
802 AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
804 AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
805 FnAttrs));
803806
804807 // Reconstruct the AttributesList based on the vector we constructed.
805808 AttrListPtr NewPAL = AttrListPtr::get(AttributesVec);
839842 Attributes::get(NF->getContext(), Attributes::Builder(RAttrs).
840843 removeAttributes(Attributes::typeIncompatible(NF->getReturnType())));
841844 if (RAttrs.hasAttributes())
842 AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
845 AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
846 RAttrs));
843847
844848 // Declare these outside of the loops, so we can reuse them for the second
845849 // loop, which loops the varargs.
865869 }
866870
867871 if (FnAttrs.hasAttributes())
868 AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
872 AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
873 FnAttrs));
869874
870875 // Reconstruct the AttributesList based on the vector we constructed.
871876 AttrListPtr NewCallPAL = AttrListPtr::get(AttributesVec);
214214 Attributes::Builder B;
215215 B.addAttribute(Attributes::ReadOnly)
216216 .addAttribute(Attributes::ReadNone);
217 F->removeAttribute(~0, Attributes::get(F->getContext(), B));
217 F->removeAttribute(AttrListPtr::FunctionIndex,
218 Attributes::get(F->getContext(), B));
218219
219220 // Add in the new attribute.
220221 B.clear();
221222 B.addAttribute(ReadsMemory ? Attributes::ReadOnly : Attributes::ReadNone);
222 F->addAttribute(~0, Attributes::get(F->getContext(), B));
223 F->addAttribute(AttrListPtr::FunctionIndex,
224 Attributes::get(F->getContext(), B));
223225
224226 if (ReadsMemory)
225227 ++NumReadOnly;
11171117 // Add the new return attributes.
11181118 if (RAttrs.hasAttributes())
11191119 attrVec.push_back(
1120 AttributeWithIndex::get(0, Attributes::get(FT->getContext(), RAttrs)));
1120 AttributeWithIndex::get(AttrListPtr::ReturnIndex,
1121 Attributes::get(FT->getContext(), RAttrs)));
11211122
11221123 AI = CS.arg_begin();
11231124 for (unsigned i = 0; i != NumCommonArgs; ++i, ++AI) {
11691170
11701171 Attributes FnAttrs = CallerPAL.getFnAttributes();
11711172 if (FnAttrs.hasAttributes())
1172 attrVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
1173 attrVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
1174 FnAttrs));
11731175
11741176 if (NewRetTy->isVoidTy())
11751177 Caller->setName(""); // Void type should not have a name.
12791281 // Add any result attributes.
12801282 Attributes Attr = Attrs.getRetAttributes();
12811283 if (Attr.hasAttributes())
1282 NewAttrs.push_back(AttributeWithIndex::get(0, Attr));
1284 NewAttrs.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
1285 Attr));
12831286
12841287 {
12851288 unsigned Idx = 1;
13111314 // Add any function attributes.
13121315 Attr = Attrs.getFnAttributes();
13131316 if (Attr.hasAttributes())
1314 NewAttrs.push_back(AttributeWithIndex::get(~0, Attr));
1317 NewAttrs.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
1318 Attr));
13151319
13161320 // The trampoline may have been bitcast to a bogus type (FTy).
13171321 // Handle this by synthesizing a new function type, equal to FTy
17891789 FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
17901790 Attributes::Builder B;
17911791 B.addAttribute(Attributes::NoUnwind);
1792 AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
1793 Attributes::get(M->getContext(), B));
1792 AttrListPtr Attributes =
1793 AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
1794 Attributes::get(M->getContext(), B));
17941795 RetainRVCallee =
17951796 M->getOrInsertFunction("objc_retainAutoreleasedReturnValue", FTy,
17961797 Attributes);
18061807 FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
18071808 Attributes::Builder B;
18081809 B.addAttribute(Attributes::NoUnwind);
1809 AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
1810 Attributes::get(C, B));
1810 AttrListPtr Attributes =
1811 AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
1812 Attributes::get(C, B));
18111813 AutoreleaseRVCallee =
18121814 M->getOrInsertFunction("objc_autoreleaseReturnValue", FTy,
18131815 Attributes);
18211823 Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
18221824 Attributes::Builder B;
18231825 B.addAttribute(Attributes::NoUnwind);
1824 AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
1825 Attributes::get(C, B));
1826 AttrListPtr Attributes =
1827 AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
1828 Attributes::get(C, B));
18261829 ReleaseCallee =
18271830 M->getOrInsertFunction(
18281831 "objc_release",
18381841 Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
18391842 Attributes::Builder B;
18401843 B.addAttribute(Attributes::NoUnwind);
1841 AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
1842 Attributes::get(C, B));
1844 AttrListPtr Attributes =
1845 AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
1846 Attributes::get(C, B));
18431847 RetainCallee =
18441848 M->getOrInsertFunction(
18451849 "objc_retain",
18701874 Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
18711875 Attributes::Builder B;
18721876 B.addAttribute(Attributes::NoUnwind);
1873 AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
1874 Attributes::get(C, B));
1877 AttrListPtr Attributes =
1878 AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
1879 Attributes::get(C, B));
18751880 AutoreleaseCallee =
18761881 M->getOrInsertFunction(
18771882 "objc_autorelease",
38493854 Attributes::Builder BNoCapture;
38503855 BNoCapture.addAttribute(Attributes::NoCapture);
38513856 AttrListPtr Attributes = AttrListPtr()
3852 .addAttr(M->getContext(), ~0u, Attributes::get(C, BNoUnwind))
3857 .addAttr(M->getContext(), AttrListPtr::FunctionIndex,
3858 Attributes::get(C, BNoUnwind))
38533859 .addAttr(M->getContext(), 1, Attributes::get(C, BNoCapture));
38543860
38553861 StoreStrongCallee =
38693875 FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
38703876 Attributes::Builder B;
38713877 B.addAttribute(Attributes::NoUnwind);
3872 AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
3873 Attributes::get(C, B));
3878 AttrListPtr Attributes =
3879 AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
3880 Attributes::get(C, B));
38743881 RetainAutoreleaseCallee =
38753882 M->getOrInsertFunction("objc_retainAutorelease", FTy, Attributes);
38763883 }
38853892 FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
38863893 Attributes::Builder B;
38873894 B.addAttribute(Attributes::NoUnwind);
3888 AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
3889 Attributes::get(C, B));
3895 AttrListPtr Attributes =
3896 AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
3897 Attributes::get(C, B));
38903898 RetainAutoreleaseRVCallee =
38913899 M->getOrInsertFunction("objc_retainAutoreleaseReturnValue", FTy,
38923900 Attributes);
4242 AttributeWithIndex AWI[2];
4343 AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
4444 Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
45 AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u,
45 AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
4646 ArrayRef(AVs, 2));
4747
4848 LLVMContext &Context = B.GetInsertBlock()->getContext();
6969 AttributeWithIndex AWI[2];
7070 AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
7171 Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
72 AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u,
72 AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
7373 ArrayRef(AVs, 2));
7474
7575 LLVMContext &Context = B.GetInsertBlock()->getContext();
9696 Module *M = B.GetInsertBlock()->getParent()->getParent();
9797 Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
9898 AttributeWithIndex AWI =
99 AttributeWithIndex::get(M->getContext(), ~0u,
99 AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
100100 ArrayRef(AVs, 2));
101101
102102 Type *I8Ptr = B.getInt8PtrTy();
122122 AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
123123 AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
124124 Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
125 AWI[2] = AttributeWithIndex::get(M->getContext(), ~0u,
125 AWI[2] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
126126 ArrayRef(AVs, 2));
127127
128128 LLVMContext &Context = B.GetInsertBlock()->getContext();
151151 Module *M = B.GetInsertBlock()->getParent()->getParent();
152152 AttributeWithIndex AWI[2];
153153 AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
154 AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
154 AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
155 Attributes::NoUnwind);
155156 Type *I8Ptr = B.getInt8PtrTy();
156157 Value *StrCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI),
157158 I8Ptr, I8Ptr, I8Ptr, NULL);
173174 Module *M = B.GetInsertBlock()->getParent()->getParent();
174175 AttributeWithIndex AWI[2];
175176 AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
176 AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
177 AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
178 Attributes::NoUnwind);
177179 Type *I8Ptr = B.getInt8PtrTy();
178180 Value *StrNCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI),
179181 I8Ptr, I8Ptr, I8Ptr,
196198
197199 Module *M = B.GetInsertBlock()->getParent()->getParent();
198200 AttributeWithIndex AWI;
199 AWI = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
201 AWI = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
202 Attributes::NoUnwind);
200203 LLVMContext &Context = B.GetInsertBlock()->getContext();
201204 Value *MemCpy = M->getOrInsertFunction("__memcpy_chk",
202205 AttrListPtr::get(AWI),
224227 Module *M = B.GetInsertBlock()->getParent()->getParent();
225228 AttributeWithIndex AWI;
226229 Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
227 AWI = AttributeWithIndex::get(M->getContext(), ~0u,
230 AWI = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
228231 ArrayRef(AVs, 2));
229232 LLVMContext &Context = B.GetInsertBlock()->getContext();
230233 Value *MemChr = M->getOrInsertFunction("memchr", AttrListPtr::get(AWI),
253256 AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
254257 AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
255258 Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
256 AWI[2] = AttributeWithIndex::get(M->getContext(), ~0u,
259 AWI[2] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
257260 ArrayRef(AVs, 2));
258261
259262 LLVMContext &Context = B.GetInsertBlock()->getContext();
331334 Module *M = B.GetInsertBlock()->getParent()->getParent();
332335 AttributeWithIndex AWI[2];
333336 AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
334 AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
337 AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
338 Attributes::NoUnwind);
335339
336340 Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI),
337341 B.getInt32Ty(),
353357 Module *M = B.GetInsertBlock()->getParent()->getParent();
354358 AttributeWithIndex AWI[2];
355359 AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
356 AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
360 AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
361 Attributes::NoUnwind);
357362 Constant *F;
358363 if (File->getType()->isPointerTy())
359364 F = M->getOrInsertFunction("fputc", AttrListPtr::get(AWI),
385390 AttributeWithIndex AWI[3];
386391 AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
387392 AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
388 AWI[2] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
393 AWI[2] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
394 Attributes::NoUnwind);
389395 StringRef FPutsName = TLI->getName(LibFunc::fputs);
390396 Constant *F;
391397 if (File->getType()->isPointerTy())
416422 AttributeWithIndex AWI[3];
417423 AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
418424 AWI[1] = AttributeWithIndex::get(M->getContext(), 4, Attributes::NoCapture);
419 AWI[2] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
425 AWI[2] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
426 Attributes::NoUnwind);
420427 LLVMContext &Context = B.GetInsertBlock()->getContext();
421428 StringRef FWriteName = TLI->getName(LibFunc::fwrite);
422429 Constant *F;
9797 Anew->addAttr( OldFunc->getAttributes()
9898 .getParamAttributes(I->getArgNo() + 1));
9999 NewFunc->setAttributes(NewFunc->getAttributes()
100 .addAttr(NewFunc->getContext(), 0,
100 .addAttr(NewFunc->getContext(),
101 AttrListPtr::ReturnIndex,
101102 OldFunc->getAttributes()
102103 .getRetAttributes()));
103104 NewFunc->setAttributes(NewFunc->getAttributes()
104 .addAttr(NewFunc->getContext(), ~0,
105 .addAttr(NewFunc->getContext(),
106 AttrListPtr::FunctionIndex,
105107 OldFunc->getAttributes()
106108 .getFnAttributes()));
107109
13821382 const AttrListPtr PAL = Func->getAttributes();
13831383 Attributes::Builder B(PA);
13841384 const AttrListPtr PALnew =
1385 PAL.addAttr(Func->getContext(), ~0U,
1385 PAL.addAttr(Func->getContext(), AttrListPtr::FunctionIndex,
13861386 Attributes::get(Func->getContext(), B));
13871387 Func->setAttributes(PALnew);
13881388 }
13921392 const AttrListPtr PAL = Func->getAttributes();
13931393 Attributes::Builder B(PA);
13941394 const AttrListPtr PALnew =
1395 PAL.removeAttr(Func->getContext(), ~0U,
1395 PAL.removeAttr(Func->getContext(), AttrListPtr::FunctionIndex,
13961396 Attributes::get(Func->getContext(), B));
13971397 Func->setAttributes(PALnew);
13981398 }
342342 }
343343
344344 bool CallInst::hasFnAttr(Attributes::AttrVal A) const {
345 if (AttributeList.getParamAttributes(~0U).hasAttribute(A))
345 if (AttributeList.getParamAttributes(AttrListPtr::FunctionIndex)
346 .hasAttribute(A))
346347 return true;
347348 if (const Function *F = getCalledFunction())
348 return F->getParamAttributes(~0U).hasAttribute(A);
349 return F->getParamAttributes(AttrListPtr::FunctionIndex).hasAttribute(A);
349350 return false;
350351 }
351352
570571 }
571572
572573 bool InvokeInst::hasFnAttr(Attributes::AttrVal A) const {
573 if (AttributeList.getParamAttributes(~0U).hasAttribute(A))
574 if (AttributeList.getParamAttributes(AttrListPtr::FunctionIndex).
575 hasAttribute(A))
574576 return true;
575577 if (const Function *F = getCalledFunction())
576 return F->getParamAttributes(~0U).hasAttribute(A);
578 return F->getParamAttributes(AttrListPtr::FunctionIndex).hasAttribute(A);
577579 return false;
578580 }
579581
605605 OS << " AttrVec.push_back(Attributes::ReadNone);\n";
606606 break;
607607 }
608 OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(C, ~0, "
609 << "AttrVec);\n";
608 OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(C, "
609 << "AttrListPtr::FunctionIndex, AttrVec);\n";
610610 }
611611
612612 if (numAttrs) {