Skip to content

Commit c73a04d

Browse files
committed
SILGen: ApplyOptions::Transparent and related support logic is dead, NFC
1 parent 7333c19 commit c73a04d

File tree

3 files changed

+6
-51
lines changed

3 files changed

+6
-51
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -226,27 +226,23 @@ class Callee {
226226
CanType OrigFormalInterfaceType;
227227
CanAnyFunctionType SubstFormalType;
228228
Optional<SILLocation> SpecializeLoc;
229-
bool IsTransparent;
230229
bool HasSubstitutions = false;
231230

232231
// The pointer back to the AST node that produced the callee.
233232
SILLocation Loc;
234233

235234

236-
public:
237-
void setTransparent(bool T) { IsTransparent = T; }
238235
private:
239236

240237
Callee(ManagedValue indirectValue,
241238
CanType origFormalType,
242239
CanAnyFunctionType substFormalType,
243-
bool isTransparent, SILLocation L)
240+
SILLocation L)
244241
: kind(Kind::IndirectValue),
245242
IndirectValue(indirectValue),
246243
OrigFormalOldType(origFormalType),
247244
OrigFormalInterfaceType(origFormalType),
248245
SubstFormalType(substFormalType),
249-
IsTransparent(isTransparent),
250246
Loc(L)
251247
{}
252248

