Skip to content

Commit c052d1b

Browse files
committed
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.
1 parent 7aed593 commit c052d1b

File tree

4 files changed

+6
-15
lines changed

4 files changed

+6
-15
lines changed

lib/IRGen/GenValueWitness.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,9 +1396,9 @@ getAddrOfKnownValueWitnessTable(IRGenModule &IGM, CanType type,
13961396
bool relativeReference) {
13971397
// Native PE binaries shouldn't reference data symbols across DLLs, so disable
13981398
// this on Windows, unless we're forming a relative indirectable reference.
1399-
if (IGM.useDllStorage() && !relativeReference)
1399+
if (useDllStorage(IGM.Triple) && !relativeReference)
14001400
return {};
1401-
1401+
14021402
if (auto nom = type->getAnyNominal()) {
14031403
// TODO: Non-C enums have extra inhabitants and also need additional value
14041404
// witnesses for their tag manipulation (except when they're empty, in

lib/IRGen/IRGenModule.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,10 +1057,6 @@ bool isStandardLibrary(const llvm::Module &M) {
10571057
}
10581058
}
10591059

1060-
bool IRGenModule::isStandardLibrary() const {
1061-
return ::isStandardLibrary(Module);
1062-
}
1063-
10641060
llvm::FunctionType *swift::getRuntimeFnType(llvm::Module &Module,
10651061
llvm::ArrayRef<llvm::Type*> retTypes,
10661062
llvm::ArrayRef<llvm::Type*> argTypes) {
@@ -1293,7 +1289,7 @@ IRGenModule::createStringConstant(StringRef Str, bool willBeRelativelyAddressed,
12931289
if (NAME) \
12941290
return NAME; \
12951291
NAME = Module.getOrInsertGlobal(SYM, FullExistentialTypeMetadataStructTy); \
1296-
if (useDllStorage() && !isStandardLibrary()) \
1292+
if (!getSwiftModule()->isStdlibModule()) \
12971293
ApplyIRLinkage(IRLinkage::ExternalImport) \
12981294
.to(cast<llvm::GlobalVariable>(NAME)); \
12991295
return NAME; \
@@ -2127,8 +2123,6 @@ void IRGenModule::error(SourceLoc loc, const Twine &message) {
21272123
message.toStringRef(buffer));
21282124
}
21292125

2130-
bool IRGenModule::useDllStorage() { return ::useDllStorage(Triple); }
2131-
21322126
// In embedded swift features are available independent of deployment and
21332127
// runtime targets because the runtime library is always statically linked
21342128
// to the program.
@@ -2152,9 +2146,9 @@ bool IRGenModule::shouldPrespecializeGenericMetadata() {
21522146
auto canPrespecializeTarget =
21532147
(Triple.isOSDarwin() || Triple.isOSWindows() ||
21542148
(Triple.isOSLinux() && !(Triple.isARM() && Triple.isArch32Bit())));
2155-
if (canPrespecializeTarget && isStandardLibrary()) {
2149+
if (canPrespecializeTarget && getSwiftModule()->isStdlibModule())
21562150
return IRGen.Opts.PrespecializeGenericMetadata;
2157-
}
2151+
21582152
auto &context = getSwiftModule()->getASTContext();
21592153
auto deploymentAvailability = AvailabilityRange::forDeploymentTarget(context);
21602154
return IRGen.Opts.PrespecializeGenericMetadata &&

lib/IRGen/IRGenModule.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -968,8 +968,6 @@ class IRGenModule {
968968
void fatal_unimplemented(SourceLoc, StringRef Message);
969969
void error(SourceLoc loc, const Twine &message);
970970

971-
bool useDllStorage();
972-
973971
bool shouldPrespecializeGenericMetadata();
974972

975973
bool canMakeStaticObjectReadOnly(SILType objectType);
@@ -1510,7 +1508,6 @@ class IRGenModule {
15101508
llvm::Module *getModule() const;
15111509
llvm::AttributeList getAllocAttrs();
15121510
llvm::Constant *getDeletedAsyncMethodErrorAsyncFunctionPointer();
1513-
bool isStandardLibrary() const;
15141511

15151512
private:
15161513
llvm::Constant *EmptyTupleMetadata = nullptr;

lib/IRGen/MetadataRequest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ irgen::tryEmitConstantHeapMetadataRef(IRGenModule &IGM,
602602
ConstantReference
603603
irgen::tryEmitConstantTypeMetadataRef(IRGenModule &IGM, CanType type,
604604
SymbolReferenceKind refKind) {
605-
if (IGM.isStandardLibrary())
605+
if (IGM.getSwiftModule()->isStdlibModule())
606606
return ConstantReference();
607607
if (isCanonicalCompleteTypeMetadataStaticallyAddressable(IGM, type))
608608
return ConstantReference();

0 commit comments

Comments
 (0)