зеркало из https://github.com/microsoft/clang-1.git
reapply the (corrected) patch to use the new llvm intrinsics for memcpy/memmove etc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59824 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
bbe2743b02
Коммит
4e8a9e8640
|
@ -327,14 +327,16 @@ void AggExprEmitter::EmitNullInitializationToLValue(LValue LV, QualType T) {
|
|||
// There's a potential optimization opportunity in combining
|
||||
// memsets; that would be easy for arrays, but relatively
|
||||
// difficult for structures with the current code.
|
||||
llvm::Value *MemSet = CGF.CGM.getIntrinsic(llvm::Intrinsic::memset_i64);
|
||||
const llvm::Type *SizeTy = llvm::Type::Int64Ty;
|
||||
llvm::Value *MemSet = CGF.CGM.getIntrinsic(llvm::Intrinsic::memset,
|
||||
&SizeTy, 1);
|
||||
uint64_t Size = CGF.getContext().getTypeSize(T);
|
||||
|
||||
const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
|
||||
llvm::Value* DestPtr = Builder.CreateBitCast(LV.getAddress(), BP, "tmp");
|
||||
Builder.CreateCall4(MemSet, DestPtr,
|
||||
llvm::ConstantInt::get(llvm::Type::Int8Ty, 0),
|
||||
llvm::ConstantInt::get(llvm::Type::Int64Ty, Size/8),
|
||||
llvm::ConstantInt::get(SizeTy, Size/8),
|
||||
llvm::ConstantInt::get(llvm::Type::Int32Ty, 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -757,38 +757,20 @@ llvm::Function *CodeGenModule::getIntrinsic(unsigned IID,const llvm::Type **Tys,
|
|||
|
||||
llvm::Function *CodeGenModule::getMemCpyFn() {
|
||||
if (MemCpyFn) return MemCpyFn;
|
||||
llvm::Intrinsic::ID IID;
|
||||
switch (Context.Target.getPointerWidth(0)) {
|
||||
default: assert(0 && "Unknown ptr width");
|
||||
case 16: IID = llvm::Intrinsic::memcpy_i16; break;
|
||||
case 32: IID = llvm::Intrinsic::memcpy_i32; break;
|
||||
case 64: IID = llvm::Intrinsic::memcpy_i64; break;
|
||||
}
|
||||
return MemCpyFn = getIntrinsic(IID);
|
||||
const llvm::Type *IntPtr = TheTargetData.getIntPtrType();
|
||||
return MemCpyFn = getIntrinsic(llvm::Intrinsic::memcpy, &IntPtr, 1);
|
||||
}
|
||||
|
||||
llvm::Function *CodeGenModule::getMemMoveFn() {
|
||||
if (MemMoveFn) return MemMoveFn;
|
||||
llvm::Intrinsic::ID IID;
|
||||
switch (Context.Target.getPointerWidth(0)) {
|
||||
default: assert(0 && "Unknown ptr width");
|
||||
case 16: IID = llvm::Intrinsic::memmove_i16; break;
|
||||
case 32: IID = llvm::Intrinsic::memmove_i32; break;
|
||||
case 64: IID = llvm::Intrinsic::memmove_i64; break;
|
||||
}
|
||||
return MemMoveFn = getIntrinsic(IID);
|
||||
const llvm::Type *IntPtr = TheTargetData.getIntPtrType();
|
||||
return MemMoveFn = getIntrinsic(llvm::Intrinsic::memmove, &IntPtr, 1);
|
||||
}
|
||||
|
||||
llvm::Function *CodeGenModule::getMemSetFn() {
|
||||
if (MemSetFn) return MemSetFn;
|
||||
llvm::Intrinsic::ID IID;
|
||||
switch (Context.Target.getPointerWidth(0)) {
|
||||
default: assert(0 && "Unknown ptr width");
|
||||
case 16: IID = llvm::Intrinsic::memset_i16; break;
|
||||
case 32: IID = llvm::Intrinsic::memset_i32; break;
|
||||
case 64: IID = llvm::Intrinsic::memset_i64; break;
|
||||
}
|
||||
return MemSetFn = getIntrinsic(IID);
|
||||
const llvm::Type *IntPtr = TheTargetData.getIntPtrType();
|
||||
return MemSetFn = getIntrinsic(llvm::Intrinsic::memset, &IntPtr, 1);
|
||||
}
|
||||
|
||||
static void appendFieldAndPadding(CodeGenModule &CGM,
|
||||
|
|
Загрузка…
Ссылка в новой задаче