@@ -273,7 +269,6 @@ class Callee {
273269
OrigFormalInterfaceType(getConstantFormalInterfaceType(gen, SILValue(),
274270
standaloneFunction)),
275271
SubstFormalType(substFormalType),
276-
IsTransparent(standaloneFunction.isTransparent()),
277272
Loc(l)
278273
{
279274
}
@@ -289,7 +284,6 @@ class Callee {
289284
OrigFormalInterfaceType(getConstantFormalInterfaceType(gen, selfValue,
290285
methodName)),
291286
SubstFormalType(substFormalType),
292-
IsTransparent(false),
293287
Loc(l)
294288
{
295289
}
@@ -419,12 +413,11 @@ class Callee {
419413
static Callee forIndirect(ManagedValue indirectValue,
420414
CanType origFormalType,
421415
CanAnyFunctionType substFormalType,
422-
bool isTransparent,
423416
SILLocation l) {
424417
return Callee(indirectValue,
425418
origFormalType,
426419
substFormalType,
427-
isTransparent, l);
420+
l);
428421
}
429422
static Callee forDirect(SILGenFunction &gen, SILDeclRef c,
430423
CanAnyFunctionType substFormalType,
@@ -514,7 +507,6 @@ class Callee {
514507
getAtUncurryLevel(SILGenFunction &gen, unsigned level) const {
515508
ManagedValue mv;
516509
ApplyOptions options = ApplyOptions::None;
517-
if (IsTransparent) options |= ApplyOptions::Transparent;
518510
SILConstantInfo constantInfo;
519511
Optional<SILDeclRef> constant = None;
520512

@@ -528,8 +520,6 @@ class Callee {
528520
case Kind::StandaloneFunction: {
529521
assert(level <= StandaloneFunction.uncurryLevel
530522
&& "uncurrying past natural uncurry level of standalone function");
531-
if (level < StandaloneFunction.uncurryLevel)
532-
options -= ApplyOptions::Transparent;
533523
constant = StandaloneFunction.atUncurryLevel(level);
534524

535525
// If we're currying a direct reference to a class-dispatched method,
@@ -554,7 +544,6 @@ class Callee {
554544
if (level < Method.MethodName.uncurryLevel) {
555545
SILValue ref = gen.emitGlobalFunctionRef(Loc, *constant, constantInfo);
556546
mv = ManagedValue::forUnmanaged(ref);
557-
options -= ApplyOptions::Transparent;
558547
break;
559548
}
560549

@@ -596,7 +585,6 @@ class Callee {
596585
if (level < Method.MethodName.uncurryLevel) {
597586
SILValue ref = gen.emitGlobalFunctionRef(Loc, *constant, constantInfo);
598587
mv = ManagedValue::forUnmanaged(ref);
599-
options -= ApplyOptions::Transparent;
600588
break;
601589
}
602590

@@ -925,39 +913,16 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
925913

926914
/// Fall back to an unknown, indirect callee.
927915
void visitExpr(Expr *e) {
928-
// This marks all calls to auto closure typed variables as transparent.
929-
// As of writing, local variable auto closures are currently allowed by
930-
// the parser, but the plan is that they will be disallowed, so this will
931-
// actually only apply to auto closure parameters, which is what we want
932-
auto *t = e->getType()->castTo<AnyFunctionType>();
933-
bool isTransparent = t->getExtInfo().isAutoClosure();
934-
935916
ManagedValue fn = SGF.emitRValueAsSingleValue(e);
936917
auto origType = cast<AnyFunctionType>(e->getType()->getCanonicalType());
937-
setCallee(Callee::forIndirect(fn, origType, getSubstFnType(), isTransparent,
938-
e));
918+
setCallee(Callee::forIndirect(fn, origType, getSubstFnType(), e));
939919
}
940920

941921
void visitLoadExpr(LoadExpr *e) {
942-
bool isTransparent = false;
943-
if (DeclRefExpr *d = dyn_cast<DeclRefExpr>(e->getSubExpr())) {
944-
// This marks all calls to auto closure typed variables as transparent.
945-
// As of writing, local variable auto closures are currently allowed by
946-
// the parser, but the plan is that they will be disallowed, so this will
947-
// actually only apply to auto closure parameters, which is what we want
948-
Type Ty = d->getDecl()->getType()->getInOutObjectType();
949-
950-
// If the decl type is a function type, figure out if it is an auto
951-
// closure.
952-
if (auto *AnyF = Ty->getAs<AnyFunctionType>()) {
953-
isTransparent = AnyF->getExtInfo().isAutoClosure();
954-
}
955-
}
956922
// TODO: preserve the function pointer at its original abstraction level
957923
ManagedValue fn = SGF.emitRValueAsSingleValue(e);
958924
auto origType = cast<AnyFunctionType>(e->getType()->getCanonicalType());
959-
setCallee(Callee::forIndirect(fn, origType, getSubstFnType(),
960-
isTransparent, e));
925+
setCallee(Callee::forIndirect(fn, origType, getSubstFnType(), e));
961926
}
962927

963928
/// Add a call site to the curry.
@@ -1538,11 +1503,6 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
15381503
: SILDeclRef::Kind::Initializer,
15391504
SILDeclRef::ConstructAtBestResilienceExpansion),
15401505
getSubstFnType(useAllocatingCtor), fn));
1541-
// In direct peer delegation cases, do not mark the apply as @transparent
1542-
// even if the underlying implementation is @transparent. This is a hack
1543-
// but is important because transparent inlining happends before DI, and
1544-
// DI needs to see the call to the delegated constructor.
1545-
ApplyCallee->setTransparent(false);
15461506
}
15471507

15481508
// Set up the substitutions, if we have any.

lib/SILGen/SILGenExpr.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,12 +1759,10 @@ SILGenFunction::emitApplyOfDefaultArgGenerator(SILLocation loc,
17591759
auto fnType = fnRef.getType().castTo<SILFunctionType>();
17601760
auto substFnType = fnType->substGenericArgs(SGM.M, SGM.M.getSwiftModule(),
17611761
defaultArgsOwner.getSubstitutions());
1762-
ApplyOptions options = ApplyOptions::None;
1763-
if (generator.isTransparent()) options |= ApplyOptions::Transparent;
17641762
return emitApply(loc, fnRef, defaultArgsOwner.getSubstitutions(),
17651763
{}, substFnType,
17661764
origResultType, resultType,
1767-
options, None, None, C);
1765+
ApplyOptions::None, None, None, C);
17681766
}
17691767

17701768
static void emitTupleShuffleExprInto(RValueEmitter &emitter,

lib/SILGen/SILGenFunction.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,9 @@ enum class ApplyOptions : unsigned {
146146
/// No special treatment is required.
147147
None = 0,
148148

149-
/// This call is transparent.
150-
Transparent = 0x1,
151-
152149
/// Suppress the error-handling edge out of the call. This should
153150
/// be used carefully; it's used to implement features like 'rethrows'.
154-
DoesNotThrow = 0x2,
151+
DoesNotThrow = 0x1,
155152
};
156153
inline ApplyOptions operator|(ApplyOptions lhs, ApplyOptions rhs) {
157154
return ApplyOptions(unsigned(lhs) | unsigned(rhs));

0 commit comments

Comments
 (0)