@@ -182,9 +182,10 @@ static void fixI8UseChain(Instruction &I,
182
182
ElementType = ArrTy->getArrayElementType ();
183
183
184
184
ConstantInt *Offset = dyn_cast<ConstantInt>(GEP->getOperand (1 ));
185
- // Note: the only way to convert an i8 offset to an i32 offset without
186
- // emitting code Would be to emit code. We sould expect this value to be a
187
- // ConstantInt since Offsets are very regulalrly converted.
185
+ // Note: i8 to i32 offset conversion without emitting IR requires constant
186
+ // ints. Since offset conversion is common, we can safely assume Offset is
187
+ // always a ConstantInt, so no need to have a conditional bail out on
188
+ // nullptr, instead assert this is the case.
188
189
assert (Offset && " Offset is expected to be a ConstantInt" );
189
190
uint32_t ByteOffset = Offset->getZExtValue ();
190
191
uint32_t ElemSize = GEP->getDataLayout ().getTypeAllocSize (ElementType);
@@ -210,20 +211,19 @@ static void upcastI8AllocasAndUses(Instruction &I,
210
211
auto ProcessLoad = [&](LoadInst *Load) {
211
212
for (User *LU : Load->users ()) {
212
213
Type *Ty = nullptr ;
213
- if (auto *Cast = dyn_cast<CastInst>(LU)) {
214
+ if (CastInst *Cast = dyn_cast<CastInst>(LU))
214
215
Ty = Cast->getType ();
215
- } else if (auto *CI = dyn_cast<CallInst>(LU)) {
216
+ else if (CallInst *CI = dyn_cast<CallInst>(LU)) {
216
217
if (CI->getIntrinsicID () == Intrinsic::memset)
217
218
Ty = Type::getInt32Ty (CI->getContext ());
218
219
}
219
220
220
221
if (!Ty)
221
222
continue ;
222
223
223
- if (!SmallestType || Ty-> getPrimitiveSizeInBits () <
224
- SmallestType->getPrimitiveSizeInBits ()) {
224
+ if (!SmallestType ||
225
+ Ty-> getPrimitiveSizeInBits () < SmallestType->getPrimitiveSizeInBits ())
225
226
SmallestType = Ty;
226
- }
227
227
}
228
228
};
229
229
@@ -232,9 +232,8 @@ static void upcastI8AllocasAndUses(Instruction &I,
232
232
ProcessLoad (Load);
233
233
else if (auto *GEP = dyn_cast<GetElementPtrInst>(U)) {
234
234
for (User *GU : GEP->users ()) {
235
- if (auto *Load = dyn_cast<LoadInst>(GU)) {
235
+ if (auto *Load = dyn_cast<LoadInst>(GU))
236
236
ProcessLoad (Load);
237
- }
238
237
}
239
238
}
240
239
}
0 commit comments