@@ -5138,7 +5138,8 @@ void IRGenModule::emitOpaqueTypeDecl(OpaqueTypeDecl *D) {
5138
5138
bool irgen::methodRequiresReifiedVTableEntry (IRGenModule &IGM,
5139
5139
const SILVTable *vtable,
5140
5140
SILDeclRef method) {
5141
- auto entry = vtable->getEntry (IGM.getSILModule (), method);
5141
+ Optional<SILVTable::Entry> entry
5142
+ = vtable->getEntry (IGM.getSILModule (), method);
5142
5143
LLVM_DEBUG (llvm::dbgs () << " looking at vtable:\n " ;
5143
5144
vtable->print (llvm::dbgs ()));
5144
5145
if (!entry) {
@@ -5150,7 +5151,8 @@ bool irgen::methodRequiresReifiedVTableEntry(IRGenModule &IGM,
5150
5151
return true ;
5151
5152
}
5152
5153
LLVM_DEBUG (llvm::dbgs () << " entry: " ;
5153
- entry->print (llvm::dbgs ()));
5154
+ entry->print (llvm::dbgs ());
5155
+ llvm::dbgs () << " \n " );
5154
5156
5155
5157
// We may be able to elide the vtable entry, ABI permitting, if it's not
5156
5158
// overridden.
@@ -5163,21 +5165,25 @@ bool irgen::methodRequiresReifiedVTableEntry(IRGenModule &IGM,
5163
5165
return true ;
5164
5166
}
5165
5167
5166
- // Does the ABI require a vtable entry to exist? If the class is public,
5168
+ // Does the ABI require a vtable entry to exist? If the class the vtable
5169
+ // entry originates from is public,
5167
5170
// and it's either marked fragile or part of a non-resilient module, then
5168
5171
// other modules will directly address vtable offsets and we can't remove
5169
5172
// vtable entries.
5170
- if (vtable->getClass ()->getEffectiveAccess () >= AccessLevel::Public) {
5173
+ auto originatingClass =
5174
+ cast<ClassDecl>(method.getOverriddenVTableEntry ().getDecl ()->getDeclContext ());
5175
+
5176
+ if (originatingClass->getEffectiveAccess () >= AccessLevel::Public) {
5171
5177
// If the class is public,
5172
5178
// and it's either marked fragile or part of a non-resilient module, then
5173
5179
// other modules will directly address vtable offsets and we can't remove
5174
5180
// vtable entries.
5175
- if (!vtable-> getClass () ->isResilient ()) {
5181
+ if (!originatingClass ->isResilient ()) {
5176
5182
LLVM_DEBUG (llvm::dbgs () << " vtable entry in "
5177
5183
<< vtable->getClass ()->getName ()
5178
5184
<< " for " ;
5179
5185
method.print (llvm::dbgs ());
5180
- llvm::dbgs () << " is in a public fragile class\n " );
5186
+ llvm::dbgs () << " originates from a public fragile class\n " );
5181
5187
return true ;
5182
5188
}
5183
5189
}
0 commit comments