summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-12-18 08:47:13 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-12-18 08:47:13 +0000
commit668d90f2892ed5700faa78951c5686923f2a9d6e (patch)
tree31a8d79358950aa31145c73963241655e17ee1f1 /llvm/lib/Transforms
parent4800c38a7546a8fc2435722b9e05470edb15d03e (diff)
downloadbcm5719-llvm-668d90f2892ed5700faa78951c5686923f2a9d6e.tar.gz
bcm5719-llvm-668d90f2892ed5700faa78951c5686923f2a9d6e.zip
Convert the last uses of CastInst::createInferredCast to a normal cast
creation. These changes are still temporary but at least this pushes knowledge of signedness out closer to where it can be determined properly and allows signedness to be removed from VMCore. llvm-svn: 32654
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/ExprTypeConvert.cpp14
-rw-r--r--llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp17
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp13
3 files changed, 33 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/ExprTypeConvert.cpp b/llvm/lib/Transforms/ExprTypeConvert.cpp
index 814318a587e..d59fb4db143 100644
--- a/llvm/lib/Transforms/ExprTypeConvert.cpp
+++ b/llvm/lib/Transforms/ExprTypeConvert.cpp
@@ -228,11 +228,14 @@ Value *llvm::ConvertExpressionToType(Value *V, const Type *Ty,
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:
@@ -706,9 +709,12 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
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:
diff --git a/llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp
index 274275a689b..4adf09e0999 100644
--- a/llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp
@@ -62,8 +62,10 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
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);
}
@@ -74,11 +76,18 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
// 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);
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index c63bfcb8c23..66c57a9bac8 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -7009,7 +7009,9 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
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));
}
}
@@ -7030,7 +7032,9 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
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 {
@@ -7058,7 +7062,10 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
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.
OpenPOWER on IntegriCloud