llvm.org GIT mirror llvm / 43ad6b3
Change the PointerType api for creating pointer types. The old functionality of PointerType::get() has become PointerType::getUnqual(), which returns a pointer in the generic address space. The new prototype of PointerType::get() requires both a type and an address space. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45082 91177308-0d34-0410-b5e6-96231b3b80d8 Christopher Lamb 11 years ago
32 changed file(s) with 172 addition(s) and 137 deletion(s). Raw diff Collapse all Expand all
5353 //declare void @llvm.memset.i32(i8 *, i8, i32, i32)
5454 Function *memset_func = cast(module->
5555 getOrInsertFunction("llvm.memset.i32", Type::VoidTy,
56 PointerType::get(IntegerType::Int8Ty),
56 PointerType::getUnqual(IntegerType::Int8Ty),
5757 IntegerType::Int8Ty, IntegerType::Int32Ty,
5858 IntegerType::Int32Ty, NULL));
5959
137137 //declare i32 @puts(i8 *)
138138 Function *puts_func = cast(module->
139139 getOrInsertFunction("puts", IntegerType::Int32Ty,
140 PointerType::get(IntegerType::Int8Ty), NULL));
140 PointerType::getUnqual(IntegerType::Int8Ty), NULL));
141141
142142 //brainf.aberror:
143143 aberrorbb = new BasicBlock(label, brainf_func);
281281 builder->SetInsertPoint(bb_1);
282282
283283 //Make part of PHI instruction now, wait until end of loop to finish
284 PHINode *phi_0 = new PHINode(PointerType::get(IntegerType::Int8Ty),
284 PHINode *phi_0 = new PHINode(PointerType::getUnqual(IntegerType::Int8Ty),
285285 headreg, testbb);
286286 phi_0->reserveOperandSpace(2);
287287 phi_0->addIncoming(curhead, bb_0);
438438
439439 //%head.%d = phi i8 *[%head.%d, %main.%d]
440440 PHINode *phi_1 = builder->
441 CreatePHI(PointerType::get(IntegerType::Int8Ty), headreg);
441 CreatePHI(PointerType::getUnqual(IntegerType::Int8Ty), headreg);
442442 phi_1->reserveOperandSpace(1);
443443 phi_1->addIncoming(head_0, testbb);
444444 curhead = phi_1;
5858 //define i32 @main(i32 %argc, i8 **%argv)
5959 Function *main_func = cast(mod->
6060 getOrInsertFunction("main", IntegerType::Int32Ty, IntegerType::Int32Ty,
61 PointerType::get(PointerType::get(
61 PointerType::getUnqual(PointerType::getUnqual(
6262 IntegerType::Int8Ty)), NULL));
6363 {
6464 Function::arg_iterator args = main_func->arg_begin();
368368 const PointerType &operator=(const PointerType &); // Do not implement
369369 explicit PointerType(const Type *ElType, unsigned AddrSpace);
370370 public:
371 /// PointerType::get - This is the only way to construct a new pointer type.
372 static PointerType *get(const Type *ElementType, unsigned AddressSpace = 0);
371 /// PointerType::get - This constructs a pointer to an object of the specified
372 /// type in a numbered address space.
373 static PointerType *get(const Type *ElementType, unsigned AddressSpace);
374
375 /// PointerType::getUnqual - This constructs a pointer to an object of the
376 /// specified type in the generic address space (address space zero).
377 static PointerType *getUnqual(const Type *ElementType) {
378 return PointerType::get(ElementType, 0);
379 }
373380
374381 /// @brief Return the address space of the Pointer type.
375382 inline unsigned getAddressSpace() const { return AddressSpace; }
22792279 PAL = ParamAttrsList::get(Attrs);
22802280
22812281 FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg);
2282 const PointerType *PFT = PointerType::get(FT);
2282 const PointerType *PFT = PointerType::getUnqual(FT);
22832283 delete $2;
22842284
22852285 ValID ID;
26262626 ParamTypes.push_back(Ty);
26272627 }
26282628 Ty = FunctionType::get($3->get(), ParamTypes, false);
2629 PFTy = PointerType::get(Ty);
2629 PFTy = PointerType::getUnqual(Ty);
26302630 }
26312631
26322632 delete $3;
29532953 ParamTypes.push_back(Ty);
29542954 }
29552955 Ty = FunctionType::get($3->get(), ParamTypes, false);
2956 PFTy = PointerType::get(Ty);
2956 PFTy = PointerType::getUnqual(Ty);
29572957 }
29582958
29592959 Value *V = getVal(PFTy, $4); // Get the function we're calling...
15081508 unsigned OpNum = 0;
15091509 Value *Val, *Ptr;
15101510 if (getValueTypePair(Record, OpNum, NextValueNo, Val) ||
1511 getValue(Record, OpNum, PointerType::get(Val->getType()), Ptr) ||
1511 getValue(Record, OpNum, PointerType::getUnqual(Val->getType()), Ptr)||
15121512 OpNum+2 != Record.size())
15131513 return Error("Invalid STORE record");
15141514
8080 break;
8181 case Intrinsic::memcpy_i32:
8282 case Intrinsic::memcpy_i64:
83 M.getOrInsertFunction("memcpy", PointerType::get(Type::Int8Ty),
84 PointerType::get(Type::Int8Ty),
85 PointerType::get(Type::Int8Ty),
83 M.getOrInsertFunction("memcpy", PointerType::getUnqual(Type::Int8Ty),
84 PointerType::getUnqual(Type::Int8Ty),
85 PointerType::getUnqual(Type::Int8Ty),
8686 TD.getIntPtrType(), (Type *)0);
8787 break;
8888 case Intrinsic::memmove_i32:
8989 case Intrinsic::memmove_i64:
90 M.getOrInsertFunction("memmove", PointerType::get(Type::Int8Ty),
91 PointerType::get(Type::Int8Ty),
92 PointerType::get(Type::Int8Ty),
90 M.getOrInsertFunction("memmove", PointerType::getUnqual(Type::Int8Ty),
91 PointerType::getUnqual(Type::Int8Ty),
92 PointerType::getUnqual(Type::Int8Ty),
9393 TD.getIntPtrType(), (Type *)0);
9494 break;
9595 case Intrinsic::memset_i32:
9696 case Intrinsic::memset_i64:
97 M.getOrInsertFunction("memset", PointerType::get(Type::Int8Ty),
98 PointerType::get(Type::Int8Ty), Type::Int32Ty,
97 M.getOrInsertFunction("memset", PointerType::getUnqual(Type::Int8Ty),
98 PointerType::getUnqual(Type::Int8Ty),
99 Type::Int32Ty,
99100 TD.getIntPtrType(), (Type *)0);
100101 break;
101102 case Intrinsic::sqrt:
12611261 // If not already defined.
12621262 if (!StrPtrTy) {
12631263 // Construct the pointer to signed bytes.
1264 StrPtrTy = PointerType::get(Type::Int8Ty);
1264 StrPtrTy = PointerType::getUnqual(Type::Int8Ty);
12651265 }
12661266
12671267 return StrPtrTy;
12761276 const StructType *EmptyStructTy =
12771277 StructType::get(std::vector());
12781278 // Construct the pointer to empty structure type.
1279 EmptyStructPtrTy = PointerType::get(EmptyStructTy);
1279 EmptyStructPtrTy = PointerType::getUnqual(EmptyStructTy);
12801280 }
12811281
12821282 return EmptyStructPtrTy;
169169 char *Result = new char[(InputArgv.size()+1)*PtrSize];
170170
171171 DOUT << "ARGV = " << (void*)Result << "\n";
172 const Type *SBytePtr = PointerType::get(Type::Int8Ty);
172 const Type *SBytePtr = PointerType::getUnqual(Type::Int8Ty);
173173
174174 for (unsigned i = 0; i != InputArgv.size(); ++i) {
175175 unsigned Size = InputArgv[i].size()+1;
254254 // Check main() type
255255 unsigned NumArgs = Fn->getFunctionType()->getNumParams();
256256 const FunctionType *FTy = Fn->getFunctionType();
257 const Type* PPInt8Ty = PointerType::get(PointerType::get(Type::Int8Ty));
257 const Type* PPInt8Ty =
258 PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty));
258259 switch (NumArgs) {
259260 case 3:
260261 if (FTy->getParamType(2) != PPInt8Ty) {
782782 // Save as pointer type "void*"
783783 printValueLoad(Inst->getOperand(1));
784784 printSimpleInstruction("ldloca",Name.c_str());
785 printIndirectSave(PointerType::get(IntegerType::get(8)));
785 printIndirectSave(PointerType::getUnqual(IntegerType::get(8)));
786786 break;
787787 case Intrinsic::vaend:
788788 // Close argument list handle.
10011001 printSimpleInstruction("call",
10021002 "instance typedref [mscorlib]System.ArgIterator::GetNextArg()");
10031003 printSimpleInstruction("refanyval","void*");
1004 std::string Name = "ldind."+getTypePostfix(PointerType::get(IntegerType::get(8)),false);
1004 std::string Name =
1005 "ldind."+getTypePostfix(PointerType::getUnqual(IntegerType::get(8)),false);
10051006 printSimpleInstruction(Name.c_str());
10061007 }
10071008
12161217 const AllocaInst* AI = dyn_cast(&*I);
12171218 if (AI && !isa(AI)) {
12181219 // Local variable allocation.
1219 Ty = PointerType::get(AI->getAllocatedType());
1220 Ty = PointerType::getUnqual(AI->getAllocatedType());
12201221 Name = getValueName(AI);
12211222 Out << "\t.locals (" << getTypeName(Ty) << Name << ")\n";
12221223 } else if (I->getType()!=Type::VoidTy) {
10511051
10521052 for (unsigned FieldNo = 0, e = STy->getNumElements(); FieldNo != e;++FieldNo){
10531053 const Type *FieldTy = STy->getElementType(FieldNo);
1054 const Type *PFieldTy = PointerType::get(FieldTy);
1054 const Type *PFieldTy = PointerType::getUnqual(FieldTy);
10551055
10561056 GlobalVariable *NGV =
10571057 new GlobalVariable(PFieldTy, false, GlobalValue::InternalLinkage,
16171617 } else {
16181618 const Type *FTy = FunctionType::get(Type::VoidTy,
16191619 std::vector(), false);
1620 const PointerType *PFTy = PointerType::get(FTy);
1620 const PointerType *PFTy = PointerType::getUnqual(FTy);
16211621 CSVals[1] = Constant::getNullValue(PFTy);
16221622 CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647);
16231623 }
198198 // This function is always successful, unless it isn't.
199199 bool LowerSetJmp::doInitialization(Module& M)
200200 {
201 const Type *SBPTy = PointerType::get(Type::Int8Ty);
202 const Type *SBPPTy = PointerType::get(SBPTy);
201 const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
202 const Type *SBPPTy = PointerType::getUnqual(SBPTy);
203203
204204 // N.B. See llvm/runtime/GCCLibraries/libexception/SJLJ-Exception.h for
205205 // a description of the following library functions.
255255 // throwing the exception for us.
256256 void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
257257 {
258 const Type* SBPTy = PointerType::get(Type::Int8Ty);
258 const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty);
259259
260260 // Create the call to "__llvm_sjljeh_throw_longjmp". This takes the
261261 // same parameters as "longjmp", except that the buffer is cast to a
307307 assert(Inst && "Couldn't find even ONE instruction in entry block!");
308308
309309 // Fill in the alloca and call to initialize the SJ map.
310 const Type *SBPTy = PointerType::get(Type::Int8Ty);
310 const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
311311 AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst);
312312 new CallInst(InitSJMap, Map, "", Inst);
313313 return SJMap[Func] = Map;
377377 Function* Func = ABlock->getParent();
378378
379379 // Add this setjmp to the setjmp map.
380 const Type* SBPTy = PointerType::get(Type::Int8Ty);
380 const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty);
381381 CastInst* BufPtr =
382382 new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst);
383383 std::vector Args =
7777
7878 // Get the expected prototype for malloc
7979 const FunctionType *Malloc1Type =
80 FunctionType::get(PointerType::get(Type::Int8Ty),
80 FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
8181 std::vector(1, Type::Int64Ty), false);
8282
8383 // Chck to see if we got the expected malloc
8585 // Check to see if the prototype is wrong, giving us sbyte*(uint) * malloc
8686 // This handles the common declaration of: 'void *malloc(unsigned);'
8787 const FunctionType *Malloc2Type =
88 FunctionType::get(PointerType::get(Type::Int8Ty),
88 FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
8989 std::vector(1, Type::Int32Ty), false);
9090 if (TyWeHave != Malloc2Type) {
9191 // Check to see if the prototype is missing, giving us
9292 // sbyte*(...) * malloc
9393 // This handles the common declaration of: 'void *malloc();'
9494 const FunctionType *Malloc3Type =
95 FunctionType::get(PointerType::get(Type::Int8Ty),
95 FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
9696 std::vector(), true);
9797 if (TyWeHave != Malloc3Type)
9898 // Give up
107107
108108 // Get the expected prototype for void free(i8*)
109109 const FunctionType *Free1Type = FunctionType::get(Type::VoidTy,
110 std::vector(1, PointerType::get(Type::Int8Ty)), false);
110 std::vector(1, PointerType::getUnqual(Type::Int8Ty)), false);
111111
112112 if (TyWeHave != Free1Type) {
113113 // Check to see if the prototype was forgotten, giving us
218218 //
219219 Value *Source = *CS.arg_begin();
220220 if (!isa(Source->getType()))
221 Source = new IntToPtrInst(Source, PointerType::get(Type::Int8Ty),
221 Source = new IntToPtrInst(Source,
222 PointerType::getUnqual(Type::Int8Ty),
222223 "FreePtrCast", I);
223224 new FreeInst(Source, I);
224225
243243 Constant *get_puts() {
244244 if (!puts_func)
245245 puts_func = M->getOrInsertFunction("puts", Type::Int32Ty,
246 PointerType::get(Type::Int8Ty),
246 PointerType::getUnqual(Type::Int8Ty),
247247 NULL);
248248 return puts_func;
249249 }
260260 Constant *get_fputs(const Type* FILEptr_type) {
261261 if (!fputs_func)
262262 fputs_func = M->getOrInsertFunction("fputs", Type::Int32Ty,
263 PointerType::get(Type::Int8Ty),
263 PointerType::getUnqual(Type::Int8Ty),
264264 FILEptr_type, NULL);
265265 return fputs_func;
266266 }
269269 Constant *get_fwrite(const Type* FILEptr_type) {
270270 if (!fwrite_func)
271271 fwrite_func = M->getOrInsertFunction("fwrite", TD->getIntPtrType(),
272 PointerType::get(Type::Int8Ty),
272 PointerType::getUnqual(Type::Int8Ty),
273273 TD->getIntPtrType(),
274274 TD->getIntPtrType(),
275275 FILEptr_type, NULL);
288288 Constant *get_strcpy() {
289289 if (!strcpy_func)
290290 strcpy_func = M->getOrInsertFunction("strcpy",
291 PointerType::get(Type::Int8Ty),
292 PointerType::get(Type::Int8Ty),
293 PointerType::get(Type::Int8Ty),
291 PointerType::getUnqual(Type::Int8Ty),
292 PointerType::getUnqual(Type::Int8Ty),
293 PointerType::getUnqual(Type::Int8Ty),
294294 NULL);
295295 return strcpy_func;
296296 }
299299 Constant *get_strlen() {
300300 if (!strlen_func)
301301 strlen_func = M->getOrInsertFunction("strlen", TD->getIntPtrType(),
302 PointerType::get(Type::Int8Ty),
302 PointerType::getUnqual(Type::Int8Ty),
303303 NULL);
304304 return strlen_func;
305305 }
308308 Constant *get_memchr() {
309309 if (!memchr_func)
310310 memchr_func = M->getOrInsertFunction("memchr",
311 PointerType::get(Type::Int8Ty),
312 PointerType::get(Type::Int8Ty),
311 PointerType::getUnqual(Type::Int8Ty),
312 PointerType::getUnqual(Type::Int8Ty),
313313 Type::Int32Ty, TD->getIntPtrType(),
314314 NULL);
315315 return memchr_func;
318318 /// @brief Return a Function* for the memcpy libcall
319319 Constant *get_memcpy() {
320320 if (!memcpy_func) {
321 const Type *SBP = PointerType::get(Type::Int8Ty);
321 const Type *SBP = PointerType::getUnqual(Type::Int8Ty);
322322 const char *N = TD->getIntPtrType() == Type::Int32Ty ?
323323 "llvm.memcpy.i32" : "llvm.memcpy.i64";
324324 memcpy_func = M->getOrInsertFunction(N, Type::VoidTy, SBP, SBP,
470470 virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
471471 const FunctionType *FT = F->getFunctionType();
472472 return FT->getNumParams() == 2 &&
473 FT->getReturnType() == PointerType::get(Type::Int8Ty) &&
473 FT->getReturnType() == PointerType::getUnqual(Type::Int8Ty) &&
474474 FT->getParamType(0) == FT->getReturnType() &&
475475 FT->getParamType(1) == FT->getReturnType();
476476 }
527527 virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
528528 const FunctionType *FT = F->getFunctionType();
529529 return FT->getNumParams() == 2 &&
530 FT->getReturnType() == PointerType::get(Type::Int8Ty) &&
530 FT->getReturnType() == PointerType::getUnqual(Type::Int8Ty) &&
531531 FT->getParamType(0) == FT->getReturnType() &&
532532 isa(FT->getParamType(1));
533533 }
593593 const FunctionType *FT = F->getFunctionType();
594594 return FT->getReturnType() == Type::Int32Ty && FT->getNumParams() == 2 &&
595595 FT->getParamType(0) == FT->getParamType(1) &&
596 FT->getParamType(0) == PointerType::get(Type::Int8Ty);
596 FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty);
597597 }
598598
599599 /// @brief Perform the strcmp optimization
646646 const FunctionType *FT = F->getFunctionType();
647647 return FT->getReturnType() == Type::Int32Ty && FT->getNumParams() == 3 &&
648648 FT->getParamType(0) == FT->getParamType(1) &&
649 FT->getParamType(0) == PointerType::get(Type::Int8Ty) &&
649 FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) &&
650650 isa(FT->getParamType(2));
651651 return false;
652652 }
714714 return FT->getNumParams() == 2 &&
715715 FT->getParamType(0) == FT->getParamType(1) &&
716716 FT->getReturnType() == FT->getParamType(0) &&
717 FT->getParamType(0) == PointerType::get(Type::Int8Ty);
717 FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty);
718718 }
719719
720720 /// @brief Perform the strcpy optimization
769769 virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
770770 const FunctionType *FT = F->getFunctionType();
771771 return FT->getNumParams() == 1 &&
772 FT->getParamType(0) == PointerType::get(Type::Int8Ty) &&
772 FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) &&
773773 isa(FT->getReturnType());
774774 }
775775
869869 return ReplaceCallWith(CI, Constant::getNullValue(CI->getType()));
870870 case 1: {
871871 // memcmp(S1,S2,1) -> *(ubyte*)S1 - *(ubyte*)S2
872 const Type *UCharPtr = PointerType::get(Type::Int8Ty);
872 const Type *UCharPtr = PointerType::getUnqual(Type::Int8Ty);
873873 CastInst *Op1Cast = CastInst::create(
874874 Instruction::BitCast, LHS, UCharPtr, LHS->getName(), CI);
875875 CastInst *Op2Cast = CastInst::create(
887887 // TODO: IF both are aligned, use a short load/compare.
888888
889889 // memcmp(S1,S2,2) -> S1[0]-S2[0] | S1[1]-S2[1] iff only ==/!= 0 matters
890 const Type *UCharPtr = PointerType::get(Type::Int8Ty);
890 const Type *UCharPtr = PointerType::getUnqual(Type::Int8Ty);
891891 CastInst *Op1Cast = CastInst::create(
892892 Instruction::BitCast, LHS, UCharPtr, LHS->getName(), CI);
893893 CastInst *Op2Cast = CastInst::create(
975975
976976 // Cast source and dest to the right sized primitive and then load/store
977977 CastInst* SrcCast = CastInst::create(Instruction::BitCast,
978 src, PointerType::get(castType), src->getName()+".cast", ci);
978 src, PointerType::getUnqual(castType), src->getName()+".cast", ci);
979979 CastInst* DestCast = CastInst::create(Instruction::BitCast,
980 dest, PointerType::get(castType),dest->getName()+".cast", ci);
980 dest, PointerType::getUnqual(castType),dest->getName()+".cast", ci);
981981 LoadInst* LI = new LoadInst(SrcCast,SrcCast->getName()+".val",ci);
982982 new StoreInst(LI, DestCast, ci);
983983 return ReplaceCallWith(ci, 0);
10841084 }
10851085
10861086 // Cast dest to the right sized primitive and then load/store
1087 CastInst* DestCast = new BitCastInst(dest, PointerType::get(castType),
1087 CastInst* DestCast = new BitCastInst(dest, PointerType::getUnqual(castType),
10881088 dest->getName()+".cast", ci);
10891089 new StoreInst(ConstantInt::get(castType,fill_value),DestCast, ci);
10901090 return ReplaceCallWith(ci, 0);
12061206 Init, "str",
12071207 CI->getParent()->getParent()->getParent());
12081208 // Cast GV to be a pointer to char.
1209 GV = ConstantExpr::getBitCast(GV, PointerType::get(Type::Int8Ty));
1209 GV = ConstantExpr::getBitCast(GV, PointerType::getUnqual(Type::Int8Ty));
12101210 new CallInst(SLC.get_puts(), GV, "", CI);
12111211
12121212 if (CI->use_empty()) return ReplaceCallWith(CI, 0);
12671267 virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
12681268 const FunctionType *FT = F->getFunctionType();
12691269 return FT->getNumParams() == 2 && // two fixed arguments.
1270 FT->getParamType(1) == PointerType::get(Type::Int8Ty) &&
1270 FT->getParamType(1) == PointerType::getUnqual(Type::Int8Ty) &&
12711271 isa(FT->getParamType(0)) &&
12721272 isa(FT->getReturnType());
12731273 }
13571357 virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
13581358 const FunctionType *FT = F->getFunctionType();
13591359 return FT->getNumParams() == 2 && // two fixed arguments.
1360 FT->getParamType(1) == PointerType::get(Type::Int8Ty) &&
1360 FT->getParamType(1) == PointerType::getUnqual(Type::Int8Ty) &&
13611361 FT->getParamType(0) == FT->getParamType(1) &&
13621362 isa(FT->getReturnType());
13631363 }
14901490 virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
14911491 const FunctionType *FT = F->getFunctionType();
14921492 return FT->getNumParams() == 4 &&
1493 FT->getParamType(0) == PointerType::get(Type::Int8Ty) &&
1493 FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) &&
14941494 FT->getParamType(1) == FT->getParamType(2) &&
14951495 isa(FT->getParamType(1)) &&
14961496 isa(FT->getParamType(3)) &&
19261926 static Value *CastToCStr(Value *V, Instruction *IP) {
19271927 assert(isa(V->getType()) &&
19281928 "Can't cast non-pointer type to C string type");
1929 const Type *SBPTy = PointerType::get(Type::Int8Ty);
1929 const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
19301930 if (V->getType() != SBPTy)
19311931 return new BitCastInst(V, SBPTy, V->getName(), IP);
19321932 return V;
2121
2222 void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
2323 GlobalValue *Array) {
24 const Type *ArgVTy = PointerType::get(PointerType::get(Type::Int8Ty));
25 const PointerType *UIntPtr = PointerType::get(Type::Int32Ty);
24 const Type *ArgVTy =
25 PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty));
26 const PointerType *UIntPtr = PointerType::getUnqual(Type::Int32Ty);
2627 Module &M = *MainFn->getParent();
2728 Constant *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty,
2829 ArgVTy, UIntPtr, Type::Int32Ty,
21212121 (CI->getType()->getPrimitiveSizeInBits() ==
21222122 TD->getIntPtrType()->getPrimitiveSizeInBits())
21232123 && isa(CI->getOperand(0)->getType())) {
2124 unsigned AS =
2125 cast(CI->getOperand(0)->getType())->getAddressSpace();
21242126 Value *I2 = InsertCastBefore(Instruction::BitCast, CI->getOperand(0),
2125 PointerType::get(Type::Int8Ty), I);
2127 PointerType::get(Type::Int8Ty, AS), I);
21262128 I2 = InsertNewInstBefore(new GetElementPtrInst(I2, Other, "ctg2"), I);
21272129 return new PtrToIntInst(I2, CI->getType());
21282130 }
77397741 // If Size is 2 then use Int16Ty
77407742 // If Size is 1 then use Int8Ty
77417743 if (Size && Size <=8 && !(Size&(Size-1)))
7742 NewPtrTy = PointerType::get(IntegerType::get(Size<<3));
7744 NewPtrTy = PointerType::getUnqual(IntegerType::get(Size<<3));
77437745
77447746 if (NewPtrTy) {
77457747 Value *Src = InsertCastBefore(Instruction::BitCast, CI.getOperand(2),
77737775 // Turn PPC lvx -> load if the pointer is known aligned.
77747776 // Turn X86 loadups -> load if the pointer is known aligned.
77757777 if (GetOrEnforceKnownAlignment(II->getOperand(1), TD, 16) >= 16) {
7776 Value *Ptr = InsertCastBefore(Instruction::BitCast, II->getOperand(1),
7777 PointerType::get(II->getType()), CI);
7778 Value *Ptr =
7779 InsertCastBefore(Instruction::BitCast, II->getOperand(1),
7780 PointerType::getUnqual(II->getType()), CI);
77787781 return new LoadInst(Ptr);
77797782 }
77807783 break;
77827785 case Intrinsic::ppc_altivec_stvxl:
77837786 // Turn stvx -> store if the pointer is known aligned.
77847787 if (GetOrEnforceKnownAlignment(II->getOperand(2), TD, 16) >= 16) {
7785 const Type *OpPtrTy = PointerType::get(II->getOperand(1)->getType());
7788 const Type *OpPtrTy =
7789 PointerType::getUnqual(II->getOperand(1)->getType());
77867790 Value *Ptr = InsertCastBefore(Instruction::BitCast, II->getOperand(2),
77877791 OpPtrTy, CI);
77887792 return new StoreInst(II->getOperand(1), Ptr);
77947798 case Intrinsic::x86_sse2_storel_dq:
77957799 // Turn X86 storeu -> store if the pointer is known aligned.
77967800 if (GetOrEnforceKnownAlignment(II->getOperand(1), TD, 16) >= 16) {
7797 const Type *OpPtrTy = PointerType::get(II->getOperand(2)->getType());
7801 const Type *OpPtrTy =
7802 PointerType::getUnqual(II->getOperand(2)->getType());
77987803 Value *Ptr = InsertCastBefore(Instruction::BitCast, II->getOperand(1),
77997804 OpPtrTy, CI);
78007805 return new StoreInst(II->getOperand(2), Ptr);
79207925 // If the call and callee calling conventions don't match, this call must
79217926 // be unreachable, as the call is undefined.
79227927 new StoreInst(ConstantInt::getTrue(),
7923 UndefValue::get(PointerType::get(Type::Int1Ty)), OldCall);
7928 UndefValue::get(PointerType::getUnqual(Type::Int1Ty)),
7929 OldCall);
79247930 if (!OldCall->use_empty())
79257931 OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType()));
79267932 if (isa(OldCall)) // Not worth removing an invoke here.
79337939 // undef so that we know that this code is not reachable, despite the fact
79347940 // that we can't modify the CFG here.
79357941 new StoreInst(ConstantInt::getTrue(),
7936 UndefValue::get(PointerType::get(Type::Int1Ty)),
7942 UndefValue::get(PointerType::getUnqual(Type::Int1Ty)),
79377943 CS.getInstruction());
79387944
79397945 if (!CS.getInstruction()->use_empty())
82988304 // code sort out any function type mismatches.
82998305 FunctionType *NewFTy =
83008306 FunctionType::get(FTy->getReturnType(), NewTypes, FTy->isVarArg());
8301 Constant *NewCallee = NestF->getType() == PointerType::get(NewFTy) ?
8302 NestF : ConstantExpr::getBitCast(NestF, PointerType::get(NewFTy));
8307 Constant *NewCallee = NestF->getType() == PointerType::getUnqual(NewFTy) ?
8308 NestF : ConstantExpr::getBitCast(NestF, PointerType::getUnqual(NewFTy));
83038309 const ParamAttrsList *NewPAL = ParamAttrsList::get(NewAttrs);
83048310
83058311 Instruction *NewCaller;
90519057 if (isa(Op)) {
90529058 // Insert a new store to null because we cannot modify the CFG here.
90539059 new StoreInst(ConstantInt::getTrue(),
9054 UndefValue::get(PointerType::get(Type::Int1Ty)), &FI);
9060 UndefValue::get(PointerType::getUnqual(Type::Int1Ty)), &FI);
90559061 return EraseInstFromFunction(FI);
90569062 }
90579063
98869892 return BinaryOperator::create(BO->getOpcode(), newEI0, newEI1);
98879893 }
98889894 } else if (isa(I)) {
9895 unsigned AS =
9896 cast(I->getOperand(0)->getType())->getAddressSpace();
98899897 Value *Ptr = InsertCastBefore(Instruction::BitCast, I->getOperand(0),
9890 PointerType::get(EI.getType()), EI);
9898 PointerType::get(EI.getType(), AS), EI);
98919899 GetElementPtrInst *GEP =
98929900 new GetElementPtrInst(Ptr, EI.getOperand(1), I->getName() + ".gep");
98939901 InsertNewInstBefore(GEP, EI);
8585 PATypeHolder RootListH =
8686 MainRootRecordType ? (Type*)MainRootRecordType : (Type*)OpaqueType::get();
8787 ST.clear();
88 ST.push_back(PointerType::get(RootListH)); // Prev pointer
88 ST.push_back(PointerType::getUnqual(RootListH)); // Prev pointer
8989 ST.push_back(Type::Int32Ty); // NumElements in array
9090 ST.push_back(PairArrTy); // The pairs
9191 StructType *RootList = StructType::get(ST);
106106 GCWriteInt = M.getFunction("llvm.gcwrite");
107107 if (!GCRootInt && !GCReadInt && !GCWriteInt) return false;
108108
109 PointerType *VoidPtr = PointerType::get(Type::Int8Ty);
110 PointerType *VoidPtrPtr = PointerType::get(VoidPtr);
109 PointerType *VoidPtr = PointerType::getUnqual(Type::Int8Ty);
110 PointerType *VoidPtrPtr = PointerType::getUnqual(VoidPtr);
111111
112112 // If the program is using read/write barriers, find the implementations of
113113 // them from the GC runtime library.
121121 // If the program has GC roots, get or create the global root list.
122122 if (GCRootInt) {
123123 const StructType *RootListTy = getRootRecordType(0);
124 const Type *PRLTy = PointerType::get(RootListTy);
124 const Type *PRLTy = PointerType::getUnqual(RootListTy);
125125 M.addTypeName("llvm_gc_root_ty", RootListTy);
126126
127127 // Get the root chain if it already exists.
162162 // Quick exit for programs that are not using GC mechanisms.
163163 if (!GCRootInt && !GCReadInt && !GCWriteInt) return false;
164164
165 PointerType *VoidPtr = PointerType::get(Type::Int8Ty);
166 PointerType *VoidPtrPtr = PointerType::get(VoidPtr);
165 PointerType *VoidPtr = PointerType::getUnqual(Type::Int8Ty);
166 PointerType *VoidPtrPtr = PointerType::getUnqual(VoidPtr);
167167
168168 // If there are read/write barriers in the program, perform a quick pass over
169169 // the function eliminating them. While we are at it, remember where we see
289289
290290 // Now that the record is all initialized, store the pointer into the global
291291 // pointer.
292 Value *C = new BitCastInst(AI, PointerType::get(MainRootRecordType), "", IP);
292 Value *C = new BitCastInst(AI, PointerType::getUnqual(MainRootRecordType), "", IP);
293293 new StoreInst(C, RootChain, IP);
294294
295295 // Eliminate all the gcroot records now.
262262 if (AggregateArgs)
263263 paramTy.push_back((*I)->getType());
264264 else
265 paramTy.push_back(PointerType::get((*I)->getType()));
265 paramTy.push_back(PointerType::getUnqual((*I)->getType()));
266266 }
267267
268268 DOUT << "Function type: " << *RetTy << " f(";
272272 DOUT << ")\n";
273273
274274 if (AggregateArgs && (inputs.size() + outputs.size() > 0)) {
275 PointerType *StructPtr = PointerType::get(StructType::get(paramTy));
275 PointerType *StructPtr = PointerType::getUnqual(StructType::get(paramTy));
276276 paramTy.clear();
277277 paramTy.push_back(StructPtr);
278278 }
276276 // code with llvm.stacksave/llvm.stackrestore intrinsics.
277277 if (InlinedFunctionInfo.ContainsDynamicAllocas) {
278278 Module *M = Caller->getParent();
279 const Type *BytePtr = PointerType::get(Type::Int8Ty);
279 const Type *BytePtr = PointerType::getUnqual(Type::Int8Ty);
280280 // Get the two intrinsics we care about.
281281 Constant *StackSave, *StackRestore;
282282 StackSave = M->getOrInsertFunction("llvm.stacksave", BytePtr, NULL);
8686 // This function is always successful.
8787 //
8888 bool LowerAllocations::doInitialization(Module &M) {
89 const Type *BPTy = PointerType::get(Type::Int8Ty);
89 const Type *BPTy = PointerType::getUnqual(Type::Int8Ty);
9090 // Prototype malloc as "char* malloc(...)", because we don't know in
9191 // doInitialization whether size_t is int or long.
9292 FunctionType *FT = FunctionType::get(BPTy, std::vector(), true);
157157 Changed = true;
158158 ++NumLowered;
159159 } else if (FreeInst *FI = dyn_cast(I)) {
160 Value *PtrCast = new BitCastInst(FI->getOperand(0),
161 PointerType::get(Type::Int8Ty), "", I);
160 Value *PtrCast =
161 new BitCastInst(FI->getOperand(0),
162 PointerType::getUnqual(Type::Int8Ty), "", I);
162163
163164 // Insert a call to the free function...
164165 (new CallInst(FreeFunc, PtrCast, "", I))->setTailCall();
113113 // doInitialization - Make sure that there is a prototype for abort in the
114114 // current module.
115115 bool LowerInvoke::doInitialization(Module &M) {
116 const Type *VoidPtrTy = PointerType::get(Type::Int8Ty);
116 const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
117117 AbortMessage = 0;
118118 if (ExpensiveEHSupport) {
119119 // Insert a type for the linked list of jump buffers.
125125 std::vector Elements;
126126 Elements.push_back(JmpBufTy);
127127 OpaqueType *OT = OpaqueType::get();
128 Elements.push_back(PointerType::get(OT));
128 Elements.push_back(PointerType::getUnqual(OT));
129129 PATypeHolder JBLType(StructType::get(Elements));
130130 OT->refineAbstractTypeTo(JBLType.get()); // Complete the cycle.
131131 JBLinkTy = JBLType.get();
132132 M.addTypeName("llvm.sjljeh.jmpbufty", JBLinkTy);
133133 }
134134
135 const Type *PtrJBList = PointerType::get(JBLinkTy);
135 const Type *PtrJBList = PointerType::getUnqual(JBLinkTy);
136136
137137 // Now that we've done that, insert the jmpbuf list head global, unless it
138138 // already exists.
143143 "llvm.sjljeh.jblist", &M);
144144 }
145145 SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::Int32Ty,
146 PointerType::get(JmpBufTy), (Type *)0);
146 PointerType::getUnqual(JmpBufTy),
147 (Type *)0);
147148 LongJmpFn = M.getOrInsertFunction("llvm.longjmp", Type::VoidTy,
148 PointerType::get(JmpBufTy),
149 PointerType::getUnqual(JmpBufTy),
149150 Type::Int32Ty, (Type *)0);
150151 }
151152
13821382 return const_cast(C);
13831383
13841384 if (isa(C)) {
1385 const Type *Ty = GetElementPtrInst::getIndexedType(C->getType(),
1385 const PointerType *Ptr = cast(C->getType());
1386 const Type *Ty = GetElementPtrInst::getIndexedType(Ptr,
13861387 (Value **)Idxs,
13871388 (Value **)Idxs+NumIdx,
13881389 true);
13891390 assert(Ty != 0 && "Invalid indices for GEP!");
1390 return UndefValue::get(PointerType::get(Ty));
1391 return UndefValue::get(PointerType::get(Ty, Ptr->getAddressSpace()));
13911392 }
13921393
13931394 Constant *Idx0 = Idxs[0];
13991400 break;
14001401 }
14011402 if (isNull) {
1402 const Type *Ty = GetElementPtrInst::getIndexedType(C->getType(),
1403 const PointerType *Ptr = cast(C->getType());
1404 const Type *Ty = GetElementPtrInst::getIndexedType(Ptr,
14031405 (Value**)Idxs,
14041406 (Value**)Idxs+NumIdx,
14051407 true);
14061408 assert(Ty != 0 && "Invalid indices for GEP!");
1407 return ConstantPointerNull::get(PointerType::get(Ty));
1409 return
1410 ConstantPointerNull::get(PointerType::get(Ty,Ptr->getAddressSpace()));
14081411 }
14091412 }
14101413
17091709 // sizeof is implemented as: (i64) gep (Ty*)null, 1
17101710 Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1);
17111711 Constant *GEP =
1712 getGetElementPtr(getNullValue(PointerType::get(Ty)), &GEPIdx, 1);
1712 getGetElementPtr(getNullValue(PointerType::getUnqual(Ty)), &GEPIdx, 1);
17131713 return getCast(Instruction::PtrToInt, GEP, Type::Int64Ty);
17141714 }
17151715
149149 }
150150
151151 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType) {
152 return wrap(PointerType::get(unwrap(ElementType)));
152 // FIXME: Needst to handle address spaces
153 return wrap(PointerType::getUnqual(unwrap(ElementType)));
153154 }
154155
155156 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType,unsigned ElementCount){
270270
271271 Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
272272 const std::string &name, Module *ParentModule)
273 : GlobalValue(PointerType::get(Ty), Value::FunctionVal, 0, 0, Linkage, name),
273 : GlobalValue(PointerType::getUnqual(Ty),
274 Value::FunctionVal, 0, 0, Linkage, name),
274275 ParamAttrs(0) {
275276 SymTab = new ValueSymbolTable();
276277
3333
3434 InlineAsm::InlineAsm(const FunctionType *Ty, const std::string &asmString,
3535 const std::string &constraints, bool hasSideEffects)
36 : Value(PointerType::get(Ty), Value::InlineAsmVal), AsmString(asmString),
36 : Value(PointerType::getUnqual(Ty),
37 Value::InlineAsmVal),
38 AsmString(asmString),
3739 Constraints(constraints), HasSideEffects(hasSideEffects) {
3840
3941 // Do various checks on the constraint string and type.
7070 else
7171 return cast(I)->isNoUnwind();
7272 }
73
74
7573
7674 //===----------------------------------------------------------------------===//
7775 // TerminatorInst Class
671669 AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
672670 unsigned Align, const std::string &Name,
673671 Instruction *InsertBefore)
674 : UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
672 : UnaryInstruction(PointerType::getUnqual(Ty), iTy, getAISize(ArraySize),
675673 InsertBefore), Alignment(Align) {
676674 assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
677675 assert(Ty != Type::VoidTy && "Cannot allocate void!");
681679 AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
682680 unsigned Align, const std::string &Name,
683681 BasicBlock *InsertAtEnd)
684 : UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
682 : UnaryInstruction(PointerType::getUnqual(Ty), iTy, getAISize(ArraySize),
685683 InsertAtEnd), Alignment(Align) {
686684 assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
687685 assert(Ty != Type::VoidTy && "Cannot allocate void!");
924922 // GetElementPtrInst Implementation
925923 //===----------------------------------------------------------------------===//
926924
925 static unsigned retrieveAddrSpace(const Value *Val) {
926 return cast(Val->getType())->getAddressSpace();
927 }
928
927929 void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx) {
928930 NumOperands = 1+NumIdx;
929931 Use *OL = OperandList = new Use[NumOperands];
943945 GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
944946 const std::string &Name, Instruction *InBe)
945947 : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx)),
946 cast(Ptr->getType())->getAddressSpace()),
948 retrieveAddrSpace(Ptr)),
947949 GetElementPtr, 0, 0, InBe) {
948950 init(Ptr, Idx);
949951 setName(Name);
952954 GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
953955 const std::string &Name, BasicBlock *IAE)
954956 : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx)),
955 cast(Ptr->getType())->getAddressSpace()),
957 retrieveAddrSpace(Ptr)),
956958 GetElementPtr, 0, 0, IAE) {
957959 init(Ptr, Idx);
958960 setName(Name);
163163
164164 // If the function exists but has the wrong type, return a bitcast to the
165165 // right type.
166 if (F->getType() != PointerType::get(Ty))
167 return ConstantExpr::getBitCast(F, PointerType::get(Ty));
166 if (F->getType() != PointerType::getUnqual(Ty))
167 return ConstantExpr::getBitCast(F, PointerType::getUnqual(Ty));
168168
169169 // Otherwise, we just found the existing function or a prototype.
170170 return F;
11601160 break;
11611161 case Intrinsic::gcwrite:
11621162 Assert1(CI.getOperand(3)->getType()
1163 == PointerType::get(CI.getOperand(1)->getType()),
1163 == PointerType::getUnqual(CI.getOperand(1)->getType()),
11641164 "Call to llvm.gcwrite must be with type 'void (%ty*, %ty2*, %ty**)'.",
11651165 &CI);
11661166 break;
11671167 case Intrinsic::gcread:
1168 Assert1(CI.getOperand(2)->getType() == PointerType::get(CI.getType()),
1168 Assert1(CI.getOperand(2)->getType() == PointerType::getUnqual(CI.getType()),
11691169 "Call to llvm.gcread must be with type '%ty* (%ty2*, %ty**).'",
11701170 &CI);
11711171 break;
678678 // Prototype: void *getPointerToNamedFunction(const char* Name)
679679 Constant *resolverFunc =
680680 Safe->getOrInsertFunction("getPointerToNamedFunction",
681 PointerType::get(Type::Int8Ty),
682 PointerType::get(Type::Int8Ty), (Type *)0);
681 PointerType::getUnqual(Type::Int8Ty),
682 PointerType::getUnqual(Type::Int8Ty), (Type *)0);
683683
684684 // Use the function we just added to get addresses of functions we need.
685685 for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) {
738738 "resolver", LookupBB);
739739 // cast the result from the resolver to correctly-typed function
740740 CastInst *CastedResolver = new BitCastInst(Resolver,
741 PointerType::get(F->getFunctionType()), "resolverCast", LookupBB);
741 PointerType::getUnqual(F->getFunctionType()), "resolverCast", LookupBB);
742742
743743 // Save the value in our cache.
744744 new StoreInst(CastedResolver, Cache, LookupBB);
828828 if (isa(Ty))
829829 error("Cannot declare global vars of function type");
830830
831 const PointerType *PTy = PointerType::get(Ty);
831 const PointerType *PTy = PointerType::getUnqual(Ty);
832832
833833 std::string Name;
834834 if (NameStr) {
882882 }
883883
884884 // Put the renaming in the global rename map
885 RenameMapKey Key = makeRenameMapKey(Name, PointerType::get(Ty), ID.S);
885 RenameMapKey Key =
886 makeRenameMapKey(Name, PointerType::getUnqual(Ty), ID.S);
886887 CurModule.RenameMap[Key] = NewName;
887888
888889 // Rename it
14031404 break;
14041405
14051406 case 'v' : {
1406 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1407 const Type* PtrTy = PointerType::getUnqual(Type::Int8Ty);
14071408 std::vector Params;
14081409 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
14091410 if (Args.size() != 1)
14111412 Params.push_back(PtrTy);
14121413 const FunctionType *FTy =
14131414 FunctionType::get(Type::VoidTy, Params, false);
1414 const PointerType *PFTy = PointerType::get(FTy);
1415 const PointerType *PFTy = PointerType::getUnqual(FTy);
14151416 Value* Func = getVal(PFTy, ID);
14161417 Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
14171418 return new CallInst(Func, Args.begin(), Args.end());
14221423 Params.push_back(PtrTy);
14231424 const FunctionType *FTy =
14241425 FunctionType::get(Type::VoidTy, Params, false);
1425 const PointerType *PFTy = PointerType::get(FTy);
1426 const PointerType *PFTy = PointerType::getUnqual(FTy);
14261427 Value* Func = getVal(PFTy, ID);
14271428 std::string InstName0(makeNameUnique("va0"));
14281429 std::string InstName1(makeNameUnique("va1"));
15911592
15921593 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
15931594 const Type* ArgTy = F->getFunctionType()->getReturnType();
1594 const Type* ArgTyPtr = PointerType::get(ArgTy);
1595 const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
15951596 Function* NF = cast(Result->getOrInsertFunction(
15961597 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
15971598
16181619 //vaend bar
16191620 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
16201621 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1621 const Type* ArgTyPtr = PointerType::get(ArgTy);
1622 const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
16221623 Function* NF = cast(Result->getOrInsertFunction(
16231624 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
16241625
16471648
16481649 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
16491650 const Type* ArgTy = F->getFunctionType()->getReturnType();
1650 const Type* ArgTyPtr = PointerType::get(ArgTy);
1651 const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
16511652 Function* NF = cast(Result->getOrInsertFunction(
16521653 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
16531654
21252126 if ($1.PAT->get() == Type::LabelTy)
21262127 error("Cannot form a pointer to a basic block");
21272128 $$.S.makeComposite($1.S);
2128 $$.PAT = new PATypeHolder(HandleUpRefs(PointerType::get($1.PAT->get()),
2129 $$.S));
2129 $$.PAT = new
2130 PATypeHolder(HandleUpRefs(PointerType::getUnqual($1.PAT->get()),
2131 $$.S));
21302132 delete $1.PAT;
21312133 }
21322134 ;
28332835 // i8*. We check here for those names and override the parameter list
28342836 // types to ensure the prototype is correct.
28352837 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
2836 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
2838 ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
28372839 } else if (FunctionName == "llvm.va_copy") {
2838 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
2839 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
2840 ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
2841 ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
28402842 } else if ($5) { // If there are arguments...
28412843 for (std::vector >::iterator
28422844 I = $5->begin(), E = $5->end(); I != E; ++I) {
28512853 ParamTyList.pop_back();
28522854
28532855 const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg);
2854 const PointerType *PFT = PointerType::get(FT);
2856 const PointerType *PFT = PointerType::getUnqual(FT);
28552857 delete $2.PAT;
28562858
28572859 ValID ID;
31013103 }
31023104 ;
31033105
3104 // SymbolicValueRef - Reference to one of two ways of symbolically refering to // another value.
3106 // SymbolicValueRef - Reference to one of two ways of symbolically refering to
3107 // another value.
31053108 //
31063109 SymbolicValueRef
31073110 : INTVAL { $$ = ValID::create($1); $$.S.makeSignless(); }
32503253 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
32513254 if (isVarArg) ParamTypes.pop_back();
32523255 Ty = FunctionType::get($3.PAT->get(), ParamTypes, isVarArg);
3253 PFTy = PointerType::get(Ty);
3256 PFTy = PointerType::getUnqual(Ty);
32543257 $$.S.copy($3.S);
32553258 } else {
32563259 FTySign = $3.S;
36553658 error("Functions cannot return aggregate types");
36563659
36573660 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
3658 PFTy = PointerType::get(FTy);
3661 PFTy = PointerType::getUnqual(FTy);
36593662 $$.S.copy($3.S);
36603663 } else {
36613664 FTySign = $3.S;
37953798 Value *StoreVal = $3.V;
37963799 Value* tmpVal = getVal(PTy, $6);
37973800 if (ElTy != $3.V->getType()) {
3798 PTy = PointerType::get(StoreVal->getType());
3801 PTy = PointerType::getUnqual(StoreVal->getType());
37993802 if (Constant *C = dyn_cast(tmpVal))
38003803 tmpVal = ConstantExpr::getBitCast(C, PTy);
38013804 else
576576 bool isForward = printTypeInternal(ET);
577577 std::string elemName(getCppName(ET));
578578 Out << "PointerType* " << typeName << " = PointerType::get("
579 << elemName << (isForward ? "_fwd" : "") << ");";
579 << elemName << (isForward ? "_fwd" : "")
580 << ", " << utostr(PT->getAddressSpace()) << ");";
580581 nl(Out);
581582 break;
582583 }
157157 EmitTypeForValueType(OS, MVT::getVectorElementType(VT));
158158 OS << ", " << MVT::getVectorNumElements(VT) << ")";
159159 } else if (VT == MVT::iPTR) {
160 OS << "PointerType::get(";
160 OS << "PointerType::getUnqual(";
161161 EmitTypeGenerate(OS, ArgType->getValueAsDef("ElTy"), ArgNo);
162162 OS << ")";
163163 } else if (VT == MVT::isVoid) {