Skip to content

Commit ccbb6e1

Browse files
authored
Merge pull request #68201 from atrick/verify-partialapply-callee
SIL verification: non-address partial apply callee
2 parents b40b1db + 8a71844 commit ccbb6e1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeSideEffects.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ private struct CollectedEffects {
153153
// handleApply above is sufficient. And, if they are not applied
154154
// in this function, then they are never applied.
155155
if !pa.isOnStack {
156-
// the callee and its arguments are all captured...
157-
for operand in pa.operands {
158-
if operand.value.type.isAddress {
159-
addEffects(.read, to: operand.value)
156+
// callee is never an address.
157+
for argument in pa.arguments {
158+
if argument.type.isAddress {
159+
addEffects(.read, to: argument)
160160
}
161161
}
162162
}

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,6 +1932,10 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
19321932
require(resultInfo->getExtInfo().hasContext(),
19331933
"result of closure cannot have a thin function type");
19341934

1935+
// We rely on all indirect captures to be in the argument list.
1936+
require(PAI->getCallee()->getType().isObject(),
1937+
"Closure callee must not be an address type.");
1938+
19351939
checkApplyTypeDependentArguments(PAI);
19361940

19371941
auto substTy = checkApplySubstitutions(PAI->getSubstitutionMap(),

0 commit comments

Comments
 (0)