IRGen: simplify the stdlib special casing for Windows

Remove `IRGenModule::useDllStorage()` as there is a standalone version
that is available and the necessary information is public from the
`IRGenModule` type. Additionally, avoid the wrapped `isStandardLibrary`
preferring to use the same method off of the public accessors. This
works towards removing some of the standard library special casing so
that it is possible to support both static and dynamic standard
libraries on Windows.
This commit is contained in:
Saleem Abdulrasool
2024-12-11 16:12:59 -08:00
parent 7aed593047
commit c052d1b935
4 changed files with 6 additions and 15 deletions

View File

@@ -1057,10 +1057,6 @@ bool isStandardLibrary(const llvm::Module &M) {
}
}
bool IRGenModule::isStandardLibrary() const {
return ::isStandardLibrary(Module);
}
llvm::FunctionType *swift::getRuntimeFnType(llvm::Module &Module,
llvm::ArrayRef<llvm::Type*> retTypes,
llvm::ArrayRef<llvm::Type*> argTypes) {
@@ -1293,7 +1289,7 @@ IRGenModule::createStringConstant(StringRef Str, bool willBeRelativelyAddressed,
if (NAME) \
return NAME; \
NAME = Module.getOrInsertGlobal(SYM, FullExistentialTypeMetadataStructTy); \
if (useDllStorage() && !isStandardLibrary()) \
if (!getSwiftModule()->isStdlibModule()) \
ApplyIRLinkage(IRLinkage::ExternalImport) \
.to(cast<llvm::GlobalVariable>(NAME)); \
return NAME; \
@@ -2127,8 +2123,6 @@ void IRGenModule::error(SourceLoc loc, const Twine &message) {
message.toStringRef(buffer));
}
bool IRGenModule::useDllStorage() { return ::useDllStorage(Triple); }
// In embedded swift features are available independent of deployment and
// runtime targets because the runtime library is always statically linked
// to the program.
@@ -2152,9 +2146,9 @@ bool IRGenModule::shouldPrespecializeGenericMetadata() {
auto canPrespecializeTarget =
(Triple.isOSDarwin() || Triple.isOSWindows() ||
(Triple.isOSLinux() && !(Triple.isARM() && Triple.isArch32Bit())));
if (canPrespecializeTarget && isStandardLibrary()) {
if (canPrespecializeTarget && getSwiftModule()->isStdlibModule())
return IRGen.Opts.PrespecializeGenericMetadata;
}
auto &context = getSwiftModule()->getASTContext();
auto deploymentAvailability = AvailabilityRange::forDeploymentTarget(context);
return IRGen.Opts.PrespecializeGenericMetadata &&