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
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index 6bf42d4..b8731b0 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -679,8 +679,8 @@
   // Prototype: void *getPointerToNamedFunction(const char* Name)
   Constant *resolverFunc =
     Safe->getOrInsertFunction("getPointerToNamedFunction",
-                              PointerType::get(Type::Int8Ty),
-                              PointerType::get(Type::Int8Ty), (Type *)0);
+                              PointerType::getUnqual(Type::Int8Ty),
+                              PointerType::getUnqual(Type::Int8Ty), (Type *)0);
 
   // Use the function we just added to get addresses of functions we need.
   for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) {
@@ -739,7 +739,7 @@
                                             "resolver", LookupBB);
           // cast the result from the resolver to correctly-typed function
           CastInst *CastedResolver = new BitCastInst(Resolver, 
-            PointerType::get(F->getFunctionType()), "resolverCast", LookupBB);
+            PointerType::getUnqual(F->getFunctionType()), "resolverCast", LookupBB);
 
           // Save the value in our cache.
           new StoreInst(CastedResolver, Cache, LookupBB);
diff --git a/tools/llvm-upgrade/UpgradeParser.y b/tools/llvm-upgrade/UpgradeParser.y
index 7a6e3ef..bcabaa3 100644
--- a/tools/llvm-upgrade/UpgradeParser.y
+++ b/tools/llvm-upgrade/UpgradeParser.y
@@ -829,7 +829,7 @@
   if (isa<FunctionType>(Ty))
     error("Cannot declare global vars of function type");
 
-  const PointerType *PTy = PointerType::get(Ty);
+  const PointerType *PTy = PointerType::getUnqual(Ty);
 
   std::string Name;
   if (NameStr) {
@@ -883,7 +883,8 @@
       }
 
       // Put the renaming in the global rename map
-      RenameMapKey Key = makeRenameMapKey(Name, PointerType::get(Ty), ID.S);
+      RenameMapKey Key = 
+        makeRenameMapKey(Name, PointerType::getUnqual(Ty), ID.S);
       CurModule.RenameMap[Key] = NewName;
 
       // Rename it
