bjope updated this revision to Diff 545783.
bjope added a comment.
Herald added a subscriber: ormris.

Replaced a couple of more occurances in this update.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156733/new/

https://reviews.llvm.org/D156733

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
  clang/unittests/CodeGen/TBAAMetadataTest.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/IR/Function.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/lib/Target/ARM/ARMFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/lib/Transforms/InstCombine/InstCombineInternal.h
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
  llvm/tools/llvm-stress/llvm-stress.cpp
  llvm/unittests/Analysis/AliasAnalysisTest.cpp
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
  llvm/unittests/Analysis/PhiValuesTest.cpp
  llvm/unittests/Analysis/SparsePropagation.cpp
  llvm/unittests/Analysis/TBAATest.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  llvm/unittests/IR/BasicBlockTest.cpp
  llvm/unittests/IR/ConstantsTest.cpp
  llvm/unittests/IR/InstructionsTest.cpp
  llvm/unittests/IR/MetadataTest.cpp
  llvm/unittests/Transforms/Utils/CloningTest.cpp
  llvm/unittests/Transforms/Utils/LocalTest.cpp
  llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp

Index: llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
===================================================================
--- llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
+++ llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
@@ -73,9 +73,9 @@
   // expansion when the value in ValueOffsetPair is a ptr and the offset
   // is not divisible by the elem type size of value.
   auto *I8Ty = Type::getInt8Ty(Context);
-  auto *I8PtrTy = Type::getInt8PtrTy(Context);
+  auto *I8PtrTy = PointerType::get(Context, 0);
   auto *I32Ty = Type::getInt32Ty(Context);
-  auto *I32PtrTy = Type::getInt32PtrTy(Context);
+  auto *I32PtrTy = PointerType::get(Context, 0);
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(Context), std::vector<Type *>(), false);
   Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
Index: llvm/unittests/Transforms/Utils/LocalTest.cpp
===================================================================
--- llvm/unittests/Transforms/Utils/LocalTest.cpp
+++ llvm/unittests/Transforms/Utils/LocalTest.cpp
@@ -154,7 +154,7 @@
   ASSERT_TRUE(Inst);
   auto *DII = dyn_cast<DbgDeclareInst>(Inst);
   ASSERT_TRUE(DII);
-  Value *NewBase = Constant::getNullValue(Type::getInt32PtrTy(C));
+  Value *NewBase = Constant::getNullValue(PointerType::getUnqual(C));
   DIBuilder DIB(*M);
   replaceDbgDeclare(AI, NewBase, DIB, DIExpression::ApplyOffset, 0);
 
