mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[IR] Use range-based for loops (NFC)
This commit is contained in:
parent
9d2bb4e874
commit
cf6f3cec61
@ -2332,17 +2332,17 @@ static void writeDIExpression(raw_ostream &Out, const DIExpression *N,
|
||||
Out << "!DIExpression(";
|
||||
FieldSeparator FS;
|
||||
if (N->isValid()) {
|
||||
for (auto I = N->expr_op_begin(), E = N->expr_op_end(); I != E; ++I) {
|
||||
auto OpStr = dwarf::OperationEncodingString(I->getOp());
|
||||
for (const DIExpression::ExprOperand &Op : N->expr_ops()) {
|
||||
auto OpStr = dwarf::OperationEncodingString(Op.getOp());
|
||||
assert(!OpStr.empty() && "Expected valid opcode");
|
||||
|
||||
Out << FS << OpStr;
|
||||
if (I->getOp() == dwarf::DW_OP_LLVM_convert) {
|
||||
Out << FS << I->getArg(0);
|
||||
Out << FS << dwarf::AttributeEncodingString(I->getArg(1));
|
||||
if (Op.getOp() == dwarf::DW_OP_LLVM_convert) {
|
||||
Out << FS << Op.getArg(0);
|
||||
Out << FS << dwarf::AttributeEncodingString(Op.getArg(1));
|
||||
} else {
|
||||
for (unsigned A = 0, AE = I->getNumArgs(); A != AE; ++A)
|
||||
Out << FS << I->getArg(A);
|
||||
for (unsigned A = 0, AE = Op.getNumArgs(); A != AE; ++A)
|
||||
Out << FS << Op.getArg(A);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -2914,12 +2914,11 @@ void AssemblyWriter::printModuleSummaryIndex() {
|
||||
}
|
||||
|
||||
// Print the TypeIdMap entries.
|
||||
for (auto TidIter = TheIndex->typeIds().begin();
|
||||
TidIter != TheIndex->typeIds().end(); TidIter++) {
|
||||
Out << "^" << Machine.getTypeIdSlot(TidIter->second.first)
|
||||
<< " = typeid: (name: \"" << TidIter->second.first << "\"";
|
||||
printTypeIdSummary(TidIter->second.second);
|
||||
Out << ") ; guid = " << TidIter->first << "\n";
|
||||
for (const auto &TID : TheIndex->typeIds()) {
|
||||
Out << "^" << Machine.getTypeIdSlot(TID.second.first)
|
||||
<< " = typeid: (name: \"" << TID.second.first << "\"";
|
||||
printTypeIdSummary(TID.second.second);
|
||||
Out << ") ; guid = " << TID.first << "\n";
|
||||
}
|
||||
|
||||
// Print the TypeIdCompatibleVtableMap entries.
|
||||
@ -4023,8 +4022,8 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
|
||||
} else if (const ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(&I)) {
|
||||
Out << ' ';
|
||||
writeOperand(I.getOperand(0), true);
|
||||
for (const unsigned *i = EVI->idx_begin(), *e = EVI->idx_end(); i != e; ++i)
|
||||
Out << ", " << *i;
|
||||
for (unsigned i : EVI->indices())
|
||||
Out << ", " << i;
|
||||
} else if (const InsertValueInst *IVI = dyn_cast<InsertValueInst>(&I)) {
|
||||
Out << ' ';
|
||||
writeOperand(I.getOperand(0), true); Out << ", ";
|
||||
|
@ -1869,9 +1869,8 @@ bool AttrBuilder::operator==(const AttrBuilder &B) const {
|
||||
if (Attrs != B.Attrs)
|
||||
return false;
|
||||
|
||||
for (td_const_iterator I = TargetDepAttrs.begin(),
|
||||
E = TargetDepAttrs.end(); I != E; ++I)
|
||||
if (B.TargetDepAttrs.find(I->first) == B.TargetDepAttrs.end())
|
||||
for (const auto &TDA : TargetDepAttrs)
|
||||
if (B.TargetDepAttrs.find(TDA.first) == B.TargetDepAttrs.end())
|
||||
return false;
|
||||
|
||||
return Alignment == B.Alignment && StackAlignment == B.StackAlignment &&
|
||||
|
@ -455,9 +455,8 @@ void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *Old,
|
||||
// Cope with being called on a BasicBlock that doesn't have a terminator
|
||||
// yet. Clang's CodeGenFunction::EmitReturnBlock() likes to do this.
|
||||
return;
|
||||
llvm::for_each(successors(TI), [Old, New](BasicBlock *Succ) {
|
||||
for (BasicBlock *Succ : successors(TI))
|
||||
Succ->replacePhiUsesWith(Old, New);
|
||||
});
|
||||
}
|
||||
|
||||
void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *New) {
|
||||
|
@ -679,9 +679,8 @@ unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy) {
|
||||
|
||||
void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest) {
|
||||
FunctionType *Ty = unwrap<FunctionType>(FunctionTy);
|
||||
for (FunctionType::param_iterator I = Ty->param_begin(),
|
||||
E = Ty->param_end(); I != E; ++I)
|
||||
*Dest++ = wrap(*I);
|
||||
for (Type *T : Ty->params())
|
||||
*Dest++ = wrap(T);
|
||||
}
|
||||
|
||||
/*--.. Operations on struct types ..........................................--*/
|
||||
@ -723,9 +722,8 @@ unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy) {
|
||||
|
||||
void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest) {
|
||||
StructType *Ty = unwrap<StructType>(StructTy);
|
||||
for (StructType::element_iterator I = Ty->element_begin(),
|
||||
E = Ty->element_end(); I != E; ++I)
|
||||
*Dest++ = wrap(*I);
|
||||
for (Type *T : Ty->elements())
|
||||
*Dest++ = wrap(T);
|
||||
}
|
||||
|
||||
LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i) {
|
||||
@ -2495,9 +2493,8 @@ unsigned LLVMCountParams(LLVMValueRef FnRef) {
|
||||
|
||||
void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs) {
|
||||
Function *Fn = unwrap<Function>(FnRef);
|
||||
for (Function::arg_iterator I = Fn->arg_begin(),
|
||||
E = Fn->arg_end(); I != E; I++)
|
||||
*ParamRefs++ = wrap(&*I);
|
||||
for (Argument &A : Fn->args())
|
||||
*ParamRefs++ = wrap(&A);
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index) {
|
||||
|
@ -82,8 +82,8 @@ DILocation *DILocation::getMergedLocations(ArrayRef<const DILocation *> Locs) {
|
||||
if (Locs.size() == 1)
|
||||
return Locs[0];
|
||||
auto *Merged = Locs[0];
|
||||
for (auto I = std::next(Locs.begin()), E = Locs.end(); I != E; ++I) {
|
||||
Merged = getMergedLocation(Merged, *I);
|
||||
for (const DILocation *L : llvm::drop_begin(Locs)) {
|
||||
Merged = getMergedLocation(Merged, L);
|
||||
if (Merged == nullptr)
|
||||
break;
|
||||
}
|
||||
|
@ -222,9 +222,7 @@ bool DominatorTree::dominates(const BasicBlockEdge &BBE,
|
||||
// other predecessors. Since the only way out of X is via NormalDest, X can
|
||||
// only properly dominate a node if NormalDest dominates that node too.
|
||||
int IsDuplicateEdge = 0;
|
||||
for (const_pred_iterator PI = pred_begin(End), E = pred_end(End);
|
||||
PI != E; ++PI) {
|
||||
const BasicBlock *BB = *PI;
|
||||
for (const BasicBlock *BB : predecessors(End)) {
|
||||
if (BB == Start) {
|
||||
// If there are multiple edges between Start and End, by definition they
|
||||
// can't dominate anything.
|
||||
|
@ -2105,13 +2105,13 @@ static bool isSingleSourceMaskImpl(ArrayRef<int> Mask, int NumOpElts) {
|
||||
assert(!Mask.empty() && "Shuffle mask must contain elements");
|
||||
bool UsesLHS = false;
|
||||
bool UsesRHS = false;
|
||||
for (int i = 0, NumMaskElts = Mask.size(); i < NumMaskElts; ++i) {
|
||||
if (Mask[i] == -1)
|
||||
for (int I : Mask) {
|
||||
if (I == -1)
|
||||
continue;
|
||||
assert(Mask[i] >= 0 && Mask[i] < (NumOpElts * 2) &&
|
||||
assert(I >= 0 && I < (NumOpElts * 2) &&
|
||||
"Out-of-bounds shuffle mask element");
|
||||
UsesLHS |= (Mask[i] < NumOpElts);
|
||||
UsesRHS |= (Mask[i] >= NumOpElts);
|
||||
UsesLHS |= (I < NumOpElts);
|
||||
UsesRHS |= (I >= NumOpElts);
|
||||
if (UsesLHS && UsesRHS)
|
||||
return false;
|
||||
}
|
||||
|
@ -948,14 +948,13 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
|
||||
|
||||
// Check inherited analysis also. If P is not preserving analysis
|
||||
// provided by parent manager then remove it here.
|
||||
for (unsigned Index = 0; Index < PMT_Last; ++Index) {
|
||||
|
||||
if (!InheritedAnalysis[Index])
|
||||
for (DenseMap<AnalysisID, Pass *> *IA : InheritedAnalysis) {
|
||||
if (!IA)
|
||||
continue;
|
||||
|
||||
for (DenseMap<AnalysisID, Pass*>::iterator
|
||||
I = InheritedAnalysis[Index]->begin(),
|
||||
E = InheritedAnalysis[Index]->end(); I != E; ) {
|
||||
for (DenseMap<AnalysisID, Pass *>::iterator I = IA->begin(),
|
||||
E = IA->end();
|
||||
I != E;) {
|
||||
DenseMap<AnalysisID, Pass *>::iterator Info = I++;
|
||||
if (Info->second->getAsImmutablePass() == nullptr &&
|
||||
!is_contained(PreservedSet, Info->first)) {
|
||||
@ -965,7 +964,7 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
|
||||
dbgs() << " -- '" << P->getPassName() << "' is not preserving '";
|
||||
dbgs() << S->getPassName() << "'\n";
|
||||
}
|
||||
InheritedAnalysis[Index]->erase(Info);
|
||||
IA->erase(Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,12 +98,11 @@ static void addByteCountSuffix(raw_ostream &OS, const Function *F,
|
||||
|
||||
const unsigned PtrSize = DL.getPointerSize();
|
||||
|
||||
for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
|
||||
AI != AE; ++AI) {
|
||||
for (const Argument &A : F->args()) {
|
||||
// 'Dereference' type in case of byval or inalloca parameter attribute.
|
||||
uint64_t AllocSize = AI->hasPassPointeeByValueCopyAttr() ?
|
||||
AI->getPassPointeeByValueCopySize(DL) :
|
||||
DL.getTypeAllocSize(AI->getType());
|
||||
uint64_t AllocSize = A.hasPassPointeeByValueCopyAttr() ?
|
||||
A.getPassPointeeByValueCopySize(DL) :
|
||||
DL.getTypeAllocSize(A.getType());
|
||||
|
||||
// Size should be aligned to pointer size.
|
||||
ArgWords += alignTo(AllocSize, PtrSize);
|
||||
|
Loading…
Reference in New Issue
Block a user