@@ -98,49 +98,11 @@ using OffsetAndArgPart = std::pair<int64_t, ArgPart>;
98
98
99
99
static Value *createByteGEP (IRBuilderBase &IRB, const DataLayout &DL,
100
100
Value *Ptr , Type *ResElemTy, int64_t Offset) {
101
- // For non-opaque pointers, try to create a "nice" GEP if possible, otherwise
102
- // fall back to an i8 GEP to a specific offset.
103
- unsigned AddrSpace = Ptr ->getType ()->getPointerAddressSpace ();
104
- APInt OrigOffset (DL.getIndexTypeSizeInBits (Ptr ->getType ()), Offset);
105
- if (!Ptr ->getType ()->isOpaquePointerTy ()) {
106
- Type *OrigElemTy = Ptr ->getType ()->getNonOpaquePointerElementType ();
107
- if (OrigOffset == 0 && OrigElemTy == ResElemTy)
108
- return Ptr ;
109
-
110
- if (OrigElemTy->isSized ()) {
111
- APInt TmpOffset = OrigOffset;
112
- Type *TmpTy = OrigElemTy;
113
- SmallVector<APInt> IntIndices =
114
- DL.getGEPIndicesForOffset (TmpTy, TmpOffset);
115
- if (TmpOffset == 0 ) {
116
- // Try to add trailing zero indices to reach the right type.
117
- while (TmpTy != ResElemTy) {
118
- Type *NextTy = GetElementPtrInst::getTypeAtIndex (TmpTy, (uint64_t )0 );
119
- if (!NextTy)
120
- break ;
121
-
122
- IntIndices.push_back (APInt::getZero (
123
- isa<StructType>(TmpTy) ? 32 : OrigOffset.getBitWidth ()));
124
- TmpTy = NextTy;
125
- }
126
-
127
- SmallVector<Value *> Indices;
128
- for (const APInt &Index : IntIndices)
129
- Indices.push_back (IRB.getInt (Index));
130
-
131
- if (OrigOffset != 0 || TmpTy == ResElemTy) {
132
- Ptr = IRB.CreateGEP (OrigElemTy, Ptr , Indices);
133
- return IRB.CreateBitCast (Ptr , ResElemTy->getPointerTo (AddrSpace));
134
- }
135
- }
136
- }
137
- }
138
-
139
- if (OrigOffset != 0 ) {
140
- Ptr = IRB.CreateBitCast (Ptr , IRB.getInt8PtrTy (AddrSpace));
141
- Ptr = IRB.CreateGEP (IRB.getInt8Ty (), Ptr , IRB.getInt (OrigOffset));
101
+ if (Offset != 0 ) {
102
+ APInt APOffset (DL.getIndexTypeSizeInBits (Ptr ->getType ()), Offset);
103
+ Ptr = IRB.CreateGEP (IRB.getInt8Ty (), Ptr , IRB.getInt (APOffset));
142
104
}
143
- return IRB. CreateBitCast ( Ptr , ResElemTy-> getPointerTo (AddrSpace)) ;
105
+ return Ptr ;
144
106
}
145
107
146
108
// / DoPromotion - This method actually performs the promotion of the specified
0 commit comments