mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-11-04 05:17:07 +00:00 
			
		
		
		
	[opaque pointer type] Avoid creating (and then unwrapping) a pointer type to compute the result type of a GEP
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235234 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		@@ -924,11 +924,13 @@ public:
 | 
				
			|||||||
  /// GetGEPReturnType - Returns the pointer type returned by the GEP
 | 
					  /// GetGEPReturnType - Returns the pointer type returned by the GEP
 | 
				
			||||||
  /// instruction, which may be a vector of pointers.
 | 
					  /// instruction, which may be a vector of pointers.
 | 
				
			||||||
  static Type *getGEPReturnType(Value *Ptr, ArrayRef<Value *> IdxList) {
 | 
					  static Type *getGEPReturnType(Value *Ptr, ArrayRef<Value *> IdxList) {
 | 
				
			||||||
    Type *PtrTy =
 | 
					    return getGEPReturnType(
 | 
				
			||||||
        PointerType::get(checkGEPType(getIndexedType(
 | 
					        cast<PointerType>(Ptr->getType()->getScalarType())->getElementType(),
 | 
				
			||||||
                             cast<PointerType>(Ptr->getType()->getScalarType())
 | 
					        Ptr, IdxList);
 | 
				
			||||||
                                 ->getElementType(),
 | 
					  }
 | 
				
			||||||
                             IdxList)),
 | 
					  static Type *getGEPReturnType(Type *ElTy, Value *Ptr,
 | 
				
			||||||
 | 
					                                ArrayRef<Value *> IdxList) {
 | 
				
			||||||
 | 
					    Type *PtrTy = PointerType::get(checkGEPType(getIndexedType(ElTy, IdxList)),
 | 
				
			||||||
                                   Ptr->getType()->getPointerAddressSpace());
 | 
					                                   Ptr->getType()->getPointerAddressSpace());
 | 
				
			||||||
    // Vector GEP
 | 
					    // Vector GEP
 | 
				
			||||||
    if (Ptr->getType()->isVectorTy()) {
 | 
					    if (Ptr->getType()->isVectorTy()) {
 | 
				
			||||||
@@ -993,7 +995,9 @@ GetElementPtrInst::GetElementPtrInst(Type *PointeeType, Value *Ptr,
 | 
				
			|||||||
                                     ArrayRef<Value *> IdxList, unsigned Values,
 | 
					                                     ArrayRef<Value *> IdxList, unsigned Values,
 | 
				
			||||||
                                     const Twine &NameStr,
 | 
					                                     const Twine &NameStr,
 | 
				
			||||||
                                     Instruction *InsertBefore)
 | 
					                                     Instruction *InsertBefore)
 | 
				
			||||||
    : Instruction(getGEPReturnType(Ptr, IdxList), GetElementPtr,
 | 
					    : Instruction(PointeeType ? getGEPReturnType(PointeeType, Ptr, IdxList)
 | 
				
			||||||
 | 
					                              : getGEPReturnType(Ptr, IdxList),
 | 
				
			||||||
 | 
					                  GetElementPtr,
 | 
				
			||||||
                  OperandTraits<GetElementPtrInst>::op_end(this) - Values,
 | 
					                  OperandTraits<GetElementPtrInst>::op_end(this) - Values,
 | 
				
			||||||
                  Values, InsertBefore) {
 | 
					                  Values, InsertBefore) {
 | 
				
			||||||
  init(Ptr, IdxList, NameStr);
 | 
					  init(Ptr, IdxList, NameStr);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user