Skip to content

Commit d2fc2c1

Browse files
committed
[IRGen] Silenced unused variable warning.
1 parent ee88152 commit d2fc2c1

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,29 +1970,21 @@ class AsyncCallEmission final : public CallEmission {
19701970
llArgs.add(selfValue);
19711971
}
19721972
auto layout = getAsyncContextLayout();
1973-
auto params = fnConv.getParameters();
1974-
for (auto index : indices(params)) {
1975-
Optional<ElementLayout> fieldLayout;
1976-
if (selfValue && index == params.size() - 1) {
1977-
fieldLayout = layout.getLocalContextLayout();
1978-
} else {
1979-
fieldLayout = layout.getArgumentLayout(index);
1980-
}
1973+
for (unsigned index = 0, count = layout.getArgumentCount(); index < count;
1974+
++index) {
1975+
auto fieldLayout = layout.getArgumentLayout(index);
19811976
Address fieldAddr =
1982-
fieldLayout->project(IGF, context, /*offsets*/ llvm::None);
1983-
auto &ti = cast<LoadableTypeInfo>(fieldLayout->getType());
1977+
fieldLayout.project(IGF, context, /*offsets*/ llvm::None);
1978+
auto &ti = cast<LoadableTypeInfo>(fieldLayout.getType());
19841979
ti.initialize(IGF, llArgs, fieldAddr, isOutlined);
19851980
}
1986-
unsigned index = 0;
1987-
for (auto indirectResult : fnConv.getIndirectSILResultTypes(
1988-
IGF.IGM.getMaximalTypeExpansionContext())) {
1989-
(void)indirectResult;
1981+
for (unsigned index = 0, count = layout.getIndirectReturnCount();
1982+
index < count; ++index) {
19901983
auto fieldLayout = layout.getIndirectReturnLayout(index);
19911984
Address fieldAddr =
19921985
fieldLayout.project(IGF, context, /*offsets*/ llvm::None);
19931986
cast<LoadableTypeInfo>(fieldLayout.getType())
19941987
.initialize(IGF, llArgs, fieldAddr, isOutlined);
1995-
++index;
19961988
}
19971989
if (layout.hasBindings()) {
19981990
auto bindingLayout = layout.getBindingsLayout();
@@ -2024,15 +2016,14 @@ class AsyncCallEmission final : public CallEmission {
20242016
Explosion nativeExplosion;
20252017
auto layout = getAsyncContextLayout();
20262018
auto dataAddr = layout.emitCastTo(IGF, context);
2027-
int index = layout.getFirstDirectReturnIndex();
2028-
for (auto result : fnConv.getDirectSILResults()) {
2029-
auto &fieldLayout = layout.getElement(index);
2019+
for (unsigned index = 0, count = layout.getDirectReturnCount();
2020+
index < count; ++index) {
2021+
auto fieldLayout = layout.getDirectReturnLayout(index);
20302022
Address fieldAddr =
20312023
fieldLayout.project(IGF, dataAddr, /*offsets*/ llvm::None);
20322024
auto &fieldTI = fieldLayout.getType();
20332025
cast<LoadableTypeInfo>(fieldTI).loadAsTake(IGF, fieldAddr,
20342026
nativeExplosion);
2035-
++index;
20362027
}
20372028

20382029
out = nativeSchema.mapFromNative(IGF.IGM, IGF, nativeExplosion, resultType);

lib/IRGen/GenCall.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ namespace irgen {
183183
}
184184

185185
unsigned getFirstDirectReturnIndex() { return getIndexAfterArguments(); }
186+
unsigned getDirectReturnCount() { return directReturnInfos.size(); }
187+
ElementLayout getDirectReturnLayout(unsigned index) {
188+
return getElement(getFirstDirectReturnIndex() + index);
189+
}
186190

187191
AsyncContextLayout(IRGenModule &IGM, LayoutStrategy strategy,
188192
ArrayRef<SILType> fieldTypes,

0 commit comments

Comments
 (0)