Skip to content

Commit 7fb6233

Browse files
committed
IRGen: Remove old workaround to force emitting GOT entries
The logic in getAddrOfLLVMVariableOrGOTEquivalent() should be sufficient to decide if a GOT entry is needed.
1 parent 204fce6 commit 7fb6233

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -764,19 +764,9 @@ IRGenModule::getAddrOfContextDescriptorForParent(DeclContext *parent,
764764
// descriptor, so we'll just emit an extension context.
765765
auto clas = dyn_cast<ClassDecl>(nominal);
766766
if (!clas || clas->isForeign() || hasKnownSwiftMetadata(*this, clas)) {
767-
// Some targets don't support relative references to undefined symbols.
768-
// If the extension is in a different file from the original type
769-
// declaration, it may not get emitted in this TU. Use an indirect
770-
// reference to work around the object format limitation.
771-
auto shouldBeIndirect =
772-
parent->getModuleScopeContext() != ofChild->getModuleScopeContext()
773-
? ConstantReference::Indirect
774-
: ConstantReference::Direct;
775-
776767
IRGen.noteUseOfTypeContextDescriptor(nominal, DontRequireMetadata);
777768
return getAddrOfLLVMVariableOrGOTEquivalent(
778-
LinkEntity::forNominalTypeDescriptor(nominal),
779-
shouldBeIndirect);
769+
LinkEntity::forNominalTypeDescriptor(nominal));
780770
}
781771
}
782772
return {getAddrOfExtensionContextDescriptor(ext),
@@ -2870,8 +2860,7 @@ IRGenModule::getAddrOfLLVMVariable(LinkEntity entity,
28702860
/// global variable. LLVM can replace relative references to this variable with
28712861
/// relative references to the GOT entry for the variable in the object file.
28722862
ConstantReference
2873-
IRGenModule::getAddrOfLLVMVariableOrGOTEquivalent(LinkEntity entity,
2874-
ConstantReference::Directness forceIndirectness) {
2863+
IRGenModule::getAddrOfLLVMVariableOrGOTEquivalent(LinkEntity entity) {
28752864
// Handle SILFunctions specially, because unlike other entities they aren't
28762865
// variables and aren't kept in the GlobalVars table.
28772866
if (entity.isSILFunction()) {
@@ -2934,10 +2923,6 @@ IRGenModule::getAddrOfLLVMVariableOrGOTEquivalent(LinkEntity entity,
29342923
return {gotEquivalent, ConstantReference::Indirect};
29352924
};
29362925

2937-
// Return the GOT entry if we were asked to.
2938-
if (forceIndirectness == ConstantReference::Indirect)
2939-
return indirect();
2940-
29412926
// The integrated REPL incrementally adds new definitions, so always use
29422927
// indirect references in this mode.
29432928
if (IRGen.Opts.IntegratedREPL)

lib/IRGen/IRGenModule.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,8 +1483,7 @@ private: \
14831483
GenericEnvironment *getGenericEnvironment();
14841484

14851485
ConstantReference
1486-
getAddrOfLLVMVariableOrGOTEquivalent(LinkEntity entity,
1487-
ConstantReference::Directness forceIndirect = ConstantReference::Direct);
1486+
getAddrOfLLVMVariableOrGOTEquivalent(LinkEntity entity);
14881487

14891488
llvm::Constant *
14901489
emitRelativeReference(ConstantReference target,

0 commit comments

Comments
 (0)