diff --git a/llvm/tools/hpvm/lib/Transforms/GenVISC/GenVISC.cpp b/llvm/tools/hpvm/lib/Transforms/GenVISC/GenVISC.cpp index b1d265b132ff05289748efd6f131fdeac9ae54ab..43140244ff2593e3180bf5801974c3501c7d380e 100644 --- a/llvm/tools/hpvm/lib/Transforms/GenVISC/GenVISC.cpp +++ b/llvm/tools/hpvm/lib/Transforms/GenVISC/GenVISC.cpp @@ -801,9 +801,10 @@ static void replaceOpenCLCallsWithVISCIntrinsics(Function *F) { } } - for (std::vector<CallInst *>::reverse_iterator ri = IItoRemove.rbegin(), - re = IItoRemove.rend(); ri != re; ++ri) - (*ri)->eraseFromParent(); +//for (std::vector<CallInst *>::reverse_iterator ri = IItoRemove.rbegin(), + // re = IItoRemove.rend(); ri != re; ++ri) + for (CallInst *CI : reverse(IItoRemove)) + CI->eraseFromParent(); } @@ -866,14 +867,11 @@ bool GenVISC::runOnModule(Module &M) { std::vector<Instruction*> toBeErased; std::vector<Function*> functions; - for (Module::iterator mi = M.begin(), me = M.end(); mi != me; ++mi) { - Function* f = &*mi; - functions.push_back(f); - } + for (auto &F : M) + functions.push_back(&F); // Iterate over all functions in the module - for (unsigned i = 0; i < functions.size(); i++) { - Function* f = functions[i]; + for (Function *f : functions) { DEBUG(errs() << "Function: " << f->getName() << "\n"); // List with the required additions in the function's return type @@ -1646,7 +1644,7 @@ static Function* transformReturnTypeToStruct(Function* F) { SmallVector<ReturnInst*, 8> Returns; Function* newF = cloneFunction(F, FTy, false, &Returns); // Replace ret void instruction with ret %RetTy undef - for(auto RI: Returns) { + for(auto &RI: Returns) { DEBUG(errs() << "Found return inst: "<< *RI << "\n"); ReturnInst* newRI = ReturnInst::Create(newF->getContext(), UndefValue::get(RetTy)); ReplaceInstWithInst(RI, newRI);