]> granicus.if.org Git - clang/commitdiff
Simplify pointer creation with the new Type::getInt*Ptr methods.
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 13 Oct 2009 10:07:13 +0000 (10:07 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 13 Oct 2009 10:07:13 +0000 (10:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83964 91177308-0d34-0410-b5e6-96231b3b80d8

13 files changed:
lib/CodeGen/CGBlocks.cpp
lib/CodeGen/CGBlocks.h
lib/CodeGen/CGBuiltin.cpp
lib/CodeGen/CGCXXClass.cpp
lib/CodeGen/CGDecl.cpp
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CGExprConstant.cpp
lib/CodeGen/CGExprScalar.cpp
lib/CodeGen/CGObjCGNU.cpp
lib/CodeGen/CGObjCMac.cpp
lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/TargetABIInfo.cpp

index 79950e8c6beb44cc6b76f9b426a234b5565f0eb2..736425e01276c95dc356f21db2f0af21c40178c5 100644 (file)
@@ -414,8 +414,7 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
 
   BlockLiteral =
     Builder.CreateBitCast(BlockLiteral,
-                          llvm::PointerType::getUnqual(
-                              llvm::Type::getInt8Ty(VMContext)),
+                          llvm::Type::getInt8PtrTy(VMContext),
                           "tmp");
 
   // Add the block literal.
index 8557d1f83bff97704bc6a635c08b427aef8b4766..3a860c0d3c3693cc1267219438993e30bb643c1b 100644 (file)
@@ -112,8 +112,7 @@ public:
       GenericBlockLiteralType(0), GenericExtendedBlockLiteralType(0),
       BlockObjectAssign(0), BlockObjectDispose(0) {
     Block.GlobalUniqueCount = 0;
-    PtrToInt8Ty = llvm::PointerType::getUnqual(
-                llvm::Type::getInt8Ty(M.getContext()));
+    PtrToInt8Ty = llvm::Type::getInt8PtrTy(M.getContext());
   }
 
   bool BlockRequiresCopying(QualType Ty) {
index ffc8ea7daafa50402e977a31de5c0ef12d3ea69d..987cd24e2c8b5fc8580e0f515e0c5b6c3c58c1bc 100644 (file)
@@ -77,8 +77,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
   case Builtin::BI__builtin_va_start:
   case Builtin::BI__builtin_va_end: {
     Value *ArgValue = EmitVAListRef(E->getArg(0));
-    const llvm::Type *DestType =
-      llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+    const llvm::Type *DestType = llvm::Type::getInt8PtrTy(VMContext);
     if (ArgValue->getType() != DestType)
       ArgValue = Builder.CreateBitCast(ArgValue, DestType,
                                        ArgValue->getName().data());
@@ -91,8 +90,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
     Value *DstPtr = EmitVAListRef(E->getArg(0));
     Value *SrcPtr = EmitVAListRef(E->getArg(1));
 
-    const llvm::Type *Type =
-      llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+    const llvm::Type *Type = llvm::Type::getInt8PtrTy(VMContext);
 
     DstPtr = Builder.CreateBitCast(DstPtr, Type);
     SrcPtr = Builder.CreateBitCast(SrcPtr, Type);
@@ -349,16 +347,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
     Builder.CreateStore(FrameAddr, Buf);
     // Call the setjmp intrinsic
     Value *F = CGM.getIntrinsic(Intrinsic::eh_sjlj_setjmp, 0, 0);
-    const llvm::Type *DestType =
-      llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+    const llvm::Type *DestType = llvm::Type::getInt8PtrTy(VMContext);
     Buf = Builder.CreateBitCast(Buf, DestType);
     return RValue::get(Builder.CreateCall(F, Buf));
   }
   case Builtin::BI__builtin_longjmp: {
     Value *F = CGM.getIntrinsic(Intrinsic::eh_sjlj_longjmp, 0, 0);
     Value *Buf = EmitScalarExpr(E->getArg(0));
-    const llvm::Type *DestType =
-      llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+    const llvm::Type *DestType = llvm::Type::getInt8PtrTy(VMContext);
     Buf = Builder.CreateBitCast(Buf, DestType);
     return RValue::get(Builder.CreateCall(F, Buf));
   }
@@ -760,7 +756,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
     return Builder.CreateCall(F, &Ops[0], &Ops[0] + Ops.size(), "cmpss");
   }
   case X86::BI__builtin_ia32_ldmxcsr: {
-    llvm::Type *PtrTy = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+    const llvm::Type *PtrTy = llvm::Type::getInt8PtrTy(VMContext);
     Value *One = llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 1);
     Value *Tmp = Builder.CreateAlloca(llvm::Type::getInt32Ty(VMContext), One, "tmp");
     Builder.CreateStore(Ops[0], Tmp);
@@ -768,7 +764,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
                               Builder.CreateBitCast(Tmp, PtrTy));
   }
   case X86::BI__builtin_ia32_stmxcsr: {
-    llvm::Type *PtrTy = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+    const llvm::Type *PtrTy = llvm::Type::getInt8PtrTy(VMContext);
     Value *One = llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 1);
     Value *Tmp = Builder.CreateAlloca(llvm::Type::getInt32Ty(VMContext), One, "tmp");
     One = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_stmxcsr),
