llvm.org GIT mirror llvm / 7ed4f94
Remove a wrapper around getIntPtrType added to GVN by Hal in commit 166624 (the wrapper returns a vector of integers when passed a vector of pointers) by having getIntPtrType itself return a vector of integers in this case. Outside of this wrapper, I didn't find anywhere in the codebase that was relying on the old behaviour for vectors of pointers, so give this a whirl through the buildbots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166939 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan Sands 7 years ago
6 changed file(s) with 25 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
340340 ///
341341 unsigned getPreferredTypeAlignmentShift(Type *Ty) const;
342342
343 /// getIntPtrType - Return an integer type that is the same size or
344 /// greater to the pointer size based on the address space.
343 /// getIntPtrType - Return an integer type with size at least as big as that
344 /// of a pointer in the given address space.
345345 IntegerType *getIntPtrType(LLVMContext &C, unsigned AddressSpace) const;
346346
347 /// getIntPtrType - Return an integer type that is the same size or
348 /// greater to the pointer size based on the Type.
349 IntegerType *getIntPtrType(Type *) const;
347 /// getIntPtrType - Return an integer (vector of integer) type with size at
348 /// least as big as that of a pointer of the given pointer (vector of pointer)
349 /// type.
350 Type *getIntPtrType(Type *) const;
350351
351352 /// getIndexedOffset - return the offset from the beginning of the type for
352353 /// the specified indices. This is used to implement getelementptr.
456456 break; // Strip out annotate intrinsic
457457
458458 case Intrinsic::memcpy: {
459 IntegerType *IntPtr = TD.getIntPtrType(CI->getArgOperand(0)->getType());
459 Type *IntPtr = TD.getIntPtrType(CI->getArgOperand(0)->getType());
460460 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr,
461461 /* isSigned */ false);
462462 Value *Ops[3];
467467 break;
468468 }
469469 case Intrinsic::memmove: {
470 IntegerType *IntPtr = TD.getIntPtrType(CI->getArgOperand(0)->getType());
470 Type *IntPtr = TD.getIntPtrType(CI->getArgOperand(0)->getType());
471471 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr,
472472 /* isSigned */ false);
473473 Value *Ops[3];
478478 break;
479479 }
480480 case Intrinsic::memset: {
481 IntegerType *IntPtr = TD.getIntPtrType(CI->getArgOperand(0)->getType());
481 Type *IntPtr = TD.getIntPtrType(CI->getArgOperand(0)->getType());
482482 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr,
483483 /* isSigned */ false);
484484 Value *Ops[3];
142142 Value *Offset = SizeOffset.second;
143143 ConstantInt *SizeCI = dyn_cast(Size);
144144
145 IntegerType *IntTy = TD->getIntPtrType(Ptr->getType());
145 Type *IntTy = TD->getIntPtrType(Ptr->getType());
146146 Value *NeededSizeVal = ConstantInt::get(IntTy, NeededSize);
147147
148148 // three checks are required to ensure safety:
745745 return true;
746746 }
747747
748 /// Wrap TD.getIntPtrType, but return a vector type for vector inputs.
749 static Type *getIntPtrType(Type *Ty, const DataLayout &TD) {
750 Type *ITy = TD.getIntPtrType(Ty);
751 if (Ty->isVectorTy()) {
752 ITy = VectorType::get(ITy, Ty->getVectorNumElements());
753 }
754
755 return ITy;
756 }
757
758748 /// CoerceAvailableValueToLoadType - If we saw a store of a value to memory, and
759749 /// then a load from a must-aliased pointer of a different type, try to coerce
760750 /// the stored value. LoadedTy is the type of the load we want to replace and
783773
784774 // Convert source pointers to integers, which can be bitcast.
785775 if (StoredValTy->getScalarType()->isPointerTy()) {
786 StoredValTy = getIntPtrType(StoredValTy, TD);
776 StoredValTy = TD.getIntPtrType(StoredValTy);
787777 StoredVal = new PtrToIntInst(StoredVal, StoredValTy, "", InsertPt);
788778 }
789779
790780 Type *TypeToCastTo = LoadedTy;
791781 if (TypeToCastTo->getScalarType()->isPointerTy())
792 TypeToCastTo = getIntPtrType(StoredValTy, TD);
782 TypeToCastTo = TD.getIntPtrType(StoredValTy);
793783
794784 if (StoredValTy != TypeToCastTo)
795785 StoredVal = new BitCastInst(StoredVal, TypeToCastTo, "", InsertPt);
808798
809799 // Convert source pointers to integers, which can be manipulated.
810800 if (StoredValTy->getScalarType()->isPointerTy()) {
811 StoredValTy = getIntPtrType(StoredValTy, TD);
801 StoredValTy = TD.getIntPtrType(StoredValTy);
812802 StoredVal = new PtrToIntInst(StoredVal, StoredValTy, "", InsertPt);
813803 }
814804
10301020 // to an integer type to start with.
10311021 if (SrcVal->getType()->getScalarType()->isPointerTy())
10321022 SrcVal = Builder.CreatePtrToInt(SrcVal,
1033 getIntPtrType(SrcVal->getType(), TD));
1023 TD.getIntPtrType(SrcVal->getType()));
10341024 if (!SrcVal->getType()->isIntegerTy())
10351025 SrcVal = Builder.CreateBitCast(SrcVal, IntegerType::get(Ctx, StoreSize*8));
10361026
391391
392392 // This is some kind of pointer constant. Turn it into a pointer-sized
393393 // ConstantInt if possible.
394 IntegerType *PtrTy = TD->getIntPtrType(V->getType());
394 IntegerType *PtrTy = cast(TD->getIntPtrType(V->getType()));
395395
396396 // Null pointer means 0, see SelectionDAGBuilder::getValue(const Value*).
397397 if (isa(V))
667667 return Log2_32(Align);
668668 }
669669
670 /// getIntPtrType - Return an integer type that is the same size or
671 /// greater to the pointer size for the address space.
670 /// getIntPtrType - Return an integer type with size at least as big as that
671 /// of a pointer in the given address space.
672672 IntegerType *DataLayout::getIntPtrType(LLVMContext &C,
673673 unsigned AddressSpace) const {
674674 return IntegerType::get(C, getPointerSizeInBits(AddressSpace));
675675 }
676676
677 /// getIntPtrType - Return an integer type that is the same size or
678 /// greater to the pointer size of the specific PointerType.
679 IntegerType *DataLayout::getIntPtrType(Type *Ty) const {
677 /// getIntPtrType - Return an integer (vector of integer) type with size at
678 /// least as big as that of a pointer of the given pointer (vector of pointer)
679 /// type.
680 Type *DataLayout::getIntPtrType(Type *Ty) const {
680681 unsigned NumBits = getPointerTypeSizeInBits(Ty);
681 return IntegerType::get(Ty->getContext(), NumBits);
682 IntegerType *IntTy = IntegerType::get(Ty->getContext(), NumBits);
683 if (VectorType *VecTy = dyn_cast(Ty))
684 return VectorType::get(IntTy, VecTy->getNumElements());
685 return IntTy;
682686 }
683687
684688