[llvm] r243136 - Use foreach loops for StructType::elements(). NFC.
Pete Cooper
peter_cooper at apple.com
Fri Jul 24 11:55:49 PDT 2015
Author: pete
Date: Fri Jul 24 13:55:49 2015
New Revision: 243136
URL: http://llvm.org/viewvc/llvm-project?rev=243136&view=rev
Log:
Use foreach loops for StructType::elements(). NFC.
We had a few places where we did
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
but those could instead do
for (auto *EltTy : STy->elements()) {
Modified:
llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=243136&r1=243135&r2=243136&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Fri Jul 24 13:55:49 2015
@@ -940,9 +940,9 @@ static void getMaxByValAlign(Type *Ty, u
if (EltAlign > MaxAlign)
MaxAlign = EltAlign;
} else if (StructType *STy = dyn_cast<StructType>(Ty)) {
- for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
+ for (auto *EltTy : STy->elements()) {
unsigned EltAlign = 0;
- getMaxByValAlign(STy->getElementType(i), EltAlign, MaxMaxAlign);
+ getMaxByValAlign(EltTy, EltAlign, MaxMaxAlign);
if (EltAlign > MaxAlign)
MaxAlign = EltAlign;
if (MaxAlign == MaxMaxAlign)
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=243136&r1=243135&r2=243136&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Jul 24 13:55:49 2015
@@ -1818,9 +1818,9 @@ static void getMaxByValAlign(Type *Ty, u
if (EltAlign > MaxAlign)
MaxAlign = EltAlign;
} else if (StructType *STy = dyn_cast<StructType>(Ty)) {
- for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
+ for (auto *EltTy : STy->elements()) {
unsigned EltAlign = 0;
- getMaxByValAlign(STy->getElementType(i), EltAlign);
+ getMaxByValAlign(EltTy, EltAlign);
if (EltAlign > MaxAlign)
MaxAlign = EltAlign;
if (MaxAlign == 16)
Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=243136&r1=243135&r2=243136&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Fri Jul 24 13:55:49 2015
@@ -281,8 +281,8 @@ CallGraphNode *ArgPromotion::PromoteArgu
// If all the elements are single-value types, we can promote it.
bool AllSimple = true;
- for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
- if (!STy->getElementType(i)->isSingleValueType()) {
+ for (const auto *EltTy : STy->elements()) {
+ if (!EltTy->isSingleValueType()) {
AllSimple = false;
break;
}
@@ -303,8 +303,8 @@ CallGraphNode *ArgPromotion::PromoteArgu
if (isSelfRecursive) {
if (StructType *STy = dyn_cast<StructType>(AgTy)) {
bool RecursiveType = false;
- for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
- if (STy->getElementType(i) == PtrArg->getType()) {
+ for (const auto *EltTy : STy->elements()) {
+ if (EltTy == PtrArg->getType()) {
RecursiveType = true;
break;
}
More information about the llvm-commits
mailing list