index ff879f5786ffc7bc11f312d4f3b10f4e72a752f2..56a28fc9a007a7a2f904d7dbd8fc5c30e4ef6388 100644 (file)
@@ -144,8 +144,7 @@ CodeGenFunction::GetAddressCXXOfBaseClass(llvm::Value *BaseValue,
     EmitBlock(CastNotNull);
   }
   
-  const llvm::Type *Int8PtrTy = 
-    llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+  const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
 
   llvm::Value *Offset = 
     GetCXXBaseClassOffset(*this, BaseValue, ClassDecl, BaseClassDecl);
index 73bc0a04a0c654b237bcaf316220d0b0a9655ad8..7feff83dee6bba8a9565cb64184061cd6dd9c0ce 100644 (file)
@@ -231,8 +231,7 @@ const llvm::Type *CodeGenFunction::BuildByRefType(const ValueDecl *D) {
 
   std::vector<const llvm::Type *> Types;
   
-  const llvm::PointerType *Int8PtrTy
-    = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+  const llvm::PointerType *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
 
   llvm::PATypeHolder ByRefTypeHolder = llvm::OpaqueType::get(VMContext);
   
@@ -345,8 +344,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
 
     if (!DidCallStackSave) {
       // Save the stack.
-      const llvm::Type *LTy =
-        llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+      const llvm::Type *LTy = llvm::Type::getInt8PtrTy(VMContext);
       llvm::Value *Stack = CreateTempAlloca(LTy, "saved_stack");
 
       llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::stacksave);
@@ -433,8 +431,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
   }
 
   if (isByRef) {
-    const llvm::PointerType *PtrToInt8Ty
-      = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+    const llvm::PointerType *PtrToInt8Ty = llvm::Type::getInt8PtrTy(VMContext);
 
     EnsureInsertPoint();
     llvm::Value *isa_field = Builder.CreateStructGEP(DeclPtr, 0);
index d89da3224fc0ee5a8de5bda0b9cc3fd5fb593a4b..2834dfeb780a646c57aa781dcd7f313259f13aad 100644 (file)
@@ -969,8 +969,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) {
 
     Idx = Builder.CreateMul(Idx, InterfaceSize);
 
-    llvm::Type *i8PTy =
-            llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+    const llvm::Type *i8PTy = llvm::Type::getInt8PtrTy(VMContext);
     Address = Builder.CreateGEP(Builder.CreateBitCast(Base, i8PTy),
                                 Idx, "arrayidx");
     Address = Builder.CreateBitCast(Address, Base->getType());
index b25636ed08e0b8a872930882723e0ffffd34858b..0866ff893c4e35e2402fc8f7031d0cbba34e4f7b 100644 (file)
@@ -641,8 +641,7 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr,
   // equal, but other compilers do this optimization, and almost every memcpy
   // implementation handles this case safely.  If there is a libc that does not
   // safely handle this, we can add a target hook.
-  const llvm::Type *BP =
-                llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+  const llvm::Type *BP = llvm::Type::getInt8PtrTy(VMContext);
   if (DestPtr->getType() != BP)
     DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp");
   if (SrcPtr->getType() != BP)
index 9621e2a21c07d593fd003562adba4f05a5d181c6..119b6f31e4ae3155406be82178cc2e40f1305bc6 100644 (file)
@@ -826,8 +826,7 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
 
         // Apply offset if necessary.
         if (!Offset->isNullValue()) {
-          const llvm::Type *Type =
-            llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+          const llvm::Type *Type = llvm::Type::getInt8PtrTy(VMContext);
           llvm::Constant *Casted = llvm::ConstantExpr::getBitCast(C, Type);
           Casted = llvm::ConstantExpr::getGetElementPtr(Casted, &Offset, 1);
           C = llvm::ConstantExpr::getBitCast(Casted, C->getType());
index dcb5684032b257fe1e62b6407f54bc68d248745d..cc81256032afbc69194f7ff89bf8a96bcba80e2b 100644 (file)
@@ -789,8 +789,7 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
         if (!isInc)
           size = -size;
         Inc = llvm::ConstantInt::get(Inc->getType(), size);
-        const llvm::Type *i8Ty =
-          llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+        const llvm::Type *i8Ty = llvm::Type::getInt8PtrTy(VMContext);
         InVal = Builder.CreateBitCast(InVal, i8Ty);
         NextVal = Builder.CreateGEP(InVal, Inc, "add.ptr");
         llvm::Value *lhs = LV.getAddress();
@@ -799,8 +798,7 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
       } else
         NextVal = Builder.CreateInBoundsGEP(InVal, Inc, "ptrincdec");
     } else {
-      const llvm::Type *i8Ty =
-        llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+      const llvm::Type *i8Ty = llvm::Type::getInt8PtrTy(VMContext);
       NextVal = Builder.CreateBitCast(InVal, i8Ty, "tmp");
       NextVal = Builder.CreateGEP(NextVal, Inc, "ptrincdec");
       NextVal = Builder.CreateBitCast(NextVal, InVal->getType());
@@ -1159,8 +1157,7 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
       llvm::ConstantInt::get(Idx->getType(),
                              CGF.getContext().getTypeSize(OIT) / 8);
     Idx = Builder.CreateMul(Idx, InterfaceSize);
-    const llvm::Type *i8Ty =
-        llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+    const llvm::Type *i8Ty = llvm::Type::getInt8PtrTy(VMContext);
     Value *Casted = Builder.CreateBitCast(Ptr, i8Ty);
     Value *Res = Builder.CreateGEP(Casted, Idx, "add.ptr");
     return Builder.CreateBitCast(Res, Ptr->getType());
@@ -1170,8 +1167,7 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
   // GNU void* casts amount to no-ops since our void* type is i8*, but this is
   // future proof.
   if (ElementType->isVoidType() || ElementType->isFunctionType()) {
-    const llvm::Type *i8Ty =
-        llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+    const llvm::Type *i8Ty = llvm::Type::getInt8PtrTy(VMContext);
     Value *Casted = Builder.CreateBitCast(Ptr, i8Ty);
     Value *Res = Builder.CreateGEP(Casted, Idx, "add.ptr");
     return Builder.CreateBitCast(Res, Ptr->getType());
@@ -1225,8 +1221,7 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) {
         llvm::ConstantInt::get(Idx->getType(),
                                CGF.getContext().getTypeSize(OIT) / 8);
       Idx = Builder.CreateMul(Idx, InterfaceSize);
-      const llvm::Type *i8Ty =
-        llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+      const llvm::Type *i8Ty = llvm::Type::getInt8PtrTy(VMContext);
       Value *LHSCasted = Builder.CreateBitCast(Ops.LHS, i8Ty);
       Value *Res = Builder.CreateGEP(LHSCasted, Idx, "add.ptr");
       return Builder.CreateBitCast(Res, Ops.LHS->getType());
@@ -1236,8 +1231,7 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) {
     // extensions. The GNU void* casts amount to no-ops since our void* type is
     // i8*, but this is future proof.
     if (LHSElementType->isVoidType() || LHSElementType->isFunctionType()) {
-      const llvm::Type *i8Ty =
-        llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+      const llvm::Type *i8Ty = llvm::Type::getInt8PtrTy(VMContext);
       Value *LHSCasted = Builder.CreateBitCast(Ops.LHS, i8Ty);
       Value *Res = Builder.CreateGEP(LHSCasted, Idx, "sub.ptr");
       return Builder.CreateBitCast(Res, Ops.LHS->getType());
index a08ec472e97f3494e83125c4f7e1de4c25265d5a..c34138fbd290866662d81230e7d973d33f44088d 100644 (file)
@@ -1917,8 +1917,8 @@ llvm::GlobalVariable *CGObjCGNU::ObjCIvarOffsetVariable(
             IvarOffsetGV, Name);
     } else {
       IvarOffsetPointer = new llvm::GlobalVariable(TheModule,
-              llvm::PointerType::getUnqual(llvm::Type::getInt32Ty(VMContext)),
-              false, llvm::GlobalValue::ExternalLinkage, 0, Name);
+              llvm::Type::getInt32PtrTy(VMContext), false,
+              llvm::GlobalValue::ExternalLinkage, 0, Name);
     }
   }
   return IvarOffsetPointer;
