[SILGen] Directly silgen access of #dsohandle

Synthesizing a VarDecl for #dsohandle causes some unwanted accessors to
be expected, but we really don't need them: this is a global variable
for the start of the image. There are only two uses of getDSOHandle:
getting the type and emitting the SIL for it. Rather than perform
acrobatics to turn off switches, just emit access directly where it's
needed.

rdar://problem/26565092
This commit is contained in:
David Farler
2016-07-28 16:06:20 -07:00
parent 8cb358195d
commit 3c11665d56
6 changed files with 40 additions and 39 deletions

View File

@@ -367,28 +367,6 @@ void Module::removeFile(FileUnit &existingFile) {
Files.erase(I.base());
}
VarDecl *Module::getDSOHandle() {
if (DSOHandle)
return DSOHandle;
auto unsafeMutableRawPtr = getASTContext().getUnsafeMutableRawPointerDecl();
if (!unsafeMutableRawPtr)
return nullptr;
auto &ctx = getASTContext();
auto handleVar = new (ctx) VarDecl(/*IsStatic=*/false, /*IsLet=*/false,
SourceLoc(),
ctx.getIdentifier("__dso_handle"),
unsafeMutableRawPtr->getDeclaredType(),
Files[0]);
handleVar->setImplicit(true);
handleVar->getAttrs().add(
new (ctx) SILGenNameAttr("__dso_handle", /*Implicit=*/true));
handleVar->setAccessibility(Accessibility::Internal);
DSOHandle = handleVar;
return handleVar;
}
#define FORWARD(name, args) \
for (const FileUnit *file : getFiles()) \
file->name args;