Skip to content

Commit f6c0773

Browse files
committed
[AddressLowering] Set new ParamDecl's specifier.
It's required that ParamDecl's that are synthesized have a specifier set. Set it to InOut, matching SILGen's behavior in emitIndirectResultParameters.
1 parent 153b1ac commit f6c0773

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/SILOptimizer/Mandatory/AddressLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
#define DEBUG_TYPE "address-lowering"
136136

137137
#include "PhiStorageOptimizer.h"
138+
#include "swift/AST/Decl.h"
138139
#include "swift/Basic/BlotSetVector.h"
139140
#include "swift/Basic/Range.h"
140141
#include "swift/SIL/BasicBlockUtils.h"
@@ -559,6 +560,7 @@ static unsigned insertIndirectReturnArgs(AddressLoweringState &pass) {
559560
auto var = new (astCtx) ParamDecl(
560561
SourceLoc(), SourceLoc(), astCtx.getIdentifier("$return_value"),
561562
SourceLoc(), astCtx.getIdentifier("$return_value"), declCtx);
563+
var->setSpecifier(ParamSpecifier::InOut);
562564

563565
SILFunctionArgument *funcArg =
564566
pass.function->begin()->insertFunctionArgument(
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %target-swift-frontend -enable-sil-opaque-values -parse-as-library -emit-sil -O %s | %FileCheck %s
2+
3+
// Verify the arguments. When AccessPathVerification runs, it will be checked
4+
// that the ParamDecl that AddressLowering synthesizes has a specifier
5+
// (ParamSpecifier) set.
6+
// CHECK-LABEL: sil @$s15opaque_values_O3minyxx_xtSLRzlF : {{.*}} {
7+
// CHECK: bb0(%0 : $*T, %1 : $*T, %2 : $*T):
8+
// CHECK-LABEL: } // end sil function '$s15opaque_values_O3minyxx_xtSLRzlF'
9+
public func min<T: Comparable>(_ x: T, _ y: T) -> T {
10+
return y < x ? y : x
11+
}

0 commit comments

Comments
 (0)