index bc4e7f9378b3a0b7d577fa41ee80b61be5908717..af9e9b3527a3bab3cea3700b7ebf6d5b4a8bf3ee 100644 (file)
@@ -104,8 +104,7 @@ LValue CGObjCRuntime::EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF,
                                                unsigned CVRQualifiers,
                                                llvm::Value *Offset) {
   // Compute (type*) ( (char *) BaseValue + Offset)
-  llvm::Type *I8Ptr =
-      llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(CGF.getLLVMContext()));
+  const llvm::Type *I8Ptr = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
   QualType IvarTy = Ivar->getType();
   const llvm::Type *LTy = CGF.CGM.getTypes().ConvertTypeForMem(IvarTy);
   llvm::Value *V = CGF.Builder.CreateBitCast(BaseValue, I8Ptr);
@@ -556,7 +555,7 @@ public:
   /// SetJmpFn - LLVM _setjmp function.
   llvm::Constant *getSetJmpFn() {
     std::vector<const llvm::Type*> Params;
-    Params.push_back(llvm::PointerType::getUnqual(llvm::Type::getInt32Ty(VMContext)));
+    Params.push_back(llvm::Type::getInt32PtrTy(VMContext));
     return
       CGM.CreateRuntimeFunction(llvm::FunctionType::get(llvm::Type::getInt32Ty(VMContext),
                                                         Params, false),
@@ -3208,7 +3207,7 @@ llvm::Constant *CGObjCCommonMac::BuildIvarLayout(
   bool hasUnion = false;
 
   unsigned int WordsToScan, WordsToSkip;
-  const llvm::Type *PtrTy = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+  const llvm::Type *PtrTy = llvm::Type::getInt8PtrTy(VMContext);
   if (CGM.getLangOptions().getGCMode() == LangOptions::NonGC)
     return llvm::Constant::getNullValue(PtrTy);
 
@@ -3535,7 +3534,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
   IntTy = Types.ConvertType(Ctx.IntTy);
   LongTy = Types.ConvertType(Ctx.LongTy);
   LongLongTy = Types.ConvertType(Ctx.LongLongTy);
-  Int8PtrTy = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+  Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
 
   ObjectPtrTy = Types.ConvertType(Ctx.getObjCIdType());
   PtrObjectPtrTy = llvm::PointerType::getUnqual(ObjectPtrTy);
@@ -3823,7 +3822,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
 
   // Exceptions
   const llvm::Type *StackPtrTy = llvm::ArrayType::get(
-    llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext)), 4);
+    llvm::Type::getInt8PtrTy(VMContext), 4);
 
   ExceptionDataTy =
     llvm::StructType::get(VMContext, llvm::ArrayType::get(llvm::Type::getInt32Ty(VMContext),
index 1958bf4ecbd8e25d7a6e937213f5e4b0e64cec6c..f49a3de32b295200bd3f55207c0e51794ea00014 100644 (file)
@@ -411,8 +411,7 @@ void CodeGenModule::EmitLLVMUsed() {
   if (LLVMUsed.empty())
     return;
 
-  llvm::Type *i8PTy =
-      llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+  const llvm::Type *i8PTy = llvm::Type::getInt8PtrTy(VMContext);
 
   // Convert LLVMUsed to what ConstantArray needs.
   std::vector<llvm::Constant*> UsedArray;
@@ -477,8 +476,7 @@ llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV,
 
   // get [N x i8] constants for the annotation string, and the filename string
   // which are the 2nd and 3rd elements of the global annotation structure.
-  const llvm::Type *SBP =
-      llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+  const llvm::Type *SBP = llvm::Type::getInt8PtrTy(VMContext);
   llvm::Constant *anno = llvm::ConstantArray::get(VMContext,
                                                   AA->getAnnotation(), true);
   llvm::Constant *unit = llvm::ConstantArray::get(VMContext,
index 010a42182135491bf89ee1787b54cb1b74997f75..59f579f7b17e111cca068f59b932a857bccc4619 100644 (file)
@@ -384,8 +384,7 @@ ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy,
       } else if (SeltTy->isPointerType()) {
         // FIXME: It would be really nice if this could come out as the proper
         // pointer type.
-        llvm::Type *PtrTy =
-          llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+        const llvm::Type *PtrTy = llvm::Type::getInt8PtrTy(VMContext);
         return ABIArgInfo::getCoerce(PtrTy);
       } else if (SeltTy->isVectorType()) {
         // 64- and 128-bit vectors are never returned in a
@@ -455,7 +454,7 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty,
 
 llvm::Value *X86_32ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
                                       CodeGenFunction &CGF) const {
-  const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(CGF.getLLVMContext()));
+  const llvm::Type *BP = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
   const llvm::Type *BPP = llvm::PointerType::getUnqual(BP);
 
   CGBuilderTy &Builder = CGF.Builder;
@@ -1589,8 +1588,7 @@ ABIArgInfo ARMABIInfo::classifyReturnType(QualType RetTy,
 llvm::Value *ARMABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
                                       CodeGenFunction &CGF) const {
   // FIXME: Need to handle alignment
-  const llvm::Type *BP =
-      llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(CGF.getLLVMContext()));
+  const llvm::Type *BP = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
   const llvm::Type *BPP = llvm::PointerType::getUnqual(BP);
 
   CGBuilderTy &Builder = CGF.Builder;