Skip to content

Commit 54e5fa0

Browse files
committed
SILGen: Record the declarations that need a #_hasSymbol query function generated.
The query functions will be fully defined by IRGen.
1 parent 5c7a34b commit 54e5fa0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

include/swift/SIL/SILModule.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ class SILModule {
315315
/// This is the set of undef values we've created, for uniquing purposes.
316316
llvm::DenseMap<SILType, SILUndef *> UndefValues;
317317

318+
/// The list of decls that require query functions for #_hasSymbol conditions.
319+
llvm::SetVector<ValueDecl *> hasSymbolDecls;
320+
318321
llvm::DenseMap<std::pair<Decl *, VarDecl *>, unsigned> fieldIndices;
319322
llvm::DenseMap<EnumElementDecl *, unsigned> enumCaseIndices;
320323

@@ -700,6 +703,12 @@ class SILModule {
700703
return externallyVisible.count(decl) != 0;
701704
}
702705

706+
void addHasSymbolDecl(ValueDecl *decl) { hasSymbolDecls.insert(decl); }
707+
708+
ArrayRef<ValueDecl *> getHasSymbolDecls() {
709+
return hasSymbolDecls.getArrayRef();
710+
}
711+
703712
using sil_global_iterator = GlobalListType::iterator;
704713
using sil_global_const_iterator = GlobalListType::const_iterator;
705714
GlobalListType &getSILGlobalList() { return silGlobals; }

lib/SILGen/SILGenDecl.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,9 +1606,12 @@ void SILGenFunction::emitStmtCondition(StmtCondition Cond, JumpDest FalseDest,
16061606
auto declRef = info->getReferencedDecl();
16071607
assert(declRef);
16081608

1609-
auto queryFunc = declRef.getDecl()->getHasSymbolQueryDecl();
1609+
auto decl = declRef.getDecl();
1610+
getModule().addHasSymbolDecl(decl);
1611+
16101612
SILFunction *silFn = SGM.getFunction(
1611-
SILDeclRef(queryFunc, SILDeclRef::Kind::Func), NotForDefinition);
1613+
SILDeclRef(decl->getHasSymbolQueryDecl(), SILDeclRef::Kind::Func),
1614+
NotForDefinition);
16121615
SILValue fnRef = B.createFunctionRefFor(loc, silFn);
16131616
booleanTestValue = B.createApply(loc, fnRef, {}, {});
16141617
booleanTestValue = emitUnwrapIntegerResult(expr, booleanTestValue);

0 commit comments

Comments
 (0)