Index: llvm/unittests/Transforms/Utils/CloningTest.cpp
===================================================================
--- llvm/unittests/Transforms/Utils/CloningTest.cpp
+++ llvm/unittests/Transforms/Utils/CloningTest.cpp
@@ -137,7 +137,7 @@
 }
 
 TEST_F(CloneInstruction, Inbounds) {
-  V = new Argument(Type::getInt32PtrTy(context));
+  V = new Argument(PointerType::get(context, 0));
 
   Constant *Z = Constant::getNullValue(Type::getInt32Ty(context));
   std::vector<Value *> ops;
@@ -161,8 +161,9 @@
 }
 
 TEST_F(CloneInstruction, Attributes) {
-  Type *ArgTy1[] = { Type::getInt32PtrTy(context) };
-  FunctionType *FT1 =  FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
+  Type *ArgTy1[] = {PointerType::get(context, 0)};
+  FunctionType *FT1 =
+      FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
 
   Function *F1 = Function::Create(FT1, Function::ExternalLinkage);
   BasicBlock *BB = BasicBlock::Create(context, "", F1);
@@ -187,8 +188,9 @@
 }
 
 TEST_F(CloneInstruction, CallingConvention) {
-  Type *ArgTy1[] = { Type::getInt32PtrTy(context) };
-  FunctionType *FT1 =  FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
+  Type *ArgTy1[] = {PointerType::get(context, 0)};
+  FunctionType *FT1 =
+      FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
 
   Function *F1 = Function::Create(FT1, Function::ExternalLinkage);
   F1->setCallingConv(CallingConv::Cold);
@@ -211,7 +213,7 @@
 }
 
 TEST_F(CloneInstruction, DuplicateInstructionsToSplit) {
-  Type *ArgTy1[] = {Type::getInt32PtrTy(context)};
+  Type *ArgTy1[] = {PointerType::get(context, 0)};
   FunctionType *FT = FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
   V = new Argument(Type::getInt32Ty(context));
 
@@ -260,7 +262,7 @@
 }
 
 TEST_F(CloneInstruction, DuplicateInstructionsToSplitBlocksEq1) {
-  Type *ArgTy1[] = {Type::getInt32PtrTy(context)};
+  Type *ArgTy1[] = {PointerType::get(context, 0)};
   FunctionType *FT = FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
   V = new Argument(Type::getInt32Ty(context));
 
@@ -313,7 +315,7 @@
 }
 
 TEST_F(CloneInstruction, DuplicateInstructionsToSplitBlocksEq2) {
-  Type *ArgTy1[] = {Type::getInt32PtrTy(context)};
+  Type *ArgTy1[] = {PointerType::get(context, 0)};
   FunctionType *FT = FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
   V = new Argument(Type::getInt32Ty(context));
 
Index: llvm/unittests/IR/MetadataTest.cpp
===================================================================
--- llvm/unittests/IR/MetadataTest.cpp
+++ llvm/unittests/IR/MetadataTest.cpp
@@ -551,7 +551,7 @@
 
 TEST_F(MDNodeTest, DistinctOnDeletedValueOperand) {
   // i1* @GV
-  Type *Ty = Type::getInt1PtrTy(Context);
+  Type *Ty = PointerType::getUnqual(Context);
   std::unique_ptr<GlobalVariable> GV(
       new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
   ConstantAsMetadata *Op = ConstantAsMetadata::get(GV.get());
@@ -790,7 +790,7 @@
 
 TEST_F(MDNodeTest, replaceWithUniquedDeletedOperand) {
   // i1* @GV
-  Type *Ty = Type::getInt1PtrTy(Context);
+  Type *Ty = PointerType::getUnqual(Context);
   std::unique_ptr<GlobalVariable> GV(
       new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
   ConstantAsMetadata *Op = ConstantAsMetadata::get(GV.get());
@@ -813,7 +813,7 @@
 
 TEST_F(MDNodeTest, replaceWithUniquedChangedOperand) {
   // i1* @GV
-  Type *Ty = Type::getInt1PtrTy(Context);
+  Type *Ty = PointerType::getUnqual(Context);
   std::unique_ptr<GlobalVariable> GV(
       new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
   ConstantAsMetadata *Op = ConstantAsMetadata::get(GV.get());
@@ -3711,7 +3711,7 @@
 typedef MetadataTest ValueAsMetadataTest;
 
 TEST_F(ValueAsMetadataTest, UpdatesOnRAUW) {
-  Type *Ty = Type::getInt1PtrTy(Context);
+  Type *Ty = PointerType::getUnqual(Context);
   std::unique_ptr<GlobalVariable> GV0(
       new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
   auto *MD = ValueAsMetadata::get(GV0.get());
@@ -3783,7 +3783,7 @@
 }
 
 TEST_F(DIArgListTest, UpdatesOnRAUW) {
-  Type *Ty = Type::getInt1PtrTy(Context);
+  Type *Ty = PointerType::getUnqual(Context);
   ConstantAsMetadata *CI =
       ConstantAsMetadata::get(ConstantInt::get(Context, APInt(8, 0)));
   std::unique_ptr<GlobalVariable> GV0(
@@ -3808,7 +3808,7 @@
 typedef MetadataTest TrackingMDRefTest;
 
 TEST_F(TrackingMDRefTest, UpdatesOnRAUW) {
-  Type *Ty = Type::getInt1PtrTy(Context);
+  Type *Ty = PointerType::getUnqual(Context);
   std::unique_ptr<GlobalVariable> GV0(
       new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
   TypedTrackingMDRef<ValueAsMetadata> MD(ValueAsMetadata::get(GV0.get()));
@@ -3825,7 +3825,7 @@
 }
 
 TEST_F(TrackingMDRefTest, UpdatesOnDeletion) {
-  Type *Ty = Type::getInt1PtrTy(Context);
+  Type *Ty = PointerType::getUnqual(Context);
   std::unique_ptr<GlobalVariable> GV(
       new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
   TypedTrackingMDRef<ValueAsMetadata> MD(ValueAsMetadata::get(GV.get()));
Index: llvm/unittests/IR/InstructionsTest.cpp
===================================================================
--- llvm/unittests/IR/InstructionsTest.cpp
+++ llvm/unittests/IR/InstructionsTest.cpp
@@ -635,7 +635,7 @@
   Type* Int16Ty = Type::getInt16Ty(C);
   Type* Int32Ty = Type::getInt32Ty(C);
   Type* Int64Ty = Type::getInt64Ty(C);
-  Type* Int64PtrTy = Type::getInt64PtrTy(C);
+  Type *Int64PtrTy = PointerType::get(C, 0);
 
   // Source and destination pointers have same size -> bitcast.
   EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::PtrToInt,
@@ -680,8 +680,8 @@
                 "-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64"
                 "-v128:128:128-a:0:64-s:64:64-f80:128:128-n8:16:32:64-S128");
 
-  Type* Int64PtrTyAS1 = Type::getInt64PtrTy(C, 1);
-  Type* Int64PtrTyAS2 = Type::getInt64PtrTy(C, 2);
+  Type *Int64PtrTyAS1 = PointerType::get(C, 1);
+  Type *Int64PtrTyAS2 = PointerType::get(C, 2);
 
   IntegerType *Int16SizePtr = DL.getIntPtrType(C, 1);
   IntegerType *Int64SizePtr = DL.getIntPtrType(C, 2);
Index: llvm/unittests/IR/ConstantsTest.cpp
===================================================================
--- llvm/unittests/IR/ConstantsTest.cpp
+++ llvm/unittests/IR/ConstantsTest.cpp
@@ -127,66 +127,60 @@
 
 TEST(ConstantsTest, PointerCast) {
   LLVMContext C;
-  Type *Int8PtrTy = Type::getInt8PtrTy(C);
-  Type *Int32PtrTy = Type::getInt32PtrTy(C);
+  Type *PtrTy = PointerType::get(C, 0);
   Type *Int64Ty = Type::getInt64Ty(C);
-  VectorType *Int8PtrVecTy = FixedVectorType::get(Int8PtrTy, 4);
-  VectorType *Int32PtrVecTy = FixedVectorType::get(Int32PtrTy, 4);
+  VectorType *PtrVecTy = FixedVectorType::get(PtrTy, 4);
   VectorType *Int64VecTy = FixedVectorType::get(Int64Ty, 4);
-  VectorType *Int8PtrScalableVecTy = ScalableVectorType::get(Int8PtrTy, 4);
-  VectorType *Int32PtrScalableVecTy = ScalableVectorType::get(Int32PtrTy, 4);
+  VectorType *PtrScalableVecTy = ScalableVectorType::get(PtrTy, 4);
   VectorType *Int64ScalableVecTy = ScalableVectorType::get(Int64Ty, 4);
 
-  // ptrtoint i8* to i64
+  // ptrtoint ptr to i64
   EXPECT_EQ(
       Constant::getNullValue(Int64Ty),
-      ConstantExpr::getPointerCast(Constant::getNullValue(Int8PtrTy), Int64Ty));
+      ConstantExpr::getPointerCast(Constant::getNullValue(PtrTy), Int64Ty));
 
-  // bitcast i8* to i32*
-  EXPECT_EQ(Constant::getNullValue(Int32PtrTy),
-            ConstantExpr::getPointerCast(Constant::getNullValue(Int8PtrTy),
-                                         Int32PtrTy));
+  // bitcast ptr to ptr
+  EXPECT_EQ(Constant::getNullValue(PtrTy),
+            ConstantExpr::getPointerCast(Constant::getNullValue(PtrTy), PtrTy));
 
-  // ptrtoint <4 x i8*> to <4 x i64>
+  // ptrtoint <4 x ptr> to <4 x i64>
   EXPECT_EQ(Constant::getNullValue(Int64VecTy),
-            ConstantExpr::getPointerCast(Constant::getNullValue(Int8PtrVecTy),
+            ConstantExpr::getPointerCast(Constant::getNullValue(PtrVecTy),
                                          Int64VecTy));
 
-  // ptrtoint <vscale x 4 x i8*> to <vscale x 4 x i64>
-  EXPECT_EQ(
-      Constant::getNullValue(Int64ScalableVecTy),
-      ConstantExpr::getPointerCast(Constant::getNullValue(Int8PtrScalableVecTy),
-                                   Int64ScalableVecTy));
-
-  // bitcast <4 x i8*> to <4 x i32*>
-  EXPECT_EQ(Constant::getNullValue(Int32PtrVecTy),
-            ConstantExpr::getPointerCast(Constant::getNullValue(Int8PtrVecTy),
-                                         Int32PtrVecTy));
+  // ptrtoint <vscale x 4 x ptr> to <vscale x 4 x i64>
+  EXPECT_EQ(Constant::getNullValue(Int64ScalableVecTy),
+            ConstantExpr::getPointerCast(
+                Constant::getNullValue(PtrScalableVecTy), Int64ScalableVecTy));
 
-  // bitcast <vscale x 4 x i8*> to <vscale x 4 x i32*>
+  // bitcast <4 x ptr> to <4 x ptr>
   EXPECT_EQ(
-      Constant::getNullValue(Int32PtrScalableVecTy),
-      ConstantExpr::getPointerCast(Constant::getNullValue(Int8PtrScalableVecTy),
-                                   Int32PtrScalableVecTy));
+      Constant::getNullValue(PtrVecTy),
+      ConstantExpr::getPointerCast(Constant::getNullValue(PtrVecTy), PtrVecTy));
+
+  // bitcast <vscale x 4 x ptr> to <vscale x 4 x ptr>
+  EXPECT_EQ(Constant::getNullValue(PtrScalableVecTy),
+            ConstantExpr::getPointerCast(
+                Constant::getNullValue(PtrScalableVecTy), PtrScalableVecTy));
 
-  Type *Int32Ptr1Ty = Type::getInt32PtrTy(C, 1);
+  Type *Ptr1Ty = PointerType::get(C, 1);
   ConstantInt *K = ConstantInt::get(Type::getInt64Ty(C), 1234);
 
   // Make sure that addrspacecast of inttoptr is not folded away.
   EXPECT_NE(K, ConstantExpr::getAddrSpaceCast(
-                   ConstantExpr::getIntToPtr(K, Int32PtrTy), Int32Ptr1Ty));
+                   ConstantExpr::getIntToPtr(K, PtrTy), Ptr1Ty));
   EXPECT_NE(K, ConstantExpr::getAddrSpaceCast(
-                   ConstantExpr::getIntToPtr(K, Int32Ptr1Ty), Int32PtrTy));
+                   ConstantExpr::getIntToPtr(K, Ptr1Ty), PtrTy));
 
-  Constant *NullInt32Ptr0 = Constant::getNullValue(Int32PtrTy);
-  Constant *NullInt32Ptr1 = Constant::getNullValue(Int32Ptr1Ty);
+  Constant *NullPtr0 = Constant::getNullValue(PtrTy);
+  Constant *NullPtr1 = Constant::getNullValue(Ptr1Ty);
 
   // Make sure that addrspacecast of null is not folded away.
-  EXPECT_NE(Constant::getNullValue(Int32PtrTy),
-            ConstantExpr::getAddrSpaceCast(NullInt32Ptr0, Int32Ptr1Ty));
+  EXPECT_NE(Constant::getNullValue(PtrTy),
+            ConstantExpr::getAddrSpaceCast(NullPtr0, Ptr1Ty));
 
-  EXPECT_NE(Constant::getNullValue(Int32Ptr1Ty),
-            ConstantExpr::getAddrSpaceCast(NullInt32Ptr1, Int32PtrTy));
+  EXPECT_NE(Constant::getNullValue(Ptr1Ty),
+            ConstantExpr::getAddrSpaceCast(NullPtr1, PtrTy));
 }
 
 #define CHECK(x, y)                                                            \
@@ -668,7 +662,7 @@
   EXPECT_FALSE(CF12U2->isElementWiseEqual(CF12U1));
   EXPECT_FALSE(CF12U1->isElementWiseEqual(CF12U2));
 
-  PointerType *PtrTy = Type::getInt8PtrTy(Context);
+  PointerType *PtrTy = PointerType::get(Context, 0);
   Constant *CPU = UndefValue::get(PtrTy);
   Constant *CP0 = ConstantPointerNull::get(PtrTy);
 
Index: llvm/unittests/IR/BasicBlockTest.cpp
===================================================================
--- llvm/unittests/IR/BasicBlockTest.cpp
+++ llvm/unittests/IR/BasicBlockTest.cpp
@@ -101,7 +101,7 @@
   LLVMContext Ctx;
 
   Module *M = new Module("MyModule", Ctx);
-  Type *ArgTy1[] = {Type::getInt32PtrTy(Ctx)};
+  Type *ArgTy1[] = {PointerType::getUnqual(Ctx)};
   FunctionType *FT = FunctionType::get(Type::getVoidTy(Ctx), ArgTy1, false);
   Argument *V = new Argument(Type::getInt32Ty(Ctx));
   Function *F = Function::Create(FT, Function::ExternalLinkage, "", M);
Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===================================================================
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -1126,23 +1126,22 @@
   using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
 
   Type *I32Ty = Type::getInt32Ty(M->getContext());
-  Type *I32PtrTy = Type::getInt32PtrTy(M->getContext());
-  Type *StructTy = StructType::get(I32Ty, I32PtrTy);
-  Type *StructPtrTy = StructTy->getPointerTo();
+  Type *PtrTy = PointerType::get(M->getContext(), 0);
+  Type *StructTy = StructType::get(I32Ty, PtrTy);
   Type *VoidTy = Type::getVoidTy(M->getContext());
   FunctionCallee RetI32Func = M->getOrInsertFunction("ret_i32", I32Ty);
   FunctionCallee TakeI32Func =
       M->getOrInsertFunction("take_i32", VoidTy, I32Ty);
-  FunctionCallee RetI32PtrFunc = M->getOrInsertFunction("ret_i32ptr", I32PtrTy);
+  FunctionCallee RetI32PtrFunc = M->getOrInsertFunction("ret_i32ptr", PtrTy);
   FunctionCallee TakeI32PtrFunc =
-      M->getOrInsertFunction("take_i32ptr", VoidTy, I32PtrTy);
+      M->getOrInsertFunction("take_i32ptr", VoidTy, PtrTy);
   FunctionCallee RetStructFunc = M->getOrInsertFunction("ret_struct", StructTy);
   FunctionCallee TakeStructFunc =
       M->getOrInsertFunction("take_struct", VoidTy, StructTy);
   FunctionCallee RetStructPtrFunc =
-      M->getOrInsertFunction("ret_structptr", StructPtrTy);
+      M->getOrInsertFunction("ret_structptr", PtrTy);
   FunctionCallee TakeStructPtrFunc =
-      M->getOrInsertFunction("take_structPtr", VoidTy, StructPtrTy);
+      M->getOrInsertFunction("take_structPtr", VoidTy, PtrTy);
   Value *I32Val = Builder.CreateCall(RetI32Func);
   Value *I32PtrVal = Builder.CreateCall(RetI32PtrFunc);
   Value *StructVal = Builder.CreateCall(RetStructFunc);
@@ -5125,8 +5124,8 @@
   LoadInst *Value = nullptr;
   StoreInst *TargetStore = nullptr;
   llvm::SmallVector<llvm::Value *, 2> CapturedArgs = {
-      Constant::getNullValue(Type::getInt32PtrTy(Ctx)),
-      Constant::getNullValue(Type::getInt32PtrTy(Ctx))};
+      Constant::getNullValue(PointerType::get(Ctx, 0)),
+      Constant::getNullValue(PointerType::get(Ctx, 0))};
 
   auto BodyGenCB = [&](OpenMPIRBuilder::InsertPointTy AllocaIP,
                        OpenMPIRBuilder::InsertPointTy CodeGenIP)
@@ -5756,10 +5755,10 @@
   OpenMPIRBuilder::TargetDataRTArgs RTArgs;
   OpenMPIRBuilder::TargetDataInfo Info(true, false);
 
-  auto VoidPtrTy = Type::getInt8PtrTy(Builder.getContext());
-  auto VoidPtrPtrTy = VoidPtrTy->getPointerTo(0);
+  auto VoidPtrTy = PointerType::getUnqual(Builder.getContext());
+  auto VoidPtrPtrTy = PointerType::getUnqual(Builder.getContext());
   auto Int64Ty = Type::getInt64Ty(Builder.getContext());
-  auto Int64PtrTy = Type::getInt64PtrTy(Builder.getContext());
+  auto Int64PtrTy = PointerType::getUnqual(Builder.getContext());
   auto Array4VoidPtrTy = ArrayType::get(VoidPtrTy, 4);
   auto Array4Int64PtrTy = ArrayType::get(Int64Ty, 4);
 
Index: llvm/unittests/Analysis/TBAATest.cpp
===================================================================
--- llvm/unittests/Analysis/TBAATest.cpp
+++ llvm/unittests/Analysis/TBAATest.cpp
@@ -36,7 +36,7 @@
   auto *F = Function::Create(FTy, Function::ExternalLinkage, Name, M);
   auto *BB = BasicBlock::Create(C, "entry", F);
   auto *IntType = Type::getInt32Ty(C);
-  auto *PtrType = Type::getInt32PtrTy(C);
+  auto *PtrType = PointerType::get(C, 0);
   auto *SI = new StoreInst(ConstantInt::get(IntType, 42),
                            ConstantPointerNull::get(PtrType), BB);
   ReturnInst::Create(C, nullptr, BB);
Index: llvm/unittests/Analysis/SparsePropagation.cpp
===================================================================
--- llvm/unittests/Analysis/SparsePropagation.cpp
+++ llvm/unittests/Analysis/SparsePropagation.cpp
@@ -372,7 +372,7 @@
 TEST_F(SparsePropagationTest, FunctionDefined) {
   Function *F =
       Function::Create(FunctionType::get(Builder.getInt64Ty(),
-                                         {Type::getInt1PtrTy(Context)}, false),
+                                         {PointerType::get(Context, 0)}, false),
                        GlobalValue::InternalLinkage, "f", &M);
   BasicBlock *If = BasicBlock::Create(Context, "if", F);
   BasicBlock *Then = BasicBlock::Create(Context, "then", F);
@@ -412,7 +412,7 @@
 TEST_F(SparsePropagationTest, FunctionOverDefined) {
   Function *F =
       Function::Create(FunctionType::get(Builder.getInt64Ty(),
-                                         {Type::getInt1PtrTy(Context)}, false),
+                                         {PointerType::get(Context, 0)}, false),
                        GlobalValue::InternalLinkage, "f", &M);
   BasicBlock *If = BasicBlock::Create(Context, "if", F);
   BasicBlock *Then = BasicBlock::Create(Context, "then", F);
Index: llvm/unittests/Analysis/PhiValuesTest.cpp
===================================================================
--- llvm/unittests/Analysis/PhiValuesTest.cpp
+++ llvm/unittests/Analysis/PhiValuesTest.cpp
@@ -24,7 +24,7 @@
   Type *VoidTy = Type::getVoidTy(C);
   Type *I1Ty = Type::getInt1Ty(C);
   Type *I32Ty = Type::getInt32Ty(C);
-  Type *I32PtrTy = Type::getInt32PtrTy(C);
+  Type *PtrTy = PointerType::get(C, 0);
 
   // Create a function with phis that do not have other phis as incoming values
   Function *F = Function::Create(FunctionType::get(VoidTy, false),
@@ -38,10 +38,10 @@
   BranchInst::Create(Then, If);
   BranchInst::Create(Then, Else);
 
-  Value *Val1 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val1", Entry);
-  Value *Val2 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val2", Entry);
-  Value *Val3 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val3", Entry);
-  Value *Val4 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val4", Entry);
+  Value *Val1 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val1", Entry);
+  Value *Val2 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val2", Entry);
+  Value *Val3 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val3", Entry);
+  Value *Val4 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val4", Entry);
 
   PHINode *Phi1 = PHINode::Create(I32Ty, 2, "phi1", Then);
   Phi1->addIncoming(Val1, If);
@@ -91,7 +91,7 @@
   Type *VoidTy = Type::getVoidTy(C);
   Type *I1Ty = Type::getInt1Ty(C);
   Type *I32Ty = Type::getInt32Ty(C);
-  Type *I32PtrTy = Type::getInt32PtrTy(C);
+  Type *PtrTy = PointerType::get(C, 0);
 
   // Create a function with a phi that has another phi as an incoming value
   Function *F = Function::Create(FunctionType::get(VoidTy, false),
@@ -111,10 +111,10 @@
   BranchInst::Create(End, If2);
   BranchInst::Create(End, Else2);
 
-  Value *Val1 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val1", Entry);
-  Value *Val2 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val2", Entry);
-  Value *Val3 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val3", Entry);
-  Value *Val4 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val4", Entry);
+  Value *Val1 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val1", Entry);
+  Value *Val2 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val2", Entry);
+  Value *Val3 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val3", Entry);
+  Value *Val4 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val4", Entry);
 
   PHINode *Phi1 = PHINode::Create(I32Ty, 2, "phi1", Then);
   Phi1->addIncoming(Val1, If1);
Index: llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
===================================================================
--- llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
+++ llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
@@ -421,7 +421,7 @@
 
   std::vector<Type *> TypeArgs;
   for (int i = 0; i < (Size * 2); i++)
-    TypeArgs.push_back(Type::getInt32PtrTy(C));
+    TypeArgs.push_back(PointerType::getUnqual(C));
   FunctionType *FuncType =
       FunctionType::get(Type::getVoidTy(C), TypeArgs, false);
 
Index: llvm/unittests/Analysis/AliasAnalysisTest.cpp
===================================================================
--- llvm/unittests/Analysis/AliasAnalysisTest.cpp
+++ llvm/unittests/Analysis/AliasAnalysisTest.cpp
@@ -169,7 +169,7 @@
   auto *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
   auto *BB = BasicBlock::Create(C, "entry", F);
   auto IntType = Type::getInt32Ty(C);
-  auto PtrType = Type::getInt32PtrTy(C);
+  auto PtrType = PointerType::get(C, 0);
   auto *Value = ConstantInt::get(IntType, 42);
   auto *Addr = ConstantPointerNull::get(PtrType);
   auto Alignment = Align(IntType->getBitWidth() / 8);
Index: llvm/tools/llvm-stress/llvm-stress.cpp
===================================================================
--- llvm/tools/llvm-stress/llvm-stress.cpp
+++ llvm/tools/llvm-stress/llvm-stress.cpp
@@ -132,9 +132,9 @@
   // Define a few arguments
   LLVMContext &Context = M->getContext();
   Type* ArgsTy[] = {
-    Type::getInt8PtrTy(Context),
-    Type::getInt32PtrTy(Context),
-    Type::getInt64PtrTy(Context),
+    PointerType::get(Context, 0),
+    PointerType::get(Context, 0),
+    PointerType::get(Context, 0),
     Type::getInt32Ty(Context),
     Type::getInt64Ty(Context),
     Type::getInt8Ty(Context)
Index: llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
===================================================================
--- llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
+++ llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
@@ -35,7 +35,7 @@
     Triple TargetTriple(M.getTargetTriple());
     if (TargetTriple.isOSAIX() && Func == "__mcount") {
       Type *SizeTy = M.getDataLayout().getIntPtrType(C);
-      Type *SizePtrTy = SizeTy->getPointerTo();
+      Type *SizePtrTy = PointerType::getUnqual(C);
       GlobalVariable *GV = new GlobalVariable(M, SizeTy, /*isConstant=*/false,
                                               GlobalValue::InternalLinkage,
                                               ConstantInt::get(SizeTy, 0));
Index: llvm/lib/Transforms/Scalar/GVN.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/GVN.cpp
+++ llvm/lib/Transforms/Scalar/GVN.cpp
@@ -1998,12 +1998,12 @@
   if (ConstantInt *Cond = dyn_cast<ConstantInt>(V)) {
     if (Cond->isZero()) {
       Type *Int8Ty = Type::getInt8Ty(V->getContext());
+      Type *PtrTy = PointerType::get(V->getContext(), 0);
       // Insert a new store to null instruction before the load to indicate that
       // this code is not reachable.  FIXME: We could insert unreachable
       // instruction directly because we can modify the CFG.
       auto *NewS = new StoreInst(PoisonValue::get(Int8Ty),
-                                 Constant::getNullValue(Int8Ty->getPointerTo()),
-                                 IntrinsicI);
+                                 Constant::getNullValue(PtrTy), IntrinsicI);
       if (MSSAU) {
         const MemoryUseOrDef *FirstNonDom = nullptr;
         const auto *AL =
Index: llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
===================================================================
--- llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -933,7 +933,8 @@
     if (IsNullOrUndef(CI->getArgOperand(0))) {
       Changed = true;
       new StoreInst(ConstantInt::getTrue(CI->getContext()),
-                    PoisonValue::get(Type::getInt1PtrTy(CI->getContext())), CI);
+                    PoisonValue::get(PointerType::getUnqual(CI->getContext())),
+                    CI);
       Value *NewValue = PoisonValue::get(CI->getType());
       LLVM_DEBUG(
           dbgs() << "A null pointer-to-weak-pointer is undefined behavior."
@@ -952,7 +953,8 @@
         IsNullOrUndef(CI->getArgOperand(1))) {
       Changed = true;
       new StoreInst(ConstantInt::getTrue(CI->getContext()),
-                    PoisonValue::get(Type::getInt1PtrTy(CI->getContext())), CI);
+                    PoisonValue::get(PointerType::getUnqual(CI->getContext())),
+                    CI);
 
       Value *NewValue = PoisonValue::get(CI->getType());
       LLVM_DEBUG(
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -5202,7 +5202,7 @@
     Value *SaveAreaPtrPtr = IRB.CreateIntToPtr(
         IRB.CreateAdd(IRB.CreatePtrToInt(VAListTag, MS.IntptrTy),
                       ConstantInt::get(MS.IntptrTy, offset)),
-        Type::getInt64PtrTy(*MS.C));
+        PointerType::get(*MS.C, 0));
     return IRB.CreateLoad(Type::getInt64Ty(*MS.C), SaveAreaPtrPtr);
   }
 
@@ -5211,7 +5211,7 @@
     Value *SaveAreaPtr = IRB.CreateIntToPtr(
         IRB.CreateAdd(IRB.CreatePtrToInt(VAListTag, MS.IntptrTy),
                       ConstantInt::get(MS.IntptrTy, offset)),
-        Type::getInt32PtrTy(*MS.C));
+        PointerType::get(*MS.C, 0));
     Value *SaveArea32 = IRB.CreateLoad(IRB.getInt32Ty(), SaveAreaPtr);
     return IRB.CreateSExt(SaveArea32, MS.IntptrTy);
   }
Index: llvm/lib/Transforms/InstCombine/InstCombineInternal.h
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -398,7 +398,7 @@
   void CreateNonTerminatorUnreachable(Instruction *InsertAt) {
     auto &Ctx = InsertAt->getContext();
     auto *SI = new StoreInst(ConstantInt::getTrue(Ctx),
-                             PoisonValue::get(Type::getInt1PtrTy(Ctx)),
+                             PoisonValue::get(PointerType::getUnqual(Ctx)),
                              /*isVolatile*/ false, Align(1));
     InsertNewInstBefore(SI, *InsertAt);
   }
Index: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -624,8 +624,8 @@
     }
   }
 
-  PointerType *PtrTy =
-      ElemTy->getPointerTo(Start->getType()->getPointerAddressSpace());
+  PointerType *PtrTy = PointerType::get(
+      Base->getContext(), Start->getType()->getPointerAddressSpace());
   for (Value *Val : Explored) {
     if (Val == Base)
       continue;
Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
===================================================================
--- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -590,7 +590,7 @@
       : M(M), AARGetter(AARGetter), LookupDomTree(LookupDomTree),
         ExportSummary(ExportSummary), ImportSummary(ImportSummary),
         Int8Ty(Type::getInt8Ty(M.getContext())),
-        Int8PtrTy(Type::getInt8PtrTy(M.getContext())),
+        Int8PtrTy(PointerType::getUnqual(M.getContext())),
         Int32Ty(Type::getInt32Ty(M.getContext())),
         Int64Ty(Type::getInt64Ty(M.getContext())),
         IntPtrTy(M.getDataLayout().getIntPtrType(M.getContext(), 0)),
Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===================================================================
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -4381,7 +4381,7 @@
 
     // Create local storage for the work function pointer.
     const DataLayout &DL = M.getDataLayout();
-    Type *VoidPtrTy = Type::getInt8PtrTy(Ctx);
+    Type *VoidPtrTy = PointerType::getUnqual(Ctx);
     Instruction *WorkFnAI =
         new AllocaInst(VoidPtrTy, DL.getAllocaAddrSpace(), nullptr,
                        "worker.work_fn.addr", &Kernel->getEntryBlock().front());
Index: llvm/lib/Transforms/IPO/LowerTypeTests.cpp
===================================================================
--- llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -417,10 +417,10 @@
 
   IntegerType *Int1Ty = Type::getInt1Ty(M.getContext());
   IntegerType *Int8Ty = Type::getInt8Ty(M.getContext());
-  PointerType *Int8PtrTy = Type::getInt8PtrTy(M.getContext());
+  PointerType *Int8PtrTy = PointerType::getUnqual(M.getContext());
   ArrayType *Int8Arr0Ty = ArrayType::get(Type::getInt8Ty(M.getContext()), 0);
   IntegerType *Int32Ty = Type::getInt32Ty(M.getContext());
-  PointerType *Int32PtrTy = PointerType::getUnqual(Int32Ty);
+  PointerType *Int32PtrTy = PointerType::getUnqual(M.getContext());
   IntegerType *Int64Ty = Type::getInt64Ty(M.getContext());
   IntegerType *IntPtrTy = M.getDataLayout().getIntPtrType(M.getContext(), 0);
 
Index: llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
===================================================================
--- llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
+++ llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
@@ -85,7 +85,7 @@
   LLVMContext &Ctx = M.getContext();
   FunctionCallee C = M.getOrInsertFunction(
       "__cfi_check", Type::getVoidTy(Ctx), Type::getInt64Ty(Ctx),
-      Type::getInt8PtrTy(Ctx), Type::getInt8PtrTy(Ctx));
+      PointerType::getUnqual(Ctx), PointerType::getUnqual(Ctx));
   Function *F = cast<Function>(C.getCallee());
   // Take over the existing function. The frontend emits a weak stub so that the
   // linker knows about the symbol; this pass replaces the function body.
@@ -110,9 +110,9 @@
 
   BasicBlock *TrapBB = BasicBlock::Create(Ctx, "fail", F);
   IRBuilder<> IRBFail(TrapBB);
-  FunctionCallee CFICheckFailFn =
-      M.getOrInsertFunction("__cfi_check_fail", Type::getVoidTy(Ctx),
-                            Type::getInt8PtrTy(Ctx), Type::getInt8PtrTy(Ctx));
+  FunctionCallee CFICheckFailFn = M.getOrInsertFunction(
+      "__cfi_check_fail", Type::getVoidTy(Ctx), PointerType::getUnqual(Ctx),
+      PointerType::getUnqual(Ctx));
   IRBFail.CreateCall(CFICheckFailFn, {&CFICheckFailData, &Addr});
   IRBFail.CreateBr(ExitBB);
 
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18585,11 +18585,9 @@
     // Get the Thread Pointer, which is %fs:__tls_array (32-bit) or
     // %gs:0x58 (64-bit). On MinGW, __tls_array is not available, so directly
     // use its literal value of 0x2C.
-    Value *Ptr = Constant::getNullValue(Subtarget.is64Bit()
-                                        ? Type::getInt8PtrTy(*DAG.getContext(),
-                                                             256)
-                                        : Type::getInt32PtrTy(*DAG.getContext(),
-                                                              257));
+    Value *Ptr = Constant::getNullValue(
+        Subtarget.is64Bit() ? PointerType::get(*DAG.getContext(), 256)
+                            : PointerType::get(*DAG.getContext(), 257));
 
     SDValue TlsArray = Subtarget.is64Bit()
                            ? DAG.getIntPtrConstant(0x58, dl)
Index: llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -471,10 +471,10 @@
 }
 
 // Returns an integer pointer type for the target architecture's address space.
-// i32* for wasm32 and i64* for wasm64.
+// i32* for wasm32 and i64* for wasm64. With opaque pointers this is just a ptr
+// in address space zero.
 static Type *getAddrPtrType(Module *M) {
-  return Type::getIntNPtrTy(M->getContext(),
-                            M->getDataLayout().getPointerSizeInBits());
+  return PointerType::getUnqual(M->getContext());
 }
 
 // Returns an integer whose type is the integer type for the target's address
@@ -495,7 +495,7 @@
                                                        unsigned NumClauses) {
   if (FindMatchingCatches.count(NumClauses))
     return FindMatchingCatches[NumClauses];
-  PointerType *Int8PtrTy = Type::getInt8PtrTy(M.getContext());
+  PointerType *Int8PtrTy = PointerType::getUnqual(M.getContext());
   SmallVector<Type *, 16> Args(NumClauses, Int8PtrTy);
   FunctionType *FTy = FunctionType::get(Int8PtrTy, Args, false);
   Function *F = getEmscriptenFunction(
@@ -831,8 +831,7 @@
         Env =
             IRB.CreatePtrToInt(CI->getArgOperand(0), getAddrIntType(M), "env");
       else // WasmLongjmpF
-        Env =
-            IRB.CreateBitCast(CI->getArgOperand(0), IRB.getInt8PtrTy(), "env");
+        Env = IRB.CreateBitCast(CI->getArgOperand(0), IRB.getPtrTy(), "env");
       IRB.CreateCall(NewF, {Env, CI->getArgOperand(1)});
       ToErase.push_back(CI);
     }
@@ -945,13 +944,13 @@
   if (EnableEmEH) {
     // Register __resumeException function
     FunctionType *ResumeFTy =
-        FunctionType::get(IRB.getVoidTy(), IRB.getInt8PtrTy(), false);
+        FunctionType::get(IRB.getVoidTy(), IRB.getPtrTy(), false);
     ResumeF = getEmscriptenFunction(ResumeFTy, "__resumeException", &M);
     ResumeF->addFnAttr(Attribute::NoReturn);
 
     // Register llvm_eh_typeid_for function
     FunctionType *EHTypeIDTy =
-        FunctionType::get(IRB.getInt32Ty(), IRB.getInt8PtrTy(), false);
+        FunctionType::get(IRB.getInt32Ty(), IRB.getPtrTy(), false);
     EHTypeIDF = getEmscriptenFunction(EHTypeIDTy, "llvm_eh_typeid_for", &M);
   }
 
@@ -995,36 +994,36 @@
       EmLongjmpF = getEmscriptenFunction(FTy, "emscripten_longjmp", &M);
       EmLongjmpF->addFnAttr(Attribute::NoReturn);
     } else { // EnableWasmSjLj
+      Type *Int8PtrTy = IRB.getPtrTy();
       // Register __wasm_longjmp function, which calls __builtin_wasm_longjmp.
       FunctionType *FTy = FunctionType::get(
-          IRB.getVoidTy(), {IRB.getInt8PtrTy(), IRB.getInt32Ty()}, false);
+          IRB.getVoidTy(), {Int8PtrTy, IRB.getInt32Ty()}, false);
       WasmLongjmpF = getEmscriptenFunction(FTy, "__wasm_longjmp", &M);
       WasmLongjmpF->addFnAttr(Attribute::NoReturn);
     }
 
     if (SetjmpF) {
+      Type *Int8PtrTy = IRB.getPtrTy();
+      Type *Int32PtrTy = IRB.getPtrTy();
+      Type *Int32Ty = IRB.getInt32Ty();
       // Register saveSetjmp function
       FunctionType *SetjmpFTy = SetjmpF->getFunctionType();
-      FunctionType *FTy =
-          FunctionType::get(Type::getInt32PtrTy(C),
-                            {SetjmpFTy->getParamType(0), IRB.getInt32Ty(),
-                             Type::getInt32PtrTy(C), IRB.getInt32Ty()},
-                            false);
+      FunctionType *FTy = FunctionType::get(
+          Int32PtrTy,
+          {SetjmpFTy->getParamType(0), Int32Ty, Int32PtrTy, Int32Ty}, false);
       SaveSetjmpF = getEmscriptenFunction(FTy, "saveSetjmp", &M);
 
       // Register testSetjmp function
-      FTy = FunctionType::get(
-          IRB.getInt32Ty(),
-          {getAddrIntType(&M), Type::getInt32PtrTy(C), IRB.getInt32Ty()},
-          false);
+      FTy = FunctionType::get(Int32Ty,
+                              {getAddrIntType(&M), Int32PtrTy, Int32Ty}, false);
       TestSetjmpF = getEmscriptenFunction(FTy, "testSetjmp", &M);
 
       // wasm.catch() will be lowered down to wasm 'catch' instruction in
       // instruction selection.
       CatchF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_catch);
       // Type for struct __WasmLongjmpArgs
-      LongjmpArgsTy = StructType::get(IRB.getInt8PtrTy(), // env
-                                      IRB.getInt32Ty()    // val
+      LongjmpArgsTy = StructType::get(Int8PtrTy, // env
+                                      Int32Ty    // val
       );
     }
   }
@@ -1426,7 +1425,7 @@
   // saveSetjmp and testSetjmp calls have the correct arguments.
   SSAUpdater SetjmpTableSSA;
   SSAUpdater SetjmpTableSizeSSA;
-  SetjmpTableSSA.Initialize(Type::getInt32PtrTy(C), "setjmpTable");
+  SetjmpTableSSA.Initialize(PointerType::get(C, 0), "setjmpTable");
   SetjmpTableSizeSSA.Initialize(Type::getInt32Ty(C), "setjmpTableSize");
   for (Instruction *I : SetjmpTableInsts)
     SetjmpTableSSA.AddAvailableValue(I->getParent(), I);
@@ -1680,7 +1679,7 @@
         FunctionType::get(IRB.getInt32Ty(), /* isVarArg */ true);
     Value *PersF = M.getOrInsertFunction(PersName, PersType).getCallee();
     F.setPersonalityFn(
-        cast<Constant>(IRB.CreateBitCast(PersF, IRB.getInt8PtrTy())));
+        cast<Constant>(IRB.CreateBitCast(PersF, IRB.getPtrTy())));
   }
 
   // Use the entry BB's debugloc as a fallback
@@ -1733,7 +1732,7 @@
   Value *ValField =
       IRB.CreateConstGEP2_32(LongjmpArgsTy, LongjmpArgs, 0, 1, "val_gep");
   // void *env = __wasm_longjmp_args.env;
-  Instruction *Env = IRB.CreateLoad(IRB.getInt8PtrTy(), EnvField, "env");
+  Instruction *Env = IRB.CreateLoad(IRB.getPtrTy(), EnvField, "env");
   // int val = __wasm_longjmp_args.val;
   Instruction *Val = IRB.CreateLoad(IRB.getInt32Ty(), ValField, "val");
 
Index: llvm/lib/Target/ARM/ARMFastISel.cpp
===================================================================
--- llvm/lib/Target/ARM/ARMFastISel.cpp
+++ llvm/lib/Target/ARM/ARMFastISel.cpp
@@ -2180,7 +2180,7 @@
 
 unsigned ARMFastISel::getLibcallReg(const Twine &Name) {
   // Manually compute the global's type to avoid building it when unnecessary.
-  Type *GVTy = Type::getInt32PtrTy(*Context, /*AS=*/0);
+  Type *GVTy = PointerType::get(*Context, /*AS=*/0);
   EVT LCREVT = TLI.getValueType(DL, GVTy);
   if (!LCREVT.isSimple()) return 0;
 
@@ -2964,7 +2964,7 @@
       /*AddCurrentAddress=*/UseGOT_PREL);
 
   Align ConstAlign =
-      MF->getDataLayout().getPrefTypeAlign(Type::getInt32PtrTy(*Context));
+      MF->getDataLayout().getPrefTypeAlign(PointerType::get(*Context, 0));
   unsigned Idx = MF->getConstantPool()->getConstantPoolIndex(CPV, ConstAlign);
   MachineMemOperand *CPMMO =
       MF->getMachineMemOperand(MachinePointerInfo::getConstantPool(*MF),
Index: llvm/lib/Linker/IRMover.cpp
===================================================================
--- llvm/lib/Linker/IRMover.cpp
+++ llvm/lib/Linker/IRMover.cpp
@@ -937,7 +937,7 @@
       IsOldStructor = true;
   }
 
-  PointerType *VoidPtrTy = Type::getInt8Ty(SrcGV->getContext())->getPointerTo();
+  PointerType *VoidPtrTy = PointerType::get(SrcGV->getContext(), 0);
   if (IsOldStructor) {
     auto &ST = *cast<StructType>(EltTy);
     Type *Tys[3] = {ST.getElementType(0), ST.getElementType(1), VoidPtrTy};
Index: llvm/lib/IR/Function.cpp
===================================================================
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -1878,7 +1878,7 @@
   setNumHungOffUseOperands(3);
 
   // Initialize the uselist with placeholder operands to allow traversal.
-  auto *CPN = ConstantPointerNull::get(Type::getInt1PtrTy(getContext(), 0));
+  auto *CPN = ConstantPointerNull::get(PointerType::get(getContext(), 0));
   Op<0>().set(CPN);
   Op<1>().set(CPN);
   Op<2>().set(CPN);
@@ -1890,8 +1890,7 @@
     allocHungoffUselist();
     Op<Idx>().set(C);
   } else if (getNumOperands()) {
-    Op<Idx>().set(
-        ConstantPointerNull::get(Type::getInt1PtrTy(getContext(), 0)));
+    Op<Idx>().set(ConstantPointerNull::get(PointerType::get(getContext(), 0)));
   }
 }
 
