Skip to content

Commit ebb0d27

Browse files
committed
[IRGen] Simplify createGOTEquivalent().
Make this function take a LinkEntity describing what we're creating a GOT entry for, to simplify callers a bit.
1 parent feb1b55 commit ebb0d27

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,7 +2009,11 @@ llvm::Function *IRGenModule::getAddrOfSILFunction(SILFunction *f,
20092009

20102010
static llvm::GlobalVariable *createGOTEquivalent(IRGenModule &IGM,
20112011
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+
20132017
if (IGM.Triple.getObjectFormat() == llvm::Triple::COFF) {
20142018
if (cast<llvm::GlobalValue>(global)->hasDLLImportStorageClass()) {
20152019
llvm::GlobalVariable *GV =
@@ -2178,7 +2182,7 @@ IRGenModule::getAddrOfLLVMVariable(LinkEntity entity,
21782182

21792183
// Make a new GOT equivalent referring to the new variable with its
21802184
// definition type.
2181-
auto newGOTEquiv = createGOTEquivalent(*this, var, var->getName());
2185+
auto newGOTEquiv = createGOTEquivalent(*this, var, entity);
21822186
auto castGOTEquiv = llvm::ConstantExpr::getBitCast(newGOTEquiv,
21832187
existingGOTEquiv->getType());
21842188
existingGOTEquiv->replaceAllUsesWith(castGOTEquiv);
@@ -2256,9 +2260,7 @@ IRGenModule::getAddrOfLLVMVariableOrGOTEquivalent(LinkEntity entity,
22562260
auto global = cast<llvm::GlobalValue>(entry);
22572261
// Use it as the initializer for an anonymous constant. LLVM can treat this as
22582262
// 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);
22622264
gotEntry = gotEquivalent;
22632265
return {gotEquivalent, ConstantReference::Indirect};
22642266
};

0 commit comments

Comments
 (0)