From 3da59db637a887474c1b1346c1f3ccf53b6c4663 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Mon, 27 Nov 2006 01:05:10 +0000 Subject: For PR950: The long awaited CAST patch. This introduces 12 new instructions into LLVM to replace the cast instruction. Corresponding changes throughout LLVM are provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the exception of 175.vpr which fails only on a slight floating point output difference. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31931 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/LowerAllocations.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'lib/Transforms/Utils/LowerAllocations.cpp') diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index d08235cd9d..b7e4040145 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/lib/Transforms/Utils/LowerAllocations.cpp @@ -134,7 +134,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) { } else { Value *Scale = MI->getOperand(0); if (Scale->getType() != IntPtrTy) - Scale = new CastInst(Scale, IntPtrTy, "", I); + Scale = CastInst::createInferredCast(Scale, IntPtrTy, "", I); // Multiply it by the array size if necessary... MallocArg = BinaryOperator::create(Instruction::Mul, Scale, @@ -148,10 +148,13 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) { if (MallocFTy->getNumParams() > 0 || MallocFTy->isVarArg()) { if (MallocFTy->isVarArg()) { if (MallocArg->getType() != IntPtrTy) - MallocArg = new CastInst(MallocArg, IntPtrTy, "", I); + MallocArg = CastInst::createInferredCast(MallocArg, IntPtrTy, "", + I); } else if (MallocFTy->getNumParams() > 0 && MallocFTy->getParamType(0) != Type::UIntTy) - MallocArg = new CastInst(MallocArg, MallocFTy->getParamType(0), "",I); + MallocArg = + CastInst::createInferredCast(MallocArg, MallocFTy->getParamType(0), + "",I); MallocArgs.push_back(MallocArg); } @@ -166,7 +169,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) { // Create a cast instruction to convert to the right type... Value *MCast; if (MCall->getType() != Type::VoidTy) - MCast = new CastInst(MCall, MI->getType(), "", I); + MCast = CastInst::createInferredCast(MCall, MI->getType(), "", I); else MCast = Constant::getNullValue(MI->getType()); @@ -183,7 +186,8 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) { Value *MCast = FI->getOperand(0); if (FreeFTy->getNumParams() > 0 && FreeFTy->getParamType(0) != MCast->getType()) - MCast = new CastInst(MCast, FreeFTy->getParamType(0), "", I); + MCast = CastInst::createInferredCast(MCast, FreeFTy->getParamType(0), + "", I); FreeArgs.push_back(MCast); } -- cgit v1.2.3