Index: llvm/include/llvm/IR/IRBuilder.h
===================================================================
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -558,7 +558,7 @@
 
   /// Fetch the type representing a pointer to an 8-bit integer value.
   PointerType *getInt8PtrTy(unsigned AddrSpace = 0) {
-    return Type::getInt8PtrTy(Context, AddrSpace);
+    return getPtrTy(AddrSpace);
   }
 
   /// Fetch the type of an integer with size at least as big as that of a
Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===================================================================
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -26,6 +26,7 @@
 #endif
 
 #define __OMP_TYPE(VarName) OMP_TYPE(VarName, Type::get##VarName##Ty(Ctx))
+#define __OMP_PTR_TYPE(VarName) OMP_TYPE(VarName, PointerType::get(Ctx, 0))
 
 __OMP_TYPE(Void)
 __OMP_TYPE(Int1)
@@ -33,23 +34,21 @@
 __OMP_TYPE(Int16)
 __OMP_TYPE(Int32)
 __OMP_TYPE(Int64)
-__OMP_TYPE(Int8Ptr)
-__OMP_TYPE(Int16Ptr)
-__OMP_TYPE(Int32Ptr)
-__OMP_TYPE(Int64Ptr)
+__OMP_PTR_TYPE(Int8Ptr)
+__OMP_PTR_TYPE(Int16Ptr)
+__OMP_PTR_TYPE(Int32Ptr)
+__OMP_PTR_TYPE(Int64Ptr)
 __OMP_TYPE(Double)
 
 OMP_TYPE(SizeTy, M.getDataLayout().getIntPtrType(Ctx))
 OMP_TYPE(Int63, Type::getIntNTy(Ctx, 63))
 
