Skip to content

Commit a6aedec

Browse files
committed
GlobalOpt: Don't assume we see all accesses to a global if it is imported from another module.
Currently we don't import (= deserialize) from other modules but we will if we serialize the StdlibUnitTests module. I didn't add an explicit test case, because it's not that easy. But this change will be tested when running the suite with serialized StdlibUnitTest.
1 parent 793b838 commit a6aedec

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/SILPasses/IPO/GlobalOpt.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,11 @@ SILGlobalVariable *SILGlobalOpt::getVariableOfGlobalInit(SILFunction *AddrF) {
713713
}
714714

715715
static bool canBeChangedExternally(SILGlobalVariable *SILG) {
716+
717+
// Don't assume anything about globals which are imported from other modules.
718+
if (isAvailableExternally(SILG->getLinkage()))
719+
return true;
720+
716721
// Use access specifiers from the declarations,
717722
// if possible.
718723
if (auto *Decl = SILG->getDecl()) {

0 commit comments

Comments
 (0)