mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Two fixes:
1. Memset takes an i32 for the value to set, not i8. This was causing GCC to ICE all over the place (PR1183). 2. memcpy/memmove were not properly zext/trunc'ing the size in some cases. llvm-svn: 33970
This commit is contained in:
parent
f69c0387b6
commit
c0fcd78ca0
@ -356,58 +356,48 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
|
|||||||
case Intrinsic::dbg_declare:
|
case Intrinsic::dbg_declare:
|
||||||
break; // Simply strip out debugging intrinsics
|
break; // Simply strip out debugging intrinsics
|
||||||
|
|
||||||
case Intrinsic::memcpy_i32: {
|
case Intrinsic::memcpy_i32:
|
||||||
static Constant *MemcpyFCache = 0;
|
|
||||||
Value * Size = cast<Value>(CI->op_end()-1);
|
|
||||||
if (Size->getType() != TD.getIntPtrType())
|
|
||||||
Size->replaceAllUsesWith(new ZExtInst(Size, TD.getIntPtrType()));
|
|
||||||
ReplaceCallWith("memcpy", CI, CI->op_begin()+1, CI->op_end()-1,
|
|
||||||
(*(CI->op_begin()+1))->getType(), MemcpyFCache);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Intrinsic::memcpy_i64: {
|
case Intrinsic::memcpy_i64: {
|
||||||
static Constant *MemcpyFCache = 0;
|
static Constant *MemcpyFCache = 0;
|
||||||
Value * Size = cast<Value>(CI->op_end()-1);
|
Value *Size = CI->getOperand(3);
|
||||||
if (Size->getType() != TD.getIntPtrType())
|
const Type *IntPtr = TD.getIntPtrType();
|
||||||
Size->replaceAllUsesWith(new TruncInst(Size, TD.getIntPtrType()));
|
if (Size->getType()->getPrimitiveSizeInBits() <
|
||||||
ReplaceCallWith("memcpy", CI, CI->op_begin()+1, CI->op_end()-1,
|
IntPtr->getPrimitiveSizeInBits())
|
||||||
(*(CI->op_begin()+1))->getType(), MemcpyFCache);
|
Size = new ZExtInst(Size, IntPtr, "", CI);
|
||||||
break;
|
else if (Size->getType()->getPrimitiveSizeInBits() >
|
||||||
}
|
IntPtr->getPrimitiveSizeInBits())
|
||||||
case Intrinsic::memmove_i32: {
|
Size = new TruncInst(Size, IntPtr, "", CI);
|
||||||
static Constant *MemmoveFCache = 0;
|
Value *Ops[3];
|
||||||
Value * Size = cast<Value>(CI->op_end()-1);
|
Ops[0] = CI->getOperand(1);
|
||||||
if (Size->getType() != TD.getIntPtrType())
|
Ops[1] = CI->getOperand(2);
|
||||||
Size->replaceAllUsesWith(new ZExtInst(Size, TD.getIntPtrType()));
|
Ops[2] = Size;
|
||||||
ReplaceCallWith("memmove", CI, CI->op_begin()+1, CI->op_end()-1,
|
ReplaceCallWith("memcpy", CI, Ops, Ops+3, CI->getOperand(1)->getType(),
|
||||||
(*(CI->op_begin()+1))->getType(), MemmoveFCache);
|
MemcpyFCache);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case Intrinsic::memmove_i32:
|
||||||
case Intrinsic::memmove_i64: {
|
case Intrinsic::memmove_i64: {
|
||||||
static Constant *MemmoveFCache = 0;
|
static Constant *MemmoveFCache = 0;
|
||||||
Value * Size = cast<Value>(CI->op_end()-1);
|
Value *Size = CI->getOperand(3);
|
||||||
if (Size->getType() != TD.getIntPtrType())
|
const Type *IntPtr = TD.getIntPtrType();
|
||||||
Size->replaceAllUsesWith(new TruncInst(Size, TD.getIntPtrType()));
|
if (Size->getType()->getPrimitiveSizeInBits() <
|
||||||
ReplaceCallWith("memmove", CI, CI->op_begin()+1, CI->op_end()-1,
|
IntPtr->getPrimitiveSizeInBits())
|
||||||
(*(CI->op_begin()+1))->getType(), MemmoveFCache);
|
Size = new ZExtInst(Size, IntPtr, "", CI);
|
||||||
|
else if (Size->getType()->getPrimitiveSizeInBits() >
|
||||||
|
IntPtr->getPrimitiveSizeInBits())
|
||||||
|
Size = new TruncInst(Size, IntPtr, "", CI);
|
||||||
|
Value *Ops[3];
|
||||||
|
Ops[0] = CI->getOperand(1);
|
||||||
|
Ops[1] = CI->getOperand(2);
|
||||||
|
Ops[2] = Size;
|
||||||
|
ReplaceCallWith("memmove", CI, Ops, Ops+3, CI->getOperand(1)->getType(),
|
||||||
|
MemmoveFCache);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Intrinsic::memset_i32: {
|
case Intrinsic::memset_i32:
|
||||||
static Constant *MemsetFCache = 0;
|
|
||||||
Value *Size = cast<Value>(CI->op_end()-1);
|
|
||||||
const Type *IntPtr = TD.getIntPtrType();
|
|
||||||
if (Size->getType()->getPrimitiveSizeInBits() <
|
|
||||||
IntPtr->getPrimitiveSizeInBits())
|
|
||||||
Size = new ZExtInst(Size, IntPtr, "", CI);
|
|
||||||
else if (Size->getType()->getPrimitiveSizeInBits() >
|
|
||||||
IntPtr->getPrimitiveSizeInBits())
|
|
||||||
Size = new TruncInst(Size, IntPtr, "", CI);
|
|
||||||
ReplaceCallWith("memset", CI, CI->op_begin()+1, CI->op_end()-1,
|
|
||||||
(*(CI->op_begin()+1))->getType(), MemsetFCache);
|
|
||||||
}
|
|
||||||
case Intrinsic::memset_i64: {
|
case Intrinsic::memset_i64: {
|
||||||
static Constant *MemsetFCache = 0;
|
static Constant *MemsetFCache = 0;
|
||||||
Value *Size = cast<Value>(CI->op_end()-1);
|
Value *Size = CI->getOperand(3);
|
||||||
const Type *IntPtr = TD.getIntPtrType();
|
const Type *IntPtr = TD.getIntPtrType();
|
||||||
if (Size->getType()->getPrimitiveSizeInBits() <
|
if (Size->getType()->getPrimitiveSizeInBits() <
|
||||||
IntPtr->getPrimitiveSizeInBits())
|
IntPtr->getPrimitiveSizeInBits())
|
||||||
@ -415,8 +405,13 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
|
|||||||
else if (Size->getType()->getPrimitiveSizeInBits() >
|
else if (Size->getType()->getPrimitiveSizeInBits() >
|
||||||
IntPtr->getPrimitiveSizeInBits())
|
IntPtr->getPrimitiveSizeInBits())
|
||||||
Size = new TruncInst(Size, IntPtr, "", CI);
|
Size = new TruncInst(Size, IntPtr, "", CI);
|
||||||
ReplaceCallWith("memset", CI, CI->op_begin()+1, CI->op_end()-1,
|
Value *Ops[3];
|
||||||
(*(CI->op_begin()+1))->getType(), MemsetFCache);
|
Ops[0] = CI->getOperand(1);
|
||||||
|
// Extend the amount to i32.
|
||||||
|
Ops[1] = new ZExtInst(CI->getOperand(2), Type::Int32Ty, "", CI);
|
||||||
|
Ops[2] = Size;
|
||||||
|
ReplaceCallWith("memset", CI, Ops, Ops+3, CI->getOperand(1)->getType(),
|
||||||
|
MemsetFCache);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Intrinsic::sqrt_f32: {
|
case Intrinsic::sqrt_f32: {
|
||||||
|
Loading…
Reference in New Issue
Block a user