-#define __OMP_PTR_TYPE(NAME, BASE) OMP_TYPE(NAME, BASE->getPointerTo())
+__OMP_PTR_TYPE(VoidPtr)
+__OMP_PTR_TYPE(VoidPtrPtr)
+__OMP_PTR_TYPE(VoidPtrPtrPtr)
 
-__OMP_PTR_TYPE(VoidPtr, Int8)
-__OMP_PTR_TYPE(VoidPtrPtr, VoidPtr)
-__OMP_PTR_TYPE(VoidPtrPtrPtr, VoidPtrPtr)
-
-__OMP_PTR_TYPE(Int8PtrPtr, Int8Ptr)
-__OMP_PTR_TYPE(Int8PtrPtrPtr, Int8PtrPtr)
+__OMP_PTR_TYPE(Int8PtrPtr)
+__OMP_PTR_TYPE(Int8PtrPtrPtr)
 
 #undef __OMP_PTR_TYPE
 
Index: clang/unittests/CodeGen/TBAAMetadataTest.cpp
===================================================================
--- clang/unittests/CodeGen/TBAAMetadataTest.cpp
+++ clang/unittests/CodeGen/TBAAMetadataTest.cpp
@@ -112,27 +112,19 @@
   ASSERT_TRUE(I);
 
   I = matchNext(I,
-      MInstruction(Instruction::Store,
-        MValType(Type::getInt8PtrTy(Compiler.Context)),
-        MMTuple(
-          MMTuple(
-            MMString("any pointer"),
-            OmnipotentCharC,
-            MConstInt(0)),
-          MSameAs(0),
-          MConstInt(0))));
+                MInstruction(Instruction::Store,
+                             MValType(PointerType::getUnqual(Compiler.Context)),
+                             MMTuple(MMTuple(MMString("any pointer"),
+                                             OmnipotentCharC, MConstInt(0)),
+                                     MSameAs(0), MConstInt(0))));
   ASSERT_TRUE(I);
 
   I = matchNext(I,
-      MInstruction(Instruction::Store,
-        MValType(Type::getInt32PtrTy(Compiler.Context)),
-        MMTuple(
-          MMTuple(
-            MMString("any pointer"),
-            OmnipotentCharC,
-            MConstInt(0)),
-          MSameAs(0),
-          MConstInt(0))));
+                MInstruction(Instruction::Store,
+                             MValType(PointerType::getUnqual(Compiler.Context)),
+                             MMTuple(MMTuple(MMString("any pointer"),
+                                             OmnipotentCharC, MConstInt(0)),
+                                     MSameAs(0), MConstInt(0))));
   ASSERT_TRUE(I);
 }
 
