@@ -2009,7 +2009,11 @@ llvm::Function *IRGenModule::getAddrOfSILFunction(SILFunction *f,
2009
2009
2010
2010
static llvm::GlobalVariable *createGOTEquivalent (IRGenModule &IGM,
2011
2011
llvm::Constant *global,
2012
- StringRef globalName) {
2012
+ LinkEntity entity) {
2013
+ // Determine the name of this entity.
2014
+ llvm::SmallString<64 > globalName;
2015
+ entity.mangle (globalName);
2016
+
2013
2017
if (IGM.Triple .getObjectFormat () == llvm::Triple::COFF) {
2014
2018
if (cast<llvm::GlobalValue>(global)->hasDLLImportStorageClass ()) {
2015
2019
llvm::GlobalVariable *GV =
@@ -2178,7 +2182,7 @@ IRGenModule::getAddrOfLLVMVariable(LinkEntity entity,
2178
2182
2179
2183
// Make a new GOT equivalent referring to the new variable with its
2180
2184
// definition type.
2181
- auto newGOTEquiv = createGOTEquivalent (*this , var, var-> getName () );
2185
+ auto newGOTEquiv = createGOTEquivalent (*this , var, entity );
2182
2186
auto castGOTEquiv = llvm::ConstantExpr::getBitCast (newGOTEquiv,
2183
2187
existingGOTEquiv->getType ());
2184
2188
existingGOTEquiv->replaceAllUsesWith (castGOTEquiv);
@@ -2256,9 +2260,7 @@ IRGenModule::getAddrOfLLVMVariableOrGOTEquivalent(LinkEntity entity,
2256
2260
auto global = cast<llvm::GlobalValue>(entry);
2257
2261
// Use it as the initializer for an anonymous constant. LLVM can treat this as
2258
2262
// equivalent to the global's GOT entry.
2259
- llvm::SmallString<64 > name;
2260
- entity.mangle (name);
2261
- auto gotEquivalent = createGOTEquivalent (*this , global, name);
2263
+ auto gotEquivalent = createGOTEquivalent (*this , global, entity);
2262
2264
gotEntry = gotEquivalent;
2263
2265
return {gotEquivalent, ConstantReference::Indirect};
2264
2266
};
0 commit comments