@@ -4157,34 +4157,29 @@ visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *E, SGFContext C) {
4157
4157
SILModule &M = SGF.SGM.M;
4158
4158
SILBuilder &B = SGF.B;
4159
4159
4160
- StructInst *S = nullptr;
4160
+ GlobalAddrInst *ModuleBase = nullptr;
4161
+
4161
4162
if (M.getASTContext().LangOpts.Target.isOSWindows()) {
4162
4163
auto ImageBase = M.lookUpGlobalVariable("__ImageBase");
4163
4164
if (!ImageBase)
4164
4165
ImageBase =
4165
4166
SILGlobalVariable::create(M, SILLinkage::Public, IsNotSerialized,
4166
4167
"__ImageBase", BuiltinRawPtrTy);
4167
-
4168
- auto ImageBaseAddr = B.createGlobalAddr(SILLoc, ImageBase);
4169
- auto ImageBasePointer =
4170
- B.createAddressToPointer(SILLoc, ImageBaseAddr, BuiltinRawPtrTy,
4171
- /*needsStackProtection=*/ false);
4172
- S = B.createStruct(SILLoc, UnsafeRawPtrTy, { ImageBasePointer });
4168
+ ModuleBase = B.createGlobalAddr(SILLoc, ImageBase);
4173
4169
} else {
4174
- auto DSOGlobal = M.lookUpGlobalVariable("__dso_handle");
4175
- if (!DSOGlobal)
4176
- DSOGlobal =
4177
- SILGlobalVariable::create(M, SILLinkage::PublicExternal,
4178
- IsNotSerialized, "__dso_handle",
4179
- BuiltinRawPtrTy);
4180
-
4181
- auto DSOAddr = B.createGlobalAddr(SILLoc, DSOGlobal);
4182
- auto DSOPointer =
4183
- B.createAddressToPointer(SILLoc, DSOAddr, BuiltinRawPtrTy,
4184
- /*needsStackProtection=*/ false);
4185
- S = B.createStruct(SILLoc, UnsafeRawPtrTy, { DSOPointer });
4170
+ auto DSOHandle = M.lookUpGlobalVariable("__dso_handle");
4171
+ if (!DSOHandle)
4172
+ DSOHandle = SILGlobalVariable::create(M, SILLinkage::PublicExternal,
4173
+ IsNotSerialized, "__dso_handle",
4174
+ BuiltinRawPtrTy);
4175
+ ModuleBase = B.createGlobalAddr(SILLoc, DSOHandle);
4186
4176
}
4187
4177
4178
+ auto ModuleBasePointer =
4179
+ B.createAddressToPointer(SILLoc, ModuleBase, BuiltinRawPtrTy,
4180
+ /*needsStackProtection=*/ false);
4181
+ StructInst *S =
4182
+ B.createStruct(SILLoc, UnsafeRawPtrTy, { ModuleBasePointer });
4188
4183
return RValue(SGF, E, ManagedValue::forUnmanaged(S));
4189
4184
}
4190
4185
}
0 commit comments