@@ -424,32 +424,17 @@ if (ExpectedSizeInBytes == Size) {
424
424
// store only the first ExpectedSizeInBytes bytes of Old
425
425
llvm::Type *OldType = Old->getType ();
426
426
427
- llvm::Align SrcAlignLLVM = DL.getABITypeAlign (OldType);
428
- llvm::Align DstAlignLLVM = DL.getABITypeAlign (ExpectedType);
429
-
430
- clang::CharUnits SrcAlign = clang::CharUnits::fromQuantity (SrcAlignLLVM.value ());
431
- clang::CharUnits DstAlign = clang::CharUnits::fromQuantity (DstAlignLLVM.value ());
432
-
433
427
// Allocate temporary storage for Old value
434
- llvm::AllocaInst *Alloca = CGF.CreateTempAlloca (OldType, " old.tmp" );
435
-
436
- // Wrap into clang::CodeGen::Address with proper type and alignment
437
- Address OldStorage (Alloca, OldType, SrcAlign);
428
+ Address OldTmp = CGF.CreateTempAlloca (OldType, Ptr.getAlignment (), " old.tmp" );
438
429
439
430
// Store Old into this temporary
440
- CGF.Builder .CreateStore (Old, OldStorage);
441
-
442
- // Bitcast pointers to i8*
443
- llvm::Type *I8PtrTy = llvm::PointerType::getUnqual (CGF.getLLVMContext ());
444
-
445
- llvm::Value *SrcPtr = CGF.Builder .CreateBitCast (OldStorage.getBasePointer (), I8PtrTy);
446
- llvm::Value *DstPtr = CGF.Builder .CreateBitCast (ExpectedResult.getBasePointer (), I8PtrTy);
431
+ CGF.Builder .CreateStore (Old, OldTmp);
447
432
448
433
// Perform memcpy for first ExpectedSizeInBytes bytes
449
434
CGF.Builder .CreateMemCpy (
450
- DstPtr, DstAlignLLVM ,
451
- SrcPtr, SrcAlignLLVM ,
452
- llvm::ConstantInt::get (CGF. IntPtrTy , ExpectedSizeInBytes) ,
435
+ ExpectedResult ,
436
+ OldTmp ,
437
+ ExpectedSizeInBytes,
453
438
/* isVolatile=*/ false );
454
439
}
455
440
0 commit comments