llvm.org GIT mirror llvm / 32a5795
Convert BuildLibCalls.cpp to using the AttributeSet methods instead of AttributeWithIndex. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173536 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 7 years ago
3 changed file(s) with 75 addition(s) and 69 deletion(s). Raw diff Collapse all Expand all
223223 static AttributeSet get(LLVMContext &C, ArrayRef Attrs);
224224 static AttributeSet get(LLVMContext &C, ArrayRef Attrs);
225225 static AttributeSet get(LLVMContext &C, unsigned Idx,
226 Attribute::AttrKind Kind);
226 ArrayRef Kind);
227227 static AttributeSet get(LLVMContext &C, unsigned Idx, AttrBuilder &B);
228228
229229 /// \brief Add an attribute to the attribute set at the given index. Since
604604 }
605605
606606 AttributeSet AttributeSet::get(LLVMContext &C, unsigned Idx,
607 Attribute::AttrKind Kind) {
608 return get(C, AttributeWithIndex::get(Idx, Attribute::get(C, Kind)));
607 ArrayRef Kind) {
608 // FIXME: This is temporary. Ultimately, the AttributeWithIndex will be
609 // replaced by an object that holds multiple Attribute::AttrKinds.
610 AttrBuilder B;
611 for (ArrayRef::iterator I = Kind.begin(),
612 E = Kind.end(); I != E; ++I)
613 B.addAttribute(*I);
614 return get(C, Idx, B);
609615 }
610616
611617 AttributeSet AttributeSet::get(LLVMContext &C, ArrayRef Attrs) {
3737 return 0;
3838
3939 Module *M = B.GetInsertBlock()->getParent()->getParent();
40 AttributeWithIndex AWI[2];
41 AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
40 AttributeSet AS[2];
41 AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
4242 Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
43 AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
44 ArrayRef(AVs, 2));
43 AS[1] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
44 ArrayRef(AVs, 2));
4545
4646 LLVMContext &Context = B.GetInsertBlock()->getContext();
4747 Constant *StrLen = M->getOrInsertFunction("strlen",
4848 AttributeSet::get(M->getContext(),
49 AWI),
49 AS),
5050 TD->getIntPtrType(Context),
5151 B.getInt8PtrTy(),
5252 NULL);
6666 return 0;
6767
6868 Module *M = B.GetInsertBlock()->getParent()->getParent();
69 AttributeWithIndex AWI[2];
70 AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
69 AttributeSet AS[2];
70 AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
7171 Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
72 AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
73 ArrayRef(AVs, 2));
72 AS[1] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
73 ArrayRef(AVs, 2));
7474
7575 LLVMContext &Context = B.GetInsertBlock()->getContext();
7676 Constant *StrNLen = M->getOrInsertFunction("strnlen",
7777 AttributeSet::get(M->getContext(),
78 AWI),
78 AS),
7979 TD->getIntPtrType(Context),
8080 B.getInt8PtrTy(),
8181 TD->getIntPtrType(Context),
9797
9898 Module *M = B.GetInsertBlock()->getParent()->getParent();
9999 Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
100 AttributeWithIndex AWI =
101 AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
102 ArrayRef(AVs, 2));
100 AttributeSet AS =
101 AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
102 ArrayRef(AVs, 2));
103103
104104 Type *I8Ptr = B.getInt8PtrTy();
105105 Type *I32Ty = B.getInt32Ty();
106106 Constant *StrChr = M->getOrInsertFunction("strchr",
107107 AttributeSet::get(M->getContext(),
108 AWI),
108 AS),
109109 I8Ptr, I8Ptr, I32Ty, NULL);
110110 CallInst *CI = B.CreateCall2(StrChr, CastToCStr(Ptr, B),
111111 ConstantInt::get(I32Ty, C), "strchr");
122122 return 0;
123123
124124 Module *M = B.GetInsertBlock()->getParent()->getParent();
125 AttributeWithIndex AWI[3];
126 AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
127 AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture);
125 AttributeSet AS[3];
126 AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
127 AS[1] = AttributeSet::get(M->getContext(), 2, Attribute::NoCapture);
128128 Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
129 AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
130 ArrayRef(AVs, 2));
129 AS[2] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
130 ArrayRef(AVs, 2));
131131
132132 LLVMContext &Context = B.GetInsertBlock()->getContext();
133133 Value *StrNCmp = M->getOrInsertFunction("strncmp",
134134 AttributeSet::get(M->getContext(),
135 AWI),
135 AS),
136136 B.getInt32Ty(),
137137 B.getInt8PtrTy(),
138138 B.getInt8PtrTy(),
155155 return 0;
156156
157157 Module *M = B.GetInsertBlock()->getParent()->getParent();
158 AttributeWithIndex AWI[2];
159 AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture);
160 AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
161 Attribute::NoUnwind);
158 AttributeSet AS[2];
159 AS[0] = AttributeSet::get(M->getContext(), 2, Attribute::NoCapture);
160 AS[1] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
161 Attribute::NoUnwind);
162162 Type *I8Ptr = B.getInt8PtrTy();
163163 Value *StrCpy = M->getOrInsertFunction(Name,
164 AttributeSet::get(M->getContext(), AWI),
164 AttributeSet::get(M->getContext(), AS),
165165 I8Ptr, I8Ptr, I8Ptr, NULL);
166166 CallInst *CI = B.CreateCall2(StrCpy, CastToCStr(Dst, B), CastToCStr(Src, B),
167167 Name);
179179 return 0;
180180
181181 Module *M = B.GetInsertBlock()->getParent()->getParent();
182 AttributeWithIndex AWI[2];
183 AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture);
184 AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
185 Attribute::NoUnwind);
182 AttributeSet AS[2];
183 AS[0] = AttributeSet::get(M->getContext(), 2, Attribute::NoCapture);
184 AS[1] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
185 Attribute::NoUnwind);
186186 Type *I8Ptr = B.getInt8PtrTy();
187187 Value *StrNCpy = M->getOrInsertFunction(Name,
188188 AttributeSet::get(M->getContext(),
189 AWI),
189 AS),
190190 I8Ptr, I8Ptr, I8Ptr,
191191 Len->getType(), NULL);
192192 CallInst *CI = B.CreateCall3(StrNCpy, CastToCStr(Dst, B), CastToCStr(Src, B),
206206 return 0;
207207
208208 Module *M = B.GetInsertBlock()->getParent()->getParent();
209 AttributeWithIndex AWI;
210 AWI = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
211 Attribute::NoUnwind);
209 AttributeSet AS;
210 AS = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
211 Attribute::NoUnwind);
212212 LLVMContext &Context = B.GetInsertBlock()->getContext();
213213 Value *MemCpy = M->getOrInsertFunction("__memcpy_chk",
214 AttributeSet::get(M->getContext(), AWI),
214 AttributeSet::get(M->getContext(), AS),
215215 B.getInt8PtrTy(),
216216 B.getInt8PtrTy(),
217217 B.getInt8PtrTy(),
234234 return 0;
235235
236236 Module *M = B.GetInsertBlock()->getParent()->getParent();
237 AttributeWithIndex AWI;
237 AttributeSet AS;
238238 Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
239 AWI = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
240 ArrayRef(AVs, 2));
239 AS = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
240 ArrayRef(AVs, 2));
241241 LLVMContext &Context = B.GetInsertBlock()->getContext();
242242 Value *MemChr = M->getOrInsertFunction("memchr",
243 AttributeSet::get(M->getContext(), AWI),
243 AttributeSet::get(M->getContext(), AS),
244244 B.getInt8PtrTy(),
245245 B.getInt8PtrTy(),
246246 B.getInt32Ty(),
262262 return 0;
263263
264264 Module *M = B.GetInsertBlock()->getParent()->getParent();
265 AttributeWithIndex AWI[3];
266 AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
267 AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture);
265 AttributeSet AS[3];
266 AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
267 AS[1] = AttributeSet::get(M->getContext(), 2, Attribute::NoCapture);
268268 Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
269 AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
270 ArrayRef(AVs, 2));
269 AS[2] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
270 ArrayRef(AVs, 2));
271271
272272 LLVMContext &Context = B.GetInsertBlock()->getContext();
273273 Value *MemCmp = M->getOrInsertFunction("memcmp",
274 AttributeSet::get(M->getContext(), AWI),
274 AttributeSet::get(M->getContext(), AS),
275275 B.getInt32Ty(),
276276 B.getInt8PtrTy(),
277277 B.getInt8PtrTy(),
343343 return 0;
344344
345345 Module *M = B.GetInsertBlock()->getParent()->getParent();
346 AttributeWithIndex AWI[2];
347 AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
348 AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
349 Attribute::NoUnwind);
346 AttributeSet AS[2];
347 AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
348 AS[1] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
349 Attribute::NoUnwind);
350350
351351 Value *PutS = M->getOrInsertFunction("puts",
352 AttributeSet::get(M->getContext(), AWI),
352 AttributeSet::get(M->getContext(), AS),
353353 B.getInt32Ty(),
354354 B.getInt8PtrTy(),
355355 NULL);
367367 return 0;
368368
369369 Module *M = B.GetInsertBlock()->getParent()->getParent();
370 AttributeWithIndex AWI[2];
371 AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture);
372 AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
373 Attribute::NoUnwind);
370 AttributeSet AS[2];
371 AS[0] = AttributeSet::get(M->getContext(), 2, Attribute::NoCapture);
372 AS[1] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
373 Attribute::NoUnwind);
374374 Constant *F;
375375 if (File->getType()->isPointerTy())
376376 F = M->getOrInsertFunction("fputc",
377 AttributeSet::get(M->getContext(), AWI),
377 AttributeSet::get(M->getContext(), AS),
378378 B.getInt32Ty(),
379379 B.getInt32Ty(), File->getType(),
380380 NULL);
400400 return 0;
401401
402402 Module *M = B.GetInsertBlock()->getParent()->getParent();
403 AttributeWithIndex AWI[3];
404 AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
405 AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture);
406 AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
407 Attribute::NoUnwind);
403 AttributeSet AS[3];
404 AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
405 AS[1] = AttributeSet::get(M->getContext(), 2, Attribute::NoCapture);
406 AS[2] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
407 Attribute::NoUnwind);
408408 StringRef FPutsName = TLI->getName(LibFunc::fputs);
409409 Constant *F;
410410 if (File->getType()->isPointerTy())
411411 F = M->getOrInsertFunction(FPutsName,
412 AttributeSet::get(M->getContext(), AWI),
412 AttributeSet::get(M->getContext(), AS),
413413 B.getInt32Ty(),
414414 B.getInt8PtrTy(),
415415 File->getType(), NULL);
433433 return 0;
434434
435435 Module *M = B.GetInsertBlock()->getParent()->getParent();
436 AttributeWithIndex AWI[3];
437 AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
438 AWI[1] = AttributeWithIndex::get(M->getContext(), 4, Attribute::NoCapture);
439 AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
440 Attribute::NoUnwind);
436 AttributeSet AS[3];
437 AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
438 AS[1] = AttributeSet::get(M->getContext(), 4, Attribute::NoCapture);
439 AS[2] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
440 Attribute::NoUnwind);
441441 LLVMContext &Context = B.GetInsertBlock()->getContext();
442442 StringRef FWriteName = TLI->getName(LibFunc::fwrite);
443443 Constant *F;
444444 if (File->getType()->isPointerTy())
445445 F = M->getOrInsertFunction(FWriteName,
446 AttributeSet::get(M->getContext(), AWI),
446 AttributeSet::get(M->getContext(), AS),
447447 TD->getIntPtrType(Context),
448448 B.getInt8PtrTy(),
449449 TD->getIntPtrType(Context),