@@ -251,7 +251,7 @@ void emitMemsetExpansion(IRBuilder<> &Builder, Value *Dst, Value *Val,
251
251
ConstantInt *SizeCI,
252
252
DenseMap<Value *, Value *> &ReplacedValues) {
253
253
LLVMContext &Ctx = Builder.getContext ();
254
- [[maybe_unused]] DataLayout DL =
254
+ [[maybe_unused]] const DataLayout & DL =
255
255
Builder.GetInsertBlock ()->getModule ()->getDataLayout ();
256
256
[[maybe_unused]] uint64_t OrigSize = SizeCI->getZExtValue ();
257
257
@@ -276,16 +276,18 @@ void emitMemsetExpansion(IRBuilder<> &Builder, Value *Dst, Value *Val,
276
276
Value *TypedVal = Val;
277
277
278
278
if (Val->getType () != ElemTy) {
279
- // Note for i8 replacements if we know them we should use them.
280
- // Further if this is a constant ReplacedValues will return null
281
- // so we will stick to TypedVal = Val
282
- if (ReplacedValues[ Val])
279
+ if (ReplacedValues[Val]) {
280
+ // Note for i8 replacements if we know them we should use them.
281
+ // Further if this is a constant ReplacedValues will return null
282
+ // so we will stick to TypedVal = Val
283
283
TypedVal = ReplacedValues[Val];
284
- // This case Val is a ConstantInt so the cast folds away.
285
- // However if we don't do the cast the store below ends up being
286
- // an i8.
287
- else
284
+
285
+ } else {
286
+ // This case Val is a ConstantInt so the cast folds away.
287
+ // However if we don't do the cast the store below ends up being
288
+ // an i8.
288
289
TypedVal = Builder.CreateIntCast (Val, ElemTy, false );
290
+ }
289
291
}
290
292
291
293
for (uint64_t I = 0 ; I < Size ; ++I) {
@@ -298,19 +300,22 @@ void emitMemsetExpansion(IRBuilder<> &Builder, Value *Dst, Value *Val,
298
300
static void removeMemSet (Instruction &I,
299
301
SmallVectorImpl<Instruction *> &ToRemove,
300
302
DenseMap<Value *, Value *> &ReplacedValues) {
301
- if (CallInst *CI = dyn_cast<CallInst>(&I)) {
302
- Intrinsic::ID ID = CI->getIntrinsicID ();
303
- if (ID == Intrinsic::memset ) {
304
- IRBuilder<> Builder (&I);
305
- Value *Dst = CI->getArgOperand (0 );
306
- Value *Val = CI->getArgOperand (1 );
307
- [[maybe_unused]] ConstantInt *Size =
308
- dyn_cast<ConstantInt>(CI->getArgOperand (2 ));
309
- assert (Size && " Expected Size to be a ConstantInt" );
310
- emitMemsetExpansion (Builder, Dst, Val, Size , ReplacedValues);
311
- ToRemove.push_back (CI);
312
- }
313
- }
303
+
304
+ CallInst *CI = dyn_cast<CallInst>(&I);
305
+ if (!CI)
306
+ return ;
307
+
308
+ Intrinsic::ID ID = CI->getIntrinsicID ();
309
+ if (ID != Intrinsic::memset )
310
+ return ;
311
+
312
+ IRBuilder<> Builder (&I);
313
+ Value *Dst = CI->getArgOperand (0 );
314
+ Value *Val = CI->getArgOperand (1 );
315
+ ConstantInt *Size = dyn_cast<ConstantInt>(CI->getArgOperand (2 ));
316
+ assert (Size && " Expected Size to be a ConstantInt" );
317
+ emitMemsetExpansion (Builder, Dst, Val, Size , ReplacedValues);
318
+ ToRemove.push_back (CI);
314
319
}
315
320
316
321
namespace {
0 commit comments