diff options
author | Christopher Lamb <christopher.lamb@gmail.com> | 2007-12-17 01:12:55 +0000 |
---|---|---|
committer | Christopher Lamb <christopher.lamb@gmail.com> | 2007-12-17 01:12:55 +0000 |
commit | 43ad6b3e0d6ada51e9b23aab3e061187f1f5710c (patch) | |
tree | accb30ee96c29fc9e1021feaa850a435b60f81fc | |
parent | 303dae993aba2474a23753ed66737b8c38cc97a0 (diff) |
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
32 files changed, 172 insertions, 137 deletions
diff --git a/examples/BrainF/BrainF.cpp b/examples/BrainF/BrainF.cpp index e7e11aca0b..b75b51943c 100644 --- a/examples/BrainF/BrainF.cpp +++ b/examples/BrainF/BrainF.cpp @@ -54,7 +54,7 @@ void BrainF::header() { //declare void @llvm.memset.i32(i8 *, i8, i32, i32) Function *memset_func = cast<Function>(module-> getOrInsertFunction("llvm.memset.i32", Type::VoidTy, - PointerType::get(IntegerType::Int8Ty), + PointerType::getUnqual(IntegerType::Int8Ty), IntegerType::Int8Ty, IntegerType::Int32Ty, IntegerType::Int32Ty, NULL)); @@ -138,7 +138,7 @@ void BrainF::header() { //declare i32 @puts(i8 *) Function *puts_func = cast<Function>(module-> getOrInsertFunction("puts", IntegerType::Int32Ty, - PointerType::get(IntegerType::Int8Ty), NULL)); + PointerType::getUnqual(IntegerType::Int8Ty), NULL)); //brainf.aberror: aberrorbb = new BasicBlock(label, brainf_func); @@ -282,7 +282,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) { builder->SetInsertPoint(bb_1); //Make part of PHI instruction now, wait until end of loop to finish - PHINode *phi_0 = new PHINode(PointerType::get(IntegerType::Int8Ty), + PHINode *phi_0 = new PHINode(PointerType::getUnqual(IntegerType::Int8Ty), headreg, testbb); phi_0->reserveOperandSpace(2); phi_0->addIncoming(curhead, bb_0); @@ -439,7 +439,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) { //%head.%d = phi i8 *[%head.%d, %main.%d] PHINode *phi_1 = builder-> - CreatePHI(PointerType::get(IntegerType::Int8Ty), headreg); + CreatePHI(PointerType::getUnqual(IntegerType::Int8Ty), headreg); phi_1->reserveOperandSpace(1); phi_1->addIncoming(head_0, testbb); curhead = phi_1; diff --git a/examples/BrainF/BrainFDriver.cpp b/examples/BrainF/BrainFDriver.cpp index 7d29fe6f72..3f3b6c3392 100644 --- a/examples/BrainF/BrainFDriver.cpp +++ b/examples/BrainF/BrainFDriver.cpp @@ -59,7 +59,7 @@ void addMainFunction(Module *mod) { //define i32 @main(i32 %argc, i8 **%argv) Function *main_func = cast<Function>(mod-> getOrInsertFunction("main", IntegerType::Int32Ty, IntegerType::Int32Ty, - PointerType::get(PointerType::get( + PointerType::getUnqual(PointerType::getUnqual( IntegerType::Int8Ty)), NULL)); { Function::arg_iterator args = main_func->arg_begin(); diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h index d62cb3bcc9..c294f402e6 100644 --- a/include/llvm/DerivedTypes.h +++ b/include/llvm/DerivedTypes.h @@ -369,8 +369,15 @@ class PointerType : public SequentialType { const PointerType &operator=(const PointerType &); // Do not implement explicit PointerType(const Type *ElType, unsigned AddrSpace); public: - /// PointerType::get - This is the only way to construct a new pointer type. - static PointerType *get(const Type *ElementType, unsigned AddressSpace = 0); + /// PointerType::get - This constructs a pointer to an object of the specified + /// type in a numbered address space. + static PointerType *get(const Type *ElementType, unsigned AddressSpace); + + /// PointerType::getUnqual - This constructs a pointer to an object of the + /// specified type in the generic address space (address space zero). + static PointerType *getUnqual(const Type *ElementType) { + return PointerType::get(ElementType, 0); + } /// @brief Return the address space of the Pointer type. inline unsigned getAddressSpace() const { return AddressSpace; } diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index c1f52a2eb0..855034cd92 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -2280,7 +2280,7 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')' PAL = ParamAttrsList::get(Attrs); FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg); - const PointerType *PFT = PointerType::get(FT); + const PointerType *PFT = PointerType::getUnqual(FT); delete $2; ValID ID; @@ -2627,7 +2627,7 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result... ParamTypes.push_back(Ty); } Ty = FunctionType::get($3->get(), ParamTypes, false); - PFTy = PointerType::get(Ty); + PFTy = PointerType::getUnqual(Ty); } delete $3; @@ -2954,7 +2954,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { ParamTypes.push_back(Ty); } Ty = FunctionType::get($3->get(), ParamTypes, false); - PFTy = PointerType::get(Ty); + PFTy = PointerType::getUnqual(Ty); } Value *V = getVal(PFTy, $4); // Get the function we're calling... diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 72756ef6cd..4e761e402b 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1509,7 +1509,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { unsigned OpNum = 0; Value *Val, *Ptr; if (getValueTypePair(Record, OpNum, NextValueNo, Val) || - getValue(Record, OpNum, PointerType::get(Val->getType()), Ptr) || + getValue(Record, OpNum, PointerType::getUnqual(Val->getType()), Ptr)|| OpNum+2 != Record.size()) return Error("Invalid STORE record"); diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp index 0d1da867ed..ef14f0b322 100644 --- a/lib/CodeGen/IntrinsicLowering.cpp +++ b/lib/CodeGen/IntrinsicLowering.cpp @@ -81,22 +81,23 @@ void IntrinsicLowering::AddPrototypes(Module &M) { break; case Intrinsic::memcpy_i32: case Intrinsic::memcpy_i64: - M.getOrInsertFunction("memcpy", PointerType::get(Type::Int8Ty), - PointerType::get(Type::Int8Ty), - PointerType::get(Type::Int8Ty), + M.getOrInsertFunction("memcpy", PointerType::getUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), TD.getIntPtrType(), (Type *)0); break; case Intrinsic::memmove_i32: case Intrinsic::memmove_i64: - M.getOrInsertFunction("memmove", PointerType::get(Type::Int8Ty), - PointerType::get(Type::Int8Ty), - PointerType::get(Type::Int8Ty), + M.getOrInsertFunction("memmove", PointerType::getUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), TD.getIntPtrType(), (Type *)0); break; case Intrinsic::memset_i32: case Intrinsic::memset_i64: - M.getOrInsertFunction("memset", PointerType::get(Type::Int8Ty), - PointerType::get(Type::Int8Ty), Type::Int32Ty, + M.getOrInsertFunction("memset", PointerType::getUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), + Type::Int32Ty, TD.getIntPtrType(), (Type *)0); break; case Intrinsic::sqrt: diff --git a/lib/CodeGen/MachineModuleInfo.cpp b/lib/CodeGen/MachineModuleInfo.cpp index 9943fa9967..14253f4111 100644 --- a/lib/CodeGen/MachineModuleInfo.cpp +++ b/lib/CodeGen/MachineModuleInfo.cpp @@ -1262,7 +1262,7 @@ const PointerType *DISerializer::getStrPtrType() { // If not already defined. if (!StrPtrTy) { // Construct the pointer to signed bytes. - StrPtrTy = PointerType::get(Type::Int8Ty); + StrPtrTy = PointerType::getUnqual(Type::Int8Ty); } return StrPtrTy; @@ -1277,7 +1277,7 @@ const PointerType *DISerializer::getEmptyStructPtrType() { const StructType *EmptyStructTy = StructType::get(std::vector<const Type*>()); // Construct the pointer to empty structure type. - EmptyStructPtrTy = PointerType::get(EmptyStructTy); + EmptyStructPtrTy = PointerType::getUnqual(EmptyStructTy); } return EmptyStructPtrTy; diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 83c0094a49..6c2d9c3841 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -170,7 +170,7 @@ static void *CreateArgv(ExecutionEngine *EE, char *Result = new char[(InputArgv.size()+1)*PtrSize]; DOUT << "ARGV = " << (void*)Result << "\n"; - const Type *SBytePtr = PointerType::get(Type::Int8Ty); + const Type *SBytePtr = PointerType::getUnqual(Type::Int8Ty); for (unsigned i = 0; i != InputArgv.size(); ++i) { unsigned Size = InputArgv[i].size()+1; @@ -255,7 +255,8 @@ int ExecutionEngine::runFunctionAsMain(Function *Fn, // Check main() type unsigned NumArgs = Fn->getFunctionType()->getNumParams(); const FunctionType *FTy = Fn->getFunctionType(); - const Type* PPInt8Ty = PointerType::get(PointerType::get(Type::Int8Ty)); + const Type* PPInt8Ty = + PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty)); switch (NumArgs) { case 3: if (FTy->getParamType(2) != PPInt8Ty) { diff --git a/lib/Target/MSIL/MSILWriter.cpp b/lib/Target/MSIL/MSILWriter.cpp index 87107d8908..cc4739a8b0 100644 --- a/lib/Target/MSIL/MSILWriter.cpp +++ b/lib/Target/MSIL/MSILWriter.cpp @@ -783,7 +783,7 @@ void MSILWriter::printIntrinsicCall(const IntrinsicInst* Inst) { // Save as pointer type "void*" printValueLoad(Inst->getOperand(1)); printSimpleInstruction("ldloca",Name.c_str()); - printIndirectSave(PointerType::get(IntegerType::get(8))); + printIndirectSave(PointerType::getUnqual(IntegerType::get(8))); break; case Intrinsic::vaend: // Close argument list handle. @@ -1002,7 +1002,8 @@ void MSILWriter::printVAArgInstruction(const VAArgInst* Inst) { printSimpleInstruction("call", "instance typedref [mscorlib]System.ArgIterator::GetNextArg()"); printSimpleInstruction("refanyval","void*"); - std::string Name = "ldind."+getTypePostfix(PointerType::get(IntegerType::get(8)),false); + std::string Name = + "ldind."+getTypePostfix(PointerType::getUnqual(IntegerType::get(8)),false); printSimpleInstruction(Name.c_str()); } @@ -1217,7 +1218,7 @@ void MSILWriter::printLocalVariables(const Function& F) { const AllocaInst* AI = dyn_cast<AllocaInst>(&*I); if (AI && !isa<GlobalVariable>(AI)) { // Local variable allocation. - Ty = PointerType::get(AI->getAllocatedType()); + Ty = PointerType::getUnqual(AI->getAllocatedType()); Name = getValueName(AI); Out << "\t.locals (" << getTypeName(Ty) << Name << ")\n"; } else if (I->getType()!=Type::VoidTy) { diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index f574ed4606..a858fb22fa 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -1052,7 +1052,7 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI){ for (unsigned FieldNo = 0, e = STy->getNumElements(); FieldNo != e;++FieldNo){ const Type *FieldTy = STy->getElementType(FieldNo); - const Type *PFieldTy = PointerType::get(FieldTy); + const Type *PFieldTy = PointerType::getUnqual(FieldTy); GlobalVariable *NGV = new GlobalVariable(PFieldTy, false, GlobalValue::InternalLinkage, @@ -1618,7 +1618,7 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL, } else { const Type *FTy = FunctionType::get(Type::VoidTy, std::vector<const Type*>(), false); - const PointerType *PFTy = PointerType::get(FTy); + const PointerType *PFTy = PointerType::getUnqual(FTy); CSVals[1] = Constant::getNullValue(PFTy); CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647); } diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index 90ece1799d..389ddebc6a 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -199,8 +199,8 @@ bool LowerSetJmp::runOnModule(Module& M) { // This function is always successful, unless it isn't. bool LowerSetJmp::doInitialization(Module& M) { - const Type *SBPTy = PointerType::get(Type::Int8Ty); - const Type *SBPPTy = PointerType::get(SBPTy); + const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty); + const Type *SBPPTy = PointerType::getUnqual(SBPTy); // N.B. See llvm/runtime/GCCLibraries/libexception/SJLJ-Exception.h for // a description of the following library functions. @@ -256,7 +256,7 @@ bool LowerSetJmp::IsTransformableFunction(const std::string& Name) { // throwing the exception for us. void LowerSetJmp::TransformLongJmpCall(CallInst* Inst) { - const Type* SBPTy = PointerType::get(Type::Int8Ty); + const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty); // Create the call to "__llvm_sjljeh_throw_longjmp". This takes the // same parameters as "longjmp", except that the buffer is cast to a @@ -308,7 +308,7 @@ AllocaInst* LowerSetJmp::GetSetJmpMap(Function* Func) assert(Inst && "Couldn't find even ONE instruction in entry block!"); // Fill in the alloca and call to initialize the SJ map. - const Type *SBPTy = PointerType::get(Type::Int8Ty); + const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty); AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst); new CallInst(InitSJMap, Map, "", Inst); return SJMap[Func] = Map; @@ -378,7 +378,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst) Function* Func = ABlock->getParent(); // Add this setjmp to the setjmp map. - const Type* SBPTy = PointerType::get(Type::Int8Ty); + const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty); CastInst* BufPtr = new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst); std::vector<Value*> Args = diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp index e6d8723f45..ca4be9e528 100644 --- a/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/lib/Transforms/IPO/RaiseAllocations.cpp @@ -78,7 +78,7 @@ void RaiseAllocations::doInitialization(Module &M) { // Get the expected prototype for malloc const FunctionType *Malloc1Type = - FunctionType::get(PointerType::get(Type::Int8Ty), + FunctionType::get(PointerType::getUnqual(Type::Int8Ty), std::vector<const Type*>(1, Type::Int64Ty), false); // Chck to see if we got the expected malloc @@ -86,14 +86,14 @@ void RaiseAllocations::doInitialization(Module &M) { // Check to see if the prototype is wrong, giving us sbyte*(uint) * malloc // This handles the common declaration of: 'void *malloc(unsigned);' const FunctionType *Malloc2Type = - FunctionType::get(PointerType::get(Type::Int8Ty), + FunctionType::get(PointerType::getUnqual(Type::Int8Ty), std::vector<const Type*>(1, Type::Int32Ty), false); if (TyWeHave != Malloc2Type) { // Check to see if the prototype is missing, giving us // sbyte*(...) * malloc // This handles the common declaration of: 'void *malloc();' const FunctionType *Malloc3Type = - FunctionType::get(PointerType::get(Type::Int8Ty), + FunctionType::get(PointerType::getUnqual(Type::Int8Ty), std::vector<const Type*>(), true); if (TyWeHave != Malloc3Type) // Give up @@ -108,7 +108,7 @@ void RaiseAllocations::doInitialization(Module &M) { // Get the expected prototype for void free(i8*) const FunctionType *Free1Type = FunctionType::get(Type::VoidTy, - std::vector<const Type*>(1, PointerType::get(Type::Int8Ty)), false); + std::vector<const Type*>(1, PointerType::getUnqual(Type::Int8Ty)), false); if (TyWeHave != Free1Type) { // Check to see if the prototype was forgotten, giving us @@ -219,7 +219,8 @@ bool RaiseAllocations::runOnModule(Module &M) { // Value *Source = *CS.arg_begin(); if (!isa<PointerType>(Source->getType())) - Source = new IntToPtrInst(Source, PointerType::get(Type::Int8Ty), + Source = new IntToPtrInst(Source, + PointerType::getUnqual(Type::Int8Ty), "FreePtrCast", I); new FreeInst(Source, I); diff --git a/lib/Transforms/IPO/SimplifyLibCalls.cpp b/lib/Transforms/IPO/SimplifyLibCalls.cpp index 0904c4c6c1..1547b6c308 100644 --- a/lib/Transforms/IPO/SimplifyLibCalls.cpp +++ b/lib/Transforms/IPO/SimplifyLibCalls.cpp @@ -244,7 +244,7 @@ public: Constant *get_puts() { if (!puts_func) puts_func = M->getOrInsertFunction("puts", Type::Int32Ty, - PointerType::get(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), NULL); return puts_func; } @@ -261,7 +261,7 @@ public: Constant *get_fputs(const Type* FILEptr_type) { if (!fputs_func) fputs_func = M->getOrInsertFunction("fputs", Type::Int32Ty, - PointerType::get(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), FILEptr_type, NULL); return fputs_func; } @@ -270,7 +270,7 @@ public: Constant *get_fwrite(const Type* FILEptr_type) { if (!fwrite_func) fwrite_func = M->getOrInsertFunction("fwrite", TD->getIntPtrType(), - PointerType::get(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), TD->getIntPtrType(), TD->getIntPtrType(), FILEptr_type, NULL); @@ -289,9 +289,9 @@ public: Constant *get_strcpy() { if (!strcpy_func) strcpy_func = M->getOrInsertFunction("strcpy", - PointerType::get(Type::Int8Ty), - PointerType::get(Type::Int8Ty), - PointerType::get(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), NULL); return strcpy_func; } @@ -300,7 +300,7 @@ public: Constant *get_strlen() { if (!strlen_func) strlen_func = M->getOrInsertFunction("strlen", TD->getIntPtrType(), - PointerType::get(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), NULL); return strlen_func; } @@ -309,8 +309,8 @@ public: Constant *get_memchr() { if (!memchr_func) memchr_func = M->getOrInsertFunction("memchr", - PointerType::get(Type::Int8Ty), - PointerType::get(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), Type::Int32Ty, TD->getIntPtrType(), NULL); return memchr_func; @@ -319,7 +319,7 @@ public: /// @brief Return a Function* for the memcpy libcall Constant *get_memcpy() { if (!memcpy_func) { - const Type *SBP = PointerType::get(Type::Int8Ty); + const Type *SBP = PointerType::getUnqual(Type::Int8Ty); const char *N = TD->getIntPtrType() == Type::Int32Ty ? "llvm.memcpy.i32" : "llvm.memcpy.i64"; memcpy_func = M->getOrInsertFunction(N, Type::VoidTy, SBP, SBP, @@ -471,7 +471,7 @@ public: virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ const FunctionType *FT = F->getFunctionType(); return FT->getNumParams() == 2 && - FT->getReturnType() == PointerType::get(Type::Int8Ty) && + FT->getReturnType() == PointerType::getUnqual(Type::Int8Ty) && FT->getParamType(0) == FT->getReturnType() && FT->getParamType(1) == FT->getReturnType(); } @@ -528,7 +528,7 @@ public: virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ const FunctionType *FT = F->getFunctionType(); return FT->getNumParams() == 2 && - FT->getReturnType() == PointerType::get(Type::Int8Ty) && + FT->getReturnType() == PointerType::getUnqual(Type::Int8Ty) && FT->getParamType(0) == FT->getReturnType() && isa<IntegerType>(FT->getParamType(1)); } @@ -594,7 +594,7 @@ public: const FunctionType *FT = F->getFunctionType(); return FT->getReturnType() == Type::Int32Ty && FT->getNumParams() == 2 && FT->getParamType(0) == FT->getParamType(1) && - FT->getParamType(0) == PointerType::get(Type::Int8Ty); + FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty); } /// @brief Perform the strcmp optimization @@ -647,7 +647,7 @@ public: const FunctionType *FT = F->getFunctionType(); return FT->getReturnType() == Type::Int32Ty && FT->getNumParams() == 3 && FT->getParamType(0) == FT->getParamType(1) && - FT->getParamType(0) == PointerType::get(Type::Int8Ty) && + FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) && isa<IntegerType>(FT->getParamType(2)); return false; } @@ -715,7 +715,7 @@ public: return FT->getNumParams() == 2 && FT->getParamType(0) == FT->getParamType(1) && FT->getReturnType() == FT->getParamType(0) && - FT->getParamType(0) == PointerType::get(Type::Int8Ty); + FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty); } /// @brief Perform the strcpy optimization @@ -770,7 +770,7 @@ struct VISIBILITY_HIDDEN StrLenOptimization : public LibCallOptimization { virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ const FunctionType *FT = F->getFunctionType(); return FT->getNumParams() == 1 && - FT->getParamType(0) == PointerType::get(Type::Int8Ty) && + FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) && isa<IntegerType>(FT->getReturnType()); } @@ -870,7 +870,7 @@ struct VISIBILITY_HIDDEN memcmpOptimization : public LibCallOptimization { return ReplaceCallWith(CI, Constant::getNullValue(CI->getType())); case 1: { // memcmp(S1,S2,1) -> *(ubyte*)S1 - *(ubyte*)S2 - const Type *UCharPtr = PointerType::get(Type::Int8Ty); + const Type *UCharPtr = PointerType::getUnqual(Type::Int8Ty); CastInst *Op1Cast = CastInst::create( Instruction::BitCast, LHS, UCharPtr, LHS->getName(), CI); CastInst *Op2Cast = CastInst::create( @@ -888,7 +888,7 @@ struct VISIBILITY_HIDDEN memcmpOptimization : public LibCallOptimization { // TODO: IF both are aligned, use a short load/compare. // memcmp(S1,S2,2) -> S1[0]-S2[0] | S1[1]-S2[1] iff only ==/!= 0 matters - const Type *UCharPtr = PointerType::get(Type::Int8Ty); + const Type *UCharPtr = PointerType::getUnqual(Type::Int8Ty); CastInst *Op1Cast = CastInst::create( Instruction::BitCast, LHS, UCharPtr, LHS->getName(), CI); CastInst *Op2Cast = CastInst::create( @@ -976,9 +976,9 @@ struct VISIBILITY_HIDDEN LLVMMemCpyMoveOptzn : public LibCallOptimization { // Cast source and dest to the right sized primitive and then load/store CastInst* SrcCast = CastInst::create(Instruction::BitCast, - src, PointerType::get(castType), src->getName()+".cast", ci); + src, PointerType::getUnqual(castType), src->getName()+".cast", ci); CastInst* DestCast = CastInst::create(Instruction::BitCast, - dest, PointerType::get(castType),dest->getName()+".cast", ci); + dest, PointerType::getUnqual(castType),dest->getName()+".cast", ci); LoadInst* LI = new LoadInst(SrcCast,SrcCast->getName()+".val",ci); new StoreInst(LI, DestCast, ci); return ReplaceCallWith(ci, 0); @@ -1085,7 +1085,7 @@ struct VISIBILITY_HIDDEN LLVMMemSetOptimization : public LibCallOptimization { } // Cast dest to the right sized primitive and then load/store - CastInst* DestCast = new BitCastInst(dest, PointerType::get(castType), + CastInst* DestCast = new BitCastInst(dest, PointerType::getUnqual(castType), dest->getName()+".cast", ci); new StoreInst(ConstantInt::get(castType,fill_value),DestCast, ci); return ReplaceCallWith(ci, 0); @@ -1207,7 +1207,7 @@ public: Init, "str", CI->getParent()->getParent()->getParent()); // Cast GV to be a pointer to char. - GV = ConstantExpr::getBitCast(GV, PointerType::get(Type::Int8Ty)); + GV = ConstantExpr::getBitCast(GV, PointerType::getUnqual(Type::Int8Ty)); new CallInst(SLC.get_puts(), GV, "", CI); if (CI->use_empty()) return ReplaceCallWith(CI, 0); @@ -1268,7 +1268,7 @@ public: virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ const FunctionType *FT = F->getFunctionType(); return FT->getNumParams() == 2 && // two fixed arguments. - FT->getParamType(1) == PointerType::get(Type::Int8Ty) && + FT->getParamType(1) == PointerType::getUnqual(Type::Int8Ty) && isa<PointerType>(FT->getParamType(0)) && isa<IntegerType>(FT->getReturnType()); } @@ -1358,7 +1358,7 @@ public: virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ const FunctionType *FT = F->getFunctionType(); return FT->getNumParams() == 2 && // two fixed arguments. - FT->getParamType(1) == PointerType::get(Type::Int8Ty) && + FT->getParamType(1) == PointerType::getUnqual(Type::Int8Ty) && FT->getParamType(0) == FT->getParamType(1) && isa<IntegerType>(FT->getReturnType()); } @@ -1491,7 +1491,7 @@ public: virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ const FunctionType *FT = F->getFunctionType(); return FT->getNumParams() == 4 && - FT->getParamType(0) == PointerType::get(Type::Int8Ty) && + FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) && FT->getParamType(1) == FT->getParamType(2) && isa<IntegerType>(FT->getParamType(1)) && isa<PointerType>(FT->getParamType(3)) && @@ -1927,7 +1927,7 @@ static bool GetConstantStringInfo(Value *V, std::string &Str) { static Value *CastToCStr(Value *V, Instruction *IP) { assert(isa<PointerType>(V->getType()) && "Can't cast non-pointer type to C string type"); - const Type *SBPTy = PointerType::get(Type::Int8Ty); + const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty); if (V->getType() != SBPTy) return new BitCastInst(V, SBPTy, V->getName(), IP); return V; diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp index 91b8ec2c5c..dacd92aef7 100644 --- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp +++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp @@ -22,8 +22,9 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName, GlobalValue *Array) { - const Type *ArgVTy = PointerType::get(PointerType::get(Type::Int8Ty)); - const PointerType *UIntPtr = PointerType::get(Type::Int32Ty); + const Type *ArgVTy = + PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty)); + const PointerType *UIntPtr = PointerType::getUnqual(Type::Int32Ty); Module &M = *MainFn->getParent(); Constant *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty, |