diff --git a/llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp b/llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp index e4dd2e9dace1..a666c5fe2e1c 100644 --- a/llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp +++ b/llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp @@ -189,8 +189,8 @@ InstructionSelection::InsertCodeForPhis(Function &F) // MachineFunction &MF = MachineFunction::get(&F); for (MachineFunction::iterator BB = MF.begin(); BB != MF.end(); ++BB) { - for (BasicBlock::iterator IIt = BB->getBasicBlock()->begin(); - PHINode *PN = dyn_cast(IIt); ++IIt) { + for (BasicBlock::const_iterator IIt = BB->getBasicBlock()->begin(); + const PHINode *PN = dyn_cast(IIt); ++IIt) { // FIXME: This is probably wrong... Value *PhiCpRes = new PHINode(PN->getType(), "PhiCp:"); @@ -209,7 +209,7 @@ InstructionSelection::InsertCodeForPhis(Function &F) for (vector::iterator MI=mvec.begin(); MI != mvec.end(); ++MI) { vector CpVec2 = - FixConstantOperandsForInstr(PN, *MI, Target); + FixConstantOperandsForInstr(const_cast(PN), *MI, Target); CpVec2.push_back(*MI); CpVec.insert(CpVec.end(), CpVec2.begin(), CpVec2.end()); } @@ -218,7 +218,8 @@ InstructionSelection::InsertCodeForPhis(Function &F) } vector mvec; - Target.getRegInfo().cpValue2Value(PhiCpRes, PN, mvec); + Target.getRegInfo().cpValue2Value(PhiCpRes, const_cast(PN), + mvec); BB->insert(BB->begin(), mvec.begin(), mvec.end()); } // for each Phi Instr in BB } // for all BBs in function diff --git a/llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp index f08e21fb933a..4d68b15dea88 100644 --- a/llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp +++ b/llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp @@ -569,7 +569,7 @@ void PhyRegAlloc::updateMachineCode() // for (MachineBasicBlock::iterator MII = MBB.begin(); MII != MBB.end(); ++MII) if (!TM.getInstrInfo().isDummyPhiInstr((*MII)->getOpCode()))// ignore Phis - updateInstruction(*MII, MBB.getBasicBlock()); + updateInstruction(*MII, const_cast(MBB.getBasicBlock())); // Now, move code out of delay slots of branches and returns if needed. // (Also, move "after" code from calls to the last delay slot instruction.)