if (castOpcodes[ArgNo])
Arg = CastInst::create(Instruction::CastOps(castOpcodes[ArgNo]),
Arg, FT->getParamType(ArgNo), Arg->getName(), CI);
- else
- Arg = CastInst::createInferredCast(Arg, FT->getParamType(ArgNo),
- Arg->getName(), CI);
+ else {
+ Instruction::CastOps opcode = CastInst::getCastOpcode(Arg,
+ Arg->getType()->isSigned(), FT->getParamType(ArgNo),
+ FT->getParamType(ArgNo)->isSigned());
+ Arg = CastInst::create(opcode, Arg, FT->getParamType(ArgNo),
+ Arg->getName(), CI);
+ }
Operands.push_back(Arg);
}
// Pass nulls into any additional arguments...
CallInst *NewCI = new CallInst(FCache, Operands, Name, CI);
if (!CI->use_empty()) {
Value *V = NewCI;
- if (CI->getType() != NewCI->getType())
- V = CastInst::createInferredCast(NewCI, CI->getType(), Name, CI);
+ if (CI->getType() != NewCI->getType()) {
+ Instruction::CastOps opcode = CastInst::getCastOpcode(NewCI,
+ NewCI->getType()->isSigned(), CI->getType(),
+ CI->getType()->isSigned());
+ V = CastInst::create(opcode, NewCI, CI->getType(), Name, CI);
+ }
CI->replaceAllUsesWith(V);
}
return NewCI;
Constant *Dummy = Constant::getNullValue(Ty);
switch (I->getOpcode()) {
- case Instruction::BitCast:
+ case Instruction::BitCast: {
assert(VMC.NewCasts.count(ValueHandle(VMC, I)) == 0);
- Res = CastInst::createInferredCast(I->getOperand(0), Ty, Name);
+ Instruction::CastOps opcode = CastInst::getCastOpcode(I->getOperand(0),
+ I->getOperand(0)->getType()->isSigned(), Ty, Ty->isSigned());
+ Res = CastInst::create(opcode, I->getOperand(0), Ty, Name);
VMC.NewCasts.insert(ValueHandle(VMC, Res));
break;
+ }
case Instruction::Add:
case Instruction::Sub:
Constant::getNullValue(NewTy) : 0;
switch (I->getOpcode()) {
- case Instruction::BitCast:
- Res = CastInst::createInferredCast(NewVal, I->getType(), Name);
+ case Instruction::BitCast: {
+ Instruction::CastOps opcode = CastInst::getCastOpcode(NewVal,
+ NewVal->getType()->isSigned(), I->getType(), I->getType()->isSigned());
+ Res = CastInst::create(opcode, NewVal, I->getType(), Name);
break;
+ }
case Instruction::Add:
case Instruction::Sub:
case 2:
AI = MainFn->arg_begin(); ++AI;
if (AI->getType() != ArgVTy) {
+ Instruction::CastOps opcode = CastInst::getCastOpcode(AI,
+ AI->getType()->isSigned(), ArgVTy, ArgVTy->isSigned());
InitCall->setOperand(2,
- CastInst::createInferredCast(AI, ArgVTy, "argv.cast", InitCall));
+ CastInst::create(opcode, AI, ArgVTy, "argv.cast", InitCall));
} else {
InitCall->setOperand(2, AI);
}
// If the program looked at argc, have it look at the return value of the
// init call instead.
if (AI->getType() != Type::IntTy) {
- if (!AI->use_empty())
+ Instruction::CastOps opcode;
+ if (!AI->use_empty()) {
+ opcode = CastInst::getCastOpcode(InitCall,
+ InitCall->getType()->isSigned(), AI->getType(),
+ AI->getType()->isSigned());
AI->replaceAllUsesWith(
- CastInst::createInferredCast(InitCall, AI->getType(), "", InsertPos));
+ CastInst::create(opcode, InitCall, AI->getType(), "", InsertPos));
+ }
+ opcode = CastInst::getCastOpcode(AI, AI->getType()->isSigned(),
+ Type::IntTy, true);
InitCall->setOperand(1,
- CastInst::createInferredCast(AI, Type::IntTy, "argc.cast", InitCall));
+ CastInst::create(opcode, AI, Type::IntTy, "argc.cast", InitCall));
} else {
AI->replaceAllUsesWith(InitCall);
InitCall->setOperand(1, AI);
if ((*AI)->getType() == ParamTy) {
Args.push_back(*AI);
} else {
- CastInst *NewCast = CastInst::createInferredCast(*AI, ParamTy, "tmp");
+ Instruction::CastOps opcode = CastInst::getCastOpcode(*AI,
+ (*AI)->getType()->isSigned(), ParamTy, ParamTy->isSigned());
+ CastInst *NewCast = CastInst::create(opcode, *AI, ParamTy, "tmp");
Args.push_back(InsertNewInstBefore(NewCast, *Caller));
}
}
const Type *PTy = getPromotedType((*AI)->getType());
if (PTy != (*AI)->getType()) {
// Must promote to pass through va_arg area!
- Instruction *Cast = CastInst::createInferredCast(*AI, PTy, "tmp");
+ Instruction::CastOps opcode = CastInst::getCastOpcode(
+ *AI, (*AI)->getType()->isSigned(), PTy, PTy->isSigned());
+ Instruction *Cast = CastInst::create(opcode, *AI, PTy, "tmp");
InsertNewInstBefore(Cast, *Caller);
Args.push_back(Cast);
} else {
Value *NV = NC;
if (Caller->getType() != NV->getType() && !Caller->use_empty()) {
if (NV->getType() != Type::VoidTy) {
- NV = NC = CastInst::createInferredCast(NC, Caller->getType(), "tmp");
+ const Type *CallerTy = Caller->getType();
+ Instruction::CastOps opcode = CastInst::getCastOpcode(
+ NC, NC->getType()->isSigned(), CallerTy, CallerTy->isSigned());
+ NV = NC = CastInst::create(opcode, NC, CallerTy, "tmp");
// If this is an invoke instruction, we should insert it after the first
// non-phi, instruction in the normal successor block.