Index: clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
===================================================================
--- clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
+++ clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
@@ -368,12 +368,13 @@
 Function *createRegisterGlobalsFunction(Module &M, bool IsHIP) {
   LLVMContext &C = M.getContext();
   // Get the __cudaRegisterFunction function declaration.
+  PointerType *Int8PtrTy = PointerType::get(C, 0);
+  PointerType *Int8PtrPtrTy = PointerType::get(C, 0);
+  PointerType *Int32PtrTy = PointerType::get(C, 0);
   auto *RegFuncTy = FunctionType::get(
       Type::getInt32Ty(C),
-      {Type::getInt8PtrTy(C)->getPointerTo(), Type::getInt8PtrTy(C),
-       Type::getInt8PtrTy(C), Type::getInt8PtrTy(C), Type::getInt32Ty(C),
-       Type::getInt8PtrTy(C), Type::getInt8PtrTy(C), Type::getInt8PtrTy(C),
-       Type::getInt8PtrTy(C), Type::getInt32PtrTy(C)},
+      {Int8PtrPtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy, Type::getInt32Ty(C),
+       Int8PtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy, Int32PtrTy},
       /*isVarArg*/ false);
   FunctionCallee RegFunc = M.getOrInsertFunction(
       IsHIP ? "__hipRegisterFunction" : "__cudaRegisterFunction", RegFuncTy);
@@ -381,8 +382,7 @@
   // Get the __cudaRegisterVar function declaration.
   auto *RegVarTy = FunctionType::get(
       Type::getVoidTy(C),
-      {Type::getInt8PtrTy(C)->getPointerTo(), Type::getInt8PtrTy(C),
-       Type::getInt8PtrTy(C), Type::getInt8PtrTy(C), Type::getInt32Ty(C),
+      {Int8PtrPtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy, Type::getInt32Ty(C),
        getSizeTTy(M), Type::getInt32Ty(C), Type::getInt32Ty(C)},
       /*isVarArg*/ false);
   FunctionCallee RegVar = M.getOrInsertFunction(
@@ -404,8 +404,7 @@
                                : "__stop_cuda_offloading_entries");
   EntriesE->setVisibility(GlobalValue::HiddenVisibility);
 
-  auto *RegGlobalsTy = FunctionType::get(Type::getVoidTy(C),
-                                         Type::getInt8PtrTy(C)->getPointerTo(),
+  auto *RegGlobalsTy = FunctionType::get(Type::getVoidTy(C), Int8PtrPtrTy,
                                          /*isVarArg*/ false);
   auto *RegGlobalsFn =
       Function::Create(RegGlobalsTy, GlobalValue::InternalLinkage,
@@ -432,12 +431,12 @@
       Builder.CreateInBoundsGEP(getEntryTy(M), Entry,
                                 {ConstantInt::get(getSizeTTy(M), 0),
                                  ConstantInt::get(Type::getInt32Ty(C), 0)});
-  auto *Addr = Builder.CreateLoad(Type::getInt8PtrTy(C), AddrPtr, "addr");
+  auto *Addr = Builder.CreateLoad(Int8PtrTy, AddrPtr, "addr");
   auto *NamePtr =
       Builder.CreateInBoundsGEP(getEntryTy(M), Entry,
                                 {ConstantInt::get(getSizeTTy(M), 0),
                                  ConstantInt::get(Type::getInt32Ty(C), 1)});
-  auto *Name = Builder.CreateLoad(Type::getInt8PtrTy(C), NamePtr, "name");
+  auto *Name = Builder.CreateLoad(Int8PtrTy, NamePtr, "name");
   auto *SizePtr =
       Builder.CreateInBoundsGEP(getEntryTy(M), Entry,
                                 {ConstantInt::get(getSizeTTy(M), 0),
@@ -454,14 +453,13 @@
 
   // Create kernel registration code.
   Builder.SetInsertPoint(IfThenBB);
-  Builder.CreateCall(RegFunc,
-                     {RegGlobalsFn->arg_begin(), Addr, Name, Name,
-                      ConstantInt::get(Type::getInt32Ty(C), -1),
-                      ConstantPointerNull::get(Type::getInt8PtrTy(C)),
-                      ConstantPointerNull::get(Type::getInt8PtrTy(C)),
-                      ConstantPointerNull::get(Type::getInt8PtrTy(C)),
-                      ConstantPointerNull::get(Type::getInt8PtrTy(C)),
-                      ConstantPointerNull::get(Type::getInt32PtrTy(C))});
+  Builder.CreateCall(RegFunc, {RegGlobalsFn->arg_begin(), Addr, Name, Name,
+                               ConstantInt::get(Type::getInt32Ty(C), -1),
+                               ConstantPointerNull::get(Int8PtrTy),
+                               ConstantPointerNull::get(Int8PtrTy),
+                               ConstantPointerNull::get(Int8PtrTy),
+                               ConstantPointerNull::get(Int8PtrTy),
+                               ConstantPointerNull::get(Int32PtrTy)});
   Builder.CreateBr(IfEndBB);
   Builder.SetInsertPoint(IfElseBB);
 
Index: clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
===================================================================
--- clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -662,8 +662,9 @@
         llvm::FunctionType::get(getIntNType(32), /*isVarArg=*/true)->
             getPointerTo()->getPointerTo()));
   if (Layout.hasOwnVBPtr())
-    Members.push_back(MemberInfo(Layout.getVBPtrOffset(), MemberInfo::VBPtr,
-        llvm::Type::getInt32PtrTy(Types.getLLVMContext())));
+    Members.push_back(
+        MemberInfo(Layout.getVBPtrOffset(), MemberInfo::VBPtr,
+                   llvm::PointerType::getUnqual(Types.getLLVMContext())));
 }
 
 void CGRecordLowering::accumulateVBases() {
Index: clang/lib/CodeGen/CGObjCGNU.cpp
===================================================================
--- clang/lib/CodeGen/CGObjCGNU.cpp
+++ clang/lib/CodeGen/CGObjCGNU.cpp
@@ -4123,9 +4123,9 @@
   // when linked against code which isn't (most of the time).
   llvm::GlobalVariable *IvarOffsetPointer = TheModule.getNamedGlobal(Name);
   if (!IvarOffsetPointer)
-    IvarOffsetPointer = new llvm::GlobalVariable(TheModule,
-            llvm::Type::getInt32PtrTy(VMContext), false,
-            llvm::GlobalValue::ExternalLinkage, nullptr, Name);
+    IvarOffsetPointer = new llvm::GlobalVariable(
+        TheModule, llvm::PointerType::getUnqual(VMContext), false,
+        llvm::GlobalValue::ExternalLinkage, nullptr, Name);
   return IvarOffsetPointer;
 }
 
@@ -4169,10 +4169,11 @@
         CGF.CGM.getTarget().getTriple().isKnownWindowsMSVCEnvironment())
       return CGF.Builder.CreateZExtOrBitCast(
           CGF.Builder.CreateAlignedLoad(
-              Int32Ty, CGF.Builder.CreateAlignedLoad(
-                           llvm::Type::getInt32PtrTy(VMContext),
-                           ObjCIvarOffsetVariable(Interface, Ivar),
-                           CGF.getPointerAlign(), "ivar"),
+              Int32Ty,
+              CGF.Builder.CreateAlignedLoad(
+                  llvm::PointerType::getUnqual(VMContext),
+                  ObjCIvarOffsetVariable(Interface, Ivar),
+                  CGF.getPointerAlign(), "ivar"),
               CharUnits::fromQuantity(4)),
           PtrDiffTy);
     std::string name = "__objc_ivar_offset_value_" +
Index: clang/lib/CodeGen/CGBuiltin.cpp
===================================================================
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -10739,7 +10739,7 @@
                                      CharUnits::fromQuantity(16));
   }
   case NEON::BI__builtin_neon_vstrq_p128: {
-    llvm::Type *Int128PTy = llvm::Type::getIntNPtrTy(getLLVMContext(), 128);
+    llvm::Type *Int128PTy = llvm::PointerType::getUnqual(getLLVMContext());
     Value *Ptr = Builder.CreateBitCast(Ops[0], Int128PTy);
     return Builder.CreateDefaultAlignedStore(EmitScalarExpr(E->getArg(1)), Ptr);
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to