@@ -1404,7 +1405,7 @@
       break;
 
     case 'v' : {
-      const Type* PtrTy = PointerType::get(Type::Int8Ty);
+      const Type* PtrTy = PointerType::getUnqual(Type::Int8Ty);
       std::vector<const Type*> Params;
       if (Name == "llvm.va_start" || Name == "llvm.va_end") {
         if (Args.size() != 1)
@@ -1412,7 +1413,7 @@
         Params.push_back(PtrTy);
         const FunctionType *FTy = 
           FunctionType::get(Type::VoidTy, Params, false);
-        const PointerType *PFTy = PointerType::get(FTy);
+        const PointerType *PFTy = PointerType::getUnqual(FTy);
         Value* Func = getVal(PFTy, ID);
         Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
         return new CallInst(Func, Args.begin(), Args.end());
@@ -1423,7 +1424,7 @@
         Params.push_back(PtrTy);
         const FunctionType *FTy = 
           FunctionType::get(Type::VoidTy, Params, false);
-        const PointerType *PFTy = PointerType::get(FTy);
+        const PointerType *PFTy = PointerType::getUnqual(FTy);
         Value* Func = getVal(PFTy, ID);
         std::string InstName0(makeNameUnique("va0"));
         std::string InstName1(makeNameUnique("va1"));
@@ -1592,7 +1593,7 @@
 
       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
       const Type* ArgTy = F->getFunctionType()->getReturnType();
-      const Type* ArgTyPtr = PointerType::get(ArgTy);
+      const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
       Function* NF = cast<Function>(Result->getOrInsertFunction(
         "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
 
@@ -1619,7 +1620,7 @@
       //vaend bar
       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
       const Type* ArgTy = F->getFunctionType()->getParamType(0);
-      const Type* ArgTyPtr = PointerType::get(ArgTy);
+      const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
       Function* NF = cast<Function>(Result->getOrInsertFunction(
         "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
 
@@ -1648,7 +1649,7 @@
       
       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
       const Type* ArgTy = F->getFunctionType()->getReturnType();
-      const Type* ArgTyPtr = PointerType::get(ArgTy);
+      const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
       Function* NF = cast<Function>(Result->getOrInsertFunction(
         "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
 
@@ -2126,8 +2127,9 @@
     if ($1.PAT->get() == Type::LabelTy)
       error("Cannot form a pointer to a basic block");
     $$.S.makeComposite($1.S);
-    $$.PAT = new PATypeHolder(HandleUpRefs(PointerType::get($1.PAT->get()),
-                                           $$.S));
+    $$.PAT = new  
+      PATypeHolder(HandleUpRefs(PointerType::getUnqual($1.PAT->get()),
+                                $$.S));
     delete $1.PAT;
   }
   ;
@@ -2834,10 +2836,10 @@
     // i8*. We check here for those names and override the parameter list
     // types to ensure the prototype is correct.
     if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
-      ParamTyList.push_back(PointerType::get(Type::Int8Ty));
+      ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
     } else if (FunctionName == "llvm.va_copy") {
-      ParamTyList.push_back(PointerType::get(Type::Int8Ty));
-      ParamTyList.push_back(PointerType::get(Type::Int8Ty));
+      ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
+      ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
     } else if ($5) {   // If there are arguments...
       for (std::vector<std::pair<PATypeInfo,char*> >::iterator 
            I = $5->begin(), E = $5->end(); I != E; ++I) {
@@ -2852,7 +2854,7 @@
       ParamTyList.pop_back();
 
     const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg);
-    const PointerType *PFT = PointerType::get(FT);
+    const PointerType *PFT = PointerType::getUnqual(FT);
     delete $2.PAT;
 
     ValID ID;
@@ -3102,7 +3104,8 @@
   }
   ;
 
-// SymbolicValueRef - Reference to one of two ways of symbolically refering to // another value.
+// SymbolicValueRef - Reference to one of two ways of symbolically refering to 
+// another value.
 //
 SymbolicValueRef 
   : INTVAL {  $$ = ValID::create($1); $$.S.makeSignless(); }
@@ -3251,7 +3254,7 @@
       bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
       if (isVarArg) ParamTypes.pop_back();
       Ty = FunctionType::get($3.PAT->get(), ParamTypes, isVarArg);
-      PFTy = PointerType::get(Ty);
+      PFTy = PointerType::getUnqual(Ty);
       $$.S.copy($3.S);
     } else {
       FTySign = $3.S;
@@ -3656,7 +3659,7 @@
         error("Functions cannot return aggregate types");
 
       FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
-      PFTy = PointerType::get(FTy);
+      PFTy = PointerType::getUnqual(FTy);
       $$.S.copy($3.S);
     } else {
       FTySign = $3.S;
@@ -3796,7 +3799,7 @@
     Value *StoreVal = $3.V;
     Value* tmpVal = getVal(PTy, $6);
     if (ElTy != $3.V->getType()) {
-      PTy = PointerType::get(StoreVal->getType());
+      PTy = PointerType::getUnqual(StoreVal->getType());
       if (Constant *C = dyn_cast<Constant>(tmpVal))
         tmpVal = ConstantExpr::getBitCast(C, PTy);
       else
diff --git a/tools/llvm2cpp/CppWriter.cpp b/tools/llvm2cpp/CppWriter.cpp
index 18bdc1b..b3aaf25 100644
--- a/tools/llvm2cpp/CppWriter.cpp
+++ b/tools/llvm2cpp/CppWriter.cpp
@@ -577,7 +577,8 @@
       bool isForward = printTypeInternal(ET);
       std::string elemName(getCppName(ET));
       Out << "PointerType* " << typeName << " = PointerType::get("
-          << elemName << (isForward ? "_fwd" : "") << ");";
+          << elemName << (isForward ? "_fwd" : "")
+          << ", " << utostr(PT->getAddressSpace()) << ");";
       nl(Out);
       break;
     }