llvm.org GIT mirror llvm / ac53a0b
Introduce and use convenience methods for getting pointer types where the element is of a basic builtin type. For example, to get an i8* use getInt8PtrTy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83379 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan Sands 10 years ago
25 changed file(s) with 121 addition(s) and 66 deletion(s). Raw diff Collapse all Expand all
380380 static const IntegerType *getInt32Ty(LLVMContext &C);
381381 static const IntegerType *getInt64Ty(LLVMContext &C);
382382
383 //===--------------------------------------------------------------------===//
384 // Convenience methods for getting pointer types with one of the above builtin
385 // types as pointee.
386 //
387 static const PointerType *getFloatPtrTy(LLVMContext &C, unsigned AS = 0);
388 static const PointerType *getDoublePtrTy(LLVMContext &C, unsigned AS = 0);
389 static const PointerType *getX86_FP80PtrTy(LLVMContext &C, unsigned AS = 0);
390 static const PointerType *getFP128PtrTy(LLVMContext &C, unsigned AS = 0);
391 static const PointerType *getPPC_FP128PtrTy(LLVMContext &C, unsigned AS = 0);
392 static const PointerType *getInt1PtrTy(LLVMContext &C, unsigned AS = 0);
393 static const PointerType *getInt8PtrTy(LLVMContext &C, unsigned AS = 0);
394 static const PointerType *getInt16PtrTy(LLVMContext &C, unsigned AS = 0);
395 static const PointerType *getInt32PtrTy(LLVMContext &C, unsigned AS = 0);
396 static const PointerType *getInt64PtrTy(LLVMContext &C, unsigned AS = 0);
397
383398 /// Methods for support type inquiry through isa, cast, and dyn_cast:
384399 static inline bool classof(const Type *) { return true; }
385400
4747 }
4848
4949 bool PointerTracking::doInitialization(Module &M) {
50 const Type *PTy = PointerType::getUnqual(Type::getInt8Ty(M.getContext()));
50 const Type *PTy = Type::getInt8PtrTy(M.getContext());
5151
5252 // Find calloc(i64, i64) or calloc(i32, i32).
5353 callocFunc = M.getFunction("calloc");
463463 if (!AnyNonZeroIndices) {
464464 // Cast the base to i8*.
465465 V = InsertNoopCastOfTo(V,
466 Type::getInt8Ty(Ty->getContext())->getPointerTo(PTy->getAddressSpace()));
466 Type::getInt8PtrTy(Ty->getContext(), PTy->getAddressSpace()));
467467
468468 // Expand the operands for a plain byte offset.
469469 Value *Idx = expandCodeFor(SE.getAddExpr(Ops), Ty);
235235 if (!RewindFunction) {
236236 LLVMContext &Ctx = UnwindInsts[0]->getContext();
237237 std::vector
238 Params(1, PointerType::getUnqual(Type::getInt8Ty(Ctx)));
238 Params(1, Type::getInt8PtrTy(Ctx));
239239 FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx),
240240 Params, false);
241241 const char *RewindName = TLI->getLibcallName(RTLIB::UNWIND_RESUME);
102102 break;
103103 case Intrinsic::memcpy:
104104 M.getOrInsertFunction("memcpy",
105 PointerType::getUnqual(Type::getInt8Ty(Context)),
106 PointerType::getUnqual(Type::getInt8Ty(Context)),
107 PointerType::getUnqual(Type::getInt8Ty(Context)),
105 Type::getInt8PtrTy(Context),
106 Type::getInt8PtrTy(Context),
107 Type::getInt8PtrTy(Context),
108108 TD.getIntPtrType(Context), (Type *)0);
109109 break;
110110 case Intrinsic::memmove:
111111 M.getOrInsertFunction("memmove",
112 PointerType::getUnqual(Type::getInt8Ty(Context)),
113 PointerType::getUnqual(Type::getInt8Ty(Context)),
114 PointerType::getUnqual(Type::getInt8Ty(Context)),
112 Type::getInt8PtrTy(Context),
113 Type::getInt8PtrTy(Context),
114 Type::getInt8PtrTy(Context),
115115 TD.getIntPtrType(Context), (Type *)0);
116116 break;
117117 case Intrinsic::memset:
118118 M.getOrInsertFunction("memset",
119 PointerType::getUnqual(Type::getInt8Ty(Context)),
120 PointerType::getUnqual(Type::getInt8Ty(Context)),
119 Type::getInt8PtrTy(Context),
120 Type::getInt8PtrTy(Context),
121121 Type::getInt32Ty(M.getContext()),
122122 TD.getIntPtrType(Context), (Type *)0);
123123 break;
4343 // static. For now, we can safely use the global context for the time being to
4444 // squeak by.
4545 PseudoSourceValue::PseudoSourceValue() :
46 Value(PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())),
46 Value(Type::getInt8PtrTy(getGlobalContext()),
4747 PseudoSourceValueVal) {}
4848
4949 void PseudoSourceValue::printCustom(raw_ostream &O) const {
188188
189189 Constant *ShadowStackGC::GetFrameMap(Function &F) {
190190 // doInitialization creates the abstract type of this value.
191 Type *VoidPtr = PointerType::getUnqual(Type::getInt8Ty(F.getContext()));
191 const Type *VoidPtr = Type::getInt8PtrTy(F.getContext());
192192
193193 // Truncate the ShadowStackDescriptor if some metadata is null.
194194 unsigned NumMeta = 0;
8787 // Build the function context structure.
8888 // builtin_setjmp uses a five word jbuf
8989 const Type *VoidPtrTy =
90 PointerType::getUnqual(Type::getInt8Ty(M.getContext()));
90 Type::getInt8PtrTy(M.getContext());
9191 const Type *Int32Ty = Type::getInt32Ty(M.getContext());
9292 FunctionContextTy =
9393 StructType::get(M.getContext(),
377377 // the instruction hasn't already been removed.
378378 if (!I->getParent()) continue;
379379 Value *Val = new LoadInst(ExceptionAddr, "exception", true, I);
380 Type *Ty = PointerType::getUnqual(Type::getInt8Ty(F.getContext()));
380 const Type *Ty = Type::getInt8PtrTy(F.getContext());
381381 Val = CastInst::Create(Instruction::IntToPtr, Val, Ty, "", I);
382382
383383 I->replaceAllUsesWith(Val);
454454 // Call the setjmp instrinsic. It fills in the rest of the jmpbuf
455455 Value *SetjmpArg =
456456 CastInst::Create(Instruction::BitCast, FieldPtr,
457 Type::getInt8Ty(F.getContext())->getPointerTo(), "",
458 EntryBB->getTerminator());
457 Type::getInt8PtrTy(F.getContext()), "",
458 EntryBB->getTerminator());
459459 Value *DispatchVal = CallInst::Create(BuiltinSetjmpFn, SetjmpArg,
460460 "dispatch",
461461 EntryBB->getTerminator());
242242 char *Result = new char[(InputArgv.size()+1)*PtrSize];
243243
244244 DEBUG(errs() << "JIT: ARGV = " << (void*)Result << "\n");
245 const Type *SBytePtr = PointerType::getUnqual(Type::getInt8Ty(C));
245 const Type *SBytePtr = Type::getInt8PtrTy(C);
246246
247247 for (unsigned i = 0; i != InputArgv.size(); ++i) {
248248 unsigned Size = InputArgv[i].size()+1;
101101 {
102102 std::vector AUGs;
103103 const Type *SBP=
104 PointerType::getUnqual(Type::getInt8Ty(M.getContext()));
104 Type::getInt8PtrTy(M.getContext());
105105 for (std::vector::iterator GI = Named.begin(),
106106 GE = Named.end(); GI != GE; ++GI) {
107107 (*GI)->setLinkage(GlobalValue::ExternalLinkage);
200200 // This function is always successful, unless it isn't.
201201 bool LowerSetJmp::doInitialization(Module& M)
202202 {
203 const Type *SBPTy = PointerType::getUnqual(Type::getInt8Ty(M.getContext()));
203 const Type *SBPTy = Type::getInt8PtrTy(M.getContext());
204204 const Type *SBPPTy = PointerType::getUnqual(SBPTy);
205205
206206 // N.B. See llvm/runtime/GCCLibraries/libexception/SJLJ-Exception.h for
265265 void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
266266 {
267267 const Type* SBPTy =
268 PointerType::getUnqual(Type::getInt8Ty(Inst->getContext()));
268 Type::getInt8PtrTy(Inst->getContext());
269269
270270 // Create the call to "__llvm_sjljeh_throw_longjmp". This takes the
271271 // same parameters as "longjmp", except that the buffer is cast to a
318318
319319 // Fill in the alloca and call to initialize the SJ map.
320320 const Type *SBPTy =
321 PointerType::getUnqual(Type::getInt8Ty(Func->getContext()));
321 Type::getInt8PtrTy(Func->getContext());
322322 AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst);
323323 CallInst::Create(InitSJMap, Map, "", Inst);
324324 return SJMap[Func] = Map;
388388
389389 // Add this setjmp to the setjmp map.
390390 const Type* SBPTy =
391 PointerType::getUnqual(Type::getInt8Ty(Inst->getContext()));
391 Type::getInt8PtrTy(Inst->getContext());
392392 CastInst* BufPtr =
393393 new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst);
394394 std::vector Args =
7676
7777 // Get the expected prototype for malloc
7878 const FunctionType *Malloc1Type =
79 FunctionType::get(PointerType::getUnqual(Type::getInt8Ty(M.getContext())),
79 FunctionType::get(Type::getInt8PtrTy(M.getContext()),
8080 std::vector(1,
8181 Type::getInt64Ty(M.getContext())), false);
8282
228228 Value *Source = *CS.arg_begin();
229229 if (!isa(Source->getType()))
230230 Source = new IntToPtrInst(Source,
231 PointerType::getUnqual(Type::getInt8Ty(M.getContext())),
231 Type::getInt8PtrTy(M.getContext()),
232232 "FreePtrCast", I);
233233 new FreeInst(Source, I);
234234
2424 GlobalValue *Array) {
2525 LLVMContext &Context = MainFn->getContext();
2626 const Type *ArgVTy =
27 PointerType::getUnqual(PointerType::getUnqual(Type::getInt8Ty(Context)));
27 PointerType::getUnqual(Type::getInt8PtrTy(Context));
2828 const PointerType *UIntPtr =
29 PointerType::getUnqual(Type::getInt32Ty(Context));
29 Type::getInt32PtrTy(Context);
3030 Module &M = *MainFn->getParent();
3131 Constant *InitFn = M.getOrInsertFunction(FnName, Type::getInt32Ty(Context),
3232 Type::getInt32Ty(Context),
99469946 // If the call and callee calling conventions don't match, this call must
99479947 // be unreachable, as the call is undefined.
99489948 new StoreInst(ConstantInt::getTrue(*Context),
9949 UndefValue::get(PointerType::getUnqual(Type::getInt1Ty(*Context))),
9949 UndefValue::get(Type::getInt1PtrTy(*Context)),
99509950 OldCall);
99519951 if (!OldCall->use_empty())
99529952 OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType()));
99609960 // undef so that we know that this code is not reachable, despite the fact
99619961 // that we can't modify the CFG here.
99629962 new StoreInst(ConstantInt::getTrue(*Context),
9963 UndefValue::get(PointerType::getUnqual(Type::getInt1Ty(*Context))),
9963 UndefValue::get(Type::getInt1PtrTy(*Context)),
99649964 CS.getInstruction());
99659965
99669966 if (!CS.getInstruction()->use_empty())
1123411234 if (isa(Op)) {
1123511235 // Insert a new store to null because we cannot modify the CFG here.
1123611236 new StoreInst(ConstantInt::getTrue(*Context),
11237 UndefValue::get(PointerType::getUnqual(Type::getInt1Ty(*Context))), &FI);
11237 UndefValue::get(Type::getInt1PtrTy(*Context)), &FI);
1123811238 return EraseInstFromFunction(FI);
1123911239 }
1124011240
442442 StartPtr = Range.StartPtr;
443443
444444 // Cast the start ptr to be i8* as memset requires.
445 const Type *i8Ptr = PointerType::getUnqual(Type::getInt8Ty(Context));
445 const Type *i8Ptr = Type::getInt8PtrTy(Context);
446446 if (StartPtr->getType() != i8Ptr)
447447 StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(),
448448 InsertPt);
123123 /// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*.
124124 Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder<> &B) {
125125 return
126 B.CreateBitCast(V, PointerType::getUnqual(Type::getInt8Ty(*Context)), "cstr");
126 B.CreateBitCast(V, Type::getInt8PtrTy(*Context), "cstr");
127127 }
128128
129129 /// EmitStrLen - Emit a call to the strlen function to the builder, for the
137137
138138 Constant *StrLen =M->getOrInsertFunction("strlen", AttrListPtr::get(AWI, 2),
139139 TD->getIntPtrType(*Context),
140 PointerType::getUnqual(Type::getInt8Ty(*Context)),
140 Type::getInt8PtrTy(*Context),
141141 NULL);
142142 CallInst *CI = B.CreateCall(StrLen, CastToCStr(Ptr, B), "strlen");
143143 if (const Function *F = dyn_cast(StrLen->stripPointerCasts()))
168168 AWI = AttributeWithIndex::get(~0u, Attribute::ReadOnly | Attribute::NoUnwind);
169169
170170 Value *MemChr = M->getOrInsertFunction("memchr", AttrListPtr::get(&AWI, 1),
171 PointerType::getUnqual(Type::getInt8Ty(*Context)),
172 PointerType::getUnqual(Type::getInt8Ty(*Context)),
171 Type::getInt8PtrTy(*Context),
172 Type::getInt8PtrTy(*Context),
173173 Type::getInt32Ty(*Context), TD->getIntPtrType(*Context),
174174 NULL);
175175 CallInst *CI = B.CreateCall3(MemChr, CastToCStr(Ptr, B), Val, Len, "memchr");
192192
193193 Value *MemCmp = M->getOrInsertFunction("memcmp", AttrListPtr::get(AWI, 3),
194194 Type::getInt32Ty(*Context),
195 PointerType::getUnqual(Type::getInt8Ty(*Context)),
196 PointerType::getUnqual(Type::getInt8Ty(*Context)),
195 Type::getInt8PtrTy(*Context),
196 Type::getInt8PtrTy(*Context),
197197 TD->getIntPtrType(*Context), NULL);
198198 CallInst *CI = B.CreateCall3(MemCmp, CastToCStr(Ptr1, B), CastToCStr(Ptr2, B),
199199 Len, "memcmp");
272272
273273 Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI, 2),
274274 Type::getInt32Ty(*Context),
275 PointerType::getUnqual(Type::getInt8Ty(*Context)),
275 Type::getInt8PtrTy(*Context),
276276 NULL);
277277 CallInst *CI = B.CreateCall(PutS, CastToCStr(Str, B), "puts");
278278 if (const Function *F = dyn_cast(PutS->stripPointerCasts()))
312312 Constant *F;
313313 if (isa(File->getType()))
314314 F = M->getOrInsertFunction("fputs", AttrListPtr::get(AWI, 3), Type::getInt32Ty(*Context),
315 PointerType::getUnqual(Type::getInt8Ty(*Context)),
315 Type::getInt8PtrTy(*Context),
316316 File->getType(), NULL);
317317 else
318318 F = M->getOrInsertFunction("fputs", Type::getInt32Ty(*Context),
319 PointerType::getUnqual(Type::getInt8Ty(*Context)),
319 Type::getInt8PtrTy(*Context),
320320 File->getType(), NULL);
321321 CallInst *CI = B.CreateCall2(F, CastToCStr(Str, B), File, "fputs");
322322
337337 if (isa(File->getType()))
338338 F = M->getOrInsertFunction("fwrite", AttrListPtr::get(AWI, 3),
339339 TD->getIntPtrType(*Context),
340 PointerType::getUnqual(Type::getInt8Ty(*Context)),
340 Type::getInt8PtrTy(*Context),
341341 TD->getIntPtrType(*Context), TD->getIntPtrType(*Context),
342342 File->getType(), NULL);
343343 else
344344 F = M->getOrInsertFunction("fwrite", TD->getIntPtrType(*Context),
345 PointerType::getUnqual(Type::getInt8Ty(*Context)),
345 Type::getInt8PtrTy(*Context),
346346 TD->getIntPtrType(*Context), TD->getIntPtrType(*Context),
347347 File->getType(), NULL);
348348 CallInst *CI = B.CreateCall4(F, CastToCStr(Ptr, B), Size,
509509 // Verify the "strcat" function prototype.
510510 const FunctionType *FT = Callee->getFunctionType();
511511 if (FT->getNumParams() != 2 ||
512 FT->getReturnType() != PointerType::getUnqual(Type::getInt8Ty(*Context)) ||
512 FT->getReturnType() != Type::getInt8PtrTy(*Context) ||
513513 FT->getParamType(0) != FT->getReturnType() ||
514514 FT->getParamType(1) != FT->getReturnType())
515515 return 0;
559559 // Verify the "strncat" function prototype.
560560 const FunctionType *FT = Callee->getFunctionType();
561561 if (FT->getNumParams() != 3 ||
562 FT->getReturnType() != PointerType::getUnqual(Type::getInt8Ty(*Context)) ||
562 FT->getReturnType() != Type::getInt8PtrTy(*Context) ||
563563 FT->getParamType(0) != FT->getReturnType() ||
564564 FT->getParamType(1) != FT->getReturnType() ||
565565 !isa(FT->getParamType(2)))
607607 // Verify the "strchr" function prototype.
608608 const FunctionType *FT = Callee->getFunctionType();
609609 if (FT->getNumParams() != 2 ||
610 FT->getReturnType() != PointerType::getUnqual(Type::getInt8Ty(*Context)) ||
610 FT->getReturnType() != Type::getInt8PtrTy(*Context) ||
611611 FT->getParamType(0) != FT->getReturnType())
612612 return 0;
613613
665665 const FunctionType *FT = Callee->getFunctionType();
666666 if (FT->getNumParams() != 2 || FT->getReturnType() != Type::getInt32Ty(*Context) ||
667667 FT->getParamType(0) != FT->getParamType(1) ||
668 FT->getParamType(0) != PointerType::getUnqual(Type::getInt8Ty(*Context)))
668 FT->getParamType(0) != Type::getInt8PtrTy(*Context))
669669 return 0;
670670
671671 Value *Str1P = CI->getOperand(1), *Str2P = CI->getOperand(2);
712712 const FunctionType *FT = Callee->getFunctionType();
713713 if (FT->getNumParams() != 3 || FT->getReturnType() != Type::getInt32Ty(*Context) ||
714714 FT->getParamType(0) != FT->getParamType(1) ||
715 FT->getParamType(0) != PointerType::getUnqual(Type::getInt8Ty(*Context)) ||
715 FT->getParamType(0) != Type::getInt8PtrTy(*Context) ||
716716 !isa(FT->getParamType(2)))
717717 return 0;
718718
758758 const FunctionType *FT = Callee->getFunctionType();
759759 if (FT->getNumParams() != 2 || FT->getReturnType() != FT->getParamType(0) ||
760760 FT->getParamType(0) != FT->getParamType(1) ||
761 FT->getParamType(0) != PointerType::getUnqual(Type::getInt8Ty(*Context)))
761 FT->getParamType(0) != Type::getInt8PtrTy(*Context))
762762 return 0;
763763
764764 Value *Dst = CI->getOperand(1), *Src = CI->getOperand(2);
788788 const FunctionType *FT = Callee->getFunctionType();
789789 if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) ||
790790 FT->getParamType(0) != FT->getParamType(1) ||
791 FT->getParamType(0) != PointerType::getUnqual(Type::getInt8Ty(*Context)) ||
791 FT->getParamType(0) != Type::getInt8PtrTy(*Context) ||
792792 !isa(FT->getParamType(2)))
793793 return 0;
794794
836836 virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
837837 const FunctionType *FT = Callee->getFunctionType();
838838 if (FT->getNumParams() != 1 ||
839 FT->getParamType(0) != PointerType::getUnqual(Type::getInt8Ty(*Context)) ||
839 FT->getParamType(0) != Type::getInt8PtrTy(*Context) ||
840840 !isa(FT->getReturnType()))
841841 return 0;
842842
315315 !CalledFunc->onlyReadsMemory()) {
316316 const Type *AggTy = cast(I->getType())->getElementType();
317317 const Type *VoidPtrTy =
318 PointerType::getUnqual(Type::getInt8Ty(Context));
318 Type::getInt8PtrTy(Context);
319319
320320 // Create the alloca. If we have TargetData, use nice alignment.
321321 unsigned Align = 1;
8686 // This function is always successful.
8787 //
8888 bool LowerAllocations::doInitialization(Module &M) {
89 const Type *BPTy = PointerType::getUnqual(Type::getInt8Ty(M.getContext()));
89 const Type *BPTy = Type::getInt8PtrTy(M.getContext());
9090 FreeFunc = M.getOrInsertFunction("free" , Type::getVoidTy(M.getContext()),
9191 BPTy, (Type *)0);
9292 return true;
122122 } else if (FreeInst *FI = dyn_cast(I)) {
123123 Value *PtrCast =
124124 new BitCastInst(FI->getOperand(0),
125 PointerType::getUnqual(Type::getInt8Ty(BB.getContext())), "", I);
125 Type::getInt8PtrTy(BB.getContext()), "", I);
126126
127127 // Insert a call to the free function...
128128 CallInst::Create(FreeFunc, PtrCast, "", I)->setTailCall();
115115 // current module.
116116 bool LowerInvoke::doInitialization(Module &M) {
117117 const Type *VoidPtrTy =
118 PointerType::getUnqual(Type::getInt8Ty(M.getContext()));
118 Type::getInt8PtrTy(M.getContext());
119119 AbortMessage = 0;
120120 if (ExpensiveEHSupport) {
121121 // Insert a type for the linked list of jump buffers.
529529 "TheJmpBuf",
530530 EntryBB->getTerminator());
531531 JmpBufPtr = new BitCastInst(JmpBufPtr,
532 PointerType::getUnqual(Type::getInt8Ty(F.getContext())),
532 Type::getInt8PtrTy(F.getContext()),
533533 "tmp", EntryBB->getTerminator());
534534 Value *SJRet = CallInst::Create(SetJmpFn, JmpBufPtr, "sjret",
535535 EntryBB->getTerminator());
584584 Idx[0] = GetElementPtrInst::Create(BufPtr, Idx.begin(), Idx.end(), "JmpBuf",
585585 UnwindBlock);
586586 Idx[0] = new BitCastInst(Idx[0],
587 PointerType::getUnqual(Type::getInt8Ty(F.getContext())),
587 Type::getInt8PtrTy(F.getContext()),
588588 "tmp", UnwindBlock);
589589 Idx[1] = ConstantInt::get(Type::getInt32Ty(F.getContext()), 1);
590590 CallInst::Create(LongJmpFn, Idx.begin(), Idx.end(), "", UnwindBlock);
264264 if (isLoadH || isLoadL) {
265265 Value *Op1 = UndefValue::get(Op0->getType());
266266 Value *Addr = new BitCastInst(CI->getOperand(2),
267 PointerType::getUnqual(Type::getDoubleTy(C)),
267 Type::getDoublePtrTy(C),
268268 "upgraded.", CI);
269269 Value *Load = new LoadInst(Addr, "upgraded.", false, 8, CI);
270270 Value *Idx = ConstantInt::get(Type::getInt32Ty(C), 0);
497497 // Create the call to Malloc.
498498 BasicBlock* BB = InsertBefore ? InsertBefore->getParent() : InsertAtEnd;
499499 Module* M = BB->getParent()->getParent();
500 const Type *BPTy = PointerType::getUnqual(Type::getInt8Ty(BB->getContext()));
500 const Type *BPTy = Type::getInt8PtrTy(BB->getContext());
501501 // prototype malloc as "void *malloc(size_t)"
502502 Constant *MallocF = M->getOrInsertFunction("malloc", BPTy, IntPtrTy, NULL);
503503 if (!cast(MallocF)->doesNotAlias(0))
355355
356356 const IntegerType *Type::getInt64Ty(LLVMContext &C) {
357357 return &C.pImpl->Int64Ty;
358 }
359
360 const PointerType *Type::getFloatPtrTy(LLVMContext &C, unsigned AS) {
361 return getFloatTy(C)->getPointerTo(AS);
362 }
363
364 const PointerType *Type::getDoublePtrTy(LLVMContext &C, unsigned AS) {
365 return getDoubleTy(C)->getPointerTo(AS);
366 }
367
368 const PointerType *Type::getX86_FP80PtrTy(LLVMContext &C, unsigned AS) {
369 return getX86_FP80Ty(C)->getPointerTo(AS);
370 }
371
372 const PointerType *Type::getFP128PtrTy(LLVMContext &C, unsigned AS) {
373 return getFP128Ty(C)->getPointerTo(AS);
374 }
375
376 const PointerType *Type::getPPC_FP128PtrTy(LLVMContext &C, unsigned AS) {
377 return getPPC_FP128Ty(C)->getPointerTo(AS);
378 }
379
380 const PointerType *Type::getInt1PtrTy(LLVMContext &C, unsigned AS) {
381 return getInt1Ty(C)->getPointerTo(AS);
382 }
383
384 const PointerType *Type::getInt8PtrTy(LLVMContext &C, unsigned AS) {
385 return getInt8Ty(C)->getPointerTo(AS);
386 }
387
388 const PointerType *Type::getInt16PtrTy(LLVMContext &C, unsigned AS) {
389 return getInt16Ty(C)->getPointerTo(AS);
390 }
391
392 const PointerType *Type::getInt32PtrTy(LLVMContext &C, unsigned AS) {
393 return getInt32Ty(C)->getPointerTo(AS);
394 }
395
396 const PointerType *Type::getInt64PtrTy(LLVMContext &C, unsigned AS) {
397 return getInt64Ty(C)->getPointerTo(AS);
358398 }
359399
360400 //===----------------------------------------------------------------------===//
703703 // Prototype: void *getPointerToNamedFunction(const char* Name)
704704 Constant *resolverFunc =
705705 Safe->getOrInsertFunction("getPointerToNamedFunction",
706 PointerType::getUnqual(Type::getInt8Ty(Safe->getContext())),
707 PointerType::getUnqual(Type::getInt8Ty(Safe->getContext())),
706 Type::getInt8PtrTy(Safe->getContext()),
707 Type::getInt8PtrTy(Safe->getContext()),
708708 (Type *)0);
709709
710710 // Use the function we just added to get addresses of functions we need.
1919 EXPECT_EQ(Type::getVoidTy(getGlobalContext()), (TypeBuilder::get(getGlobalContext())));
2020 EXPECT_EQ(Type::getVoidTy(getGlobalContext()), (TypeBuilder::get(getGlobalContext())));
2121 // Special case for C compatibility:
22 EXPECT_EQ(PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())),
22 EXPECT_EQ(Type::getInt8PtrTy(getGlobalContext()),
2323 (TypeBuilder::get(getGlobalContext())));
2424 }
2525
6363 }
6464
6565 TEST(TypeBuilderTest, Derived) {
66 EXPECT_EQ(PointerType::getUnqual(PointerType::getUnqual(Type::getInt8Ty(getGlobalContext()))),
66 EXPECT_EQ(PointerType::getUnqual(Type::getInt8PtrTy(getGlobalContext())),
6767 (TypeBuilder::get(getGlobalContext())));
6868 EXPECT_EQ(ArrayType::get(Type::getInt8Ty(getGlobalContext()), 7),
6969 (TypeBuilder::get(getGlobalContext())));
7070 EXPECT_EQ(ArrayType::get(Type::getInt8Ty(getGlobalContext()), 0),
7171 (TypeBuilder::get(getGlobalContext())));
7272
73 EXPECT_EQ(PointerType::getUnqual(PointerType::getUnqual(Type::getInt8Ty(getGlobalContext()))),
73 EXPECT_EQ(PointerType::getUnqual(Type::getInt8PtrTy(getGlobalContext())),
7474 (TypeBuilder**, false>::get(getGlobalContext())));
7575 EXPECT_EQ(ArrayType::get(Type::getInt8Ty(getGlobalContext()), 7),
7676 (TypeBuilder[7], false>::get(getGlobalContext())));
7777 EXPECT_EQ(ArrayType::get(Type::getInt8Ty(getGlobalContext()), 0),
7878 (TypeBuilder[], false>::get(getGlobalContext())));
7979
80 EXPECT_EQ(PointerType::getUnqual(PointerType::getUnqual(Type::getInt8Ty(getGlobalContext()))),
80 EXPECT_EQ(PointerType::getUnqual(Type::getInt8PtrTy(getGlobalContext())),
8181 (TypeBuilder**, true>::get(getGlobalContext())));
8282 EXPECT_EQ(ArrayType::get(Type::getInt8Ty(getGlobalContext()), 7),
8383 (TypeBuilder[7], true>::get(getGlobalContext())));
106106 EXPECT_EQ(Type::getInt8Ty(getGlobalContext()),
107107 (TypeBuilder, true>::get(getGlobalContext())));
108108
109 EXPECT_EQ(PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())),
109 EXPECT_EQ(Type::getInt8PtrTy(getGlobalContext()),
110110 (TypeBuilder::get(getGlobalContext())));
111111 }
112112
6363
6464 TEST(CloneInstruction, Inbounds) {
6565 LLVMContext context;
66 Value *V = new Argument(Type::getInt32Ty(context)->getPointerTo());
66 Value *V = new Argument(Type::getInt32PtrTy(context));
6767 Constant *Z = Constant::getNullValue(Type::getInt32Ty(context));
6868 std::vector ops;
6969 ops.push_back(Z);