File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -505,13 +505,16 @@ static void updateProtocolRefs(IRGenModule &IGM,
505
505
assert (clangImporter && " Must have a clang importer" );
506
506
507
507
// Get the array containining the protocol refs.
508
- unsigned protocolRefsSize;
509
- llvm::ConstantArray *protocolRefs;
510
- std::tie (protocolRefsSize, protocolRefs) = getProtocolRefsList (protocol);
508
+ unsigned protocolRefsSize = getProtocolRefsList (protocol).first ;
511
509
unsigned currentIdx = 0 ;
512
510
auto inheritedObjCProtocols = getRuntimeProtocolList (objcProtocol->protocols ());
513
511
for (auto inheritedObjCProtocol : inheritedObjCProtocols) {
514
512
assert (currentIdx < protocolRefsSize);
513
+
514
+ // Getting the `protocolRefs` constant must not be hoisted out of the loop
515
+ // because this constant might be deleted by
516
+ // `oldVar->replaceAllUsesWith(newOpd)` below.
517
+ llvm::ConstantArray *protocolRefs = getProtocolRefsList (protocol).second ;
515
518
auto oldVar = protocolRefs->getOperand (currentIdx);
516
519
// Map the objc protocol to swift protocol.
517
520
auto optionalDecl = clangImporter->importDeclCached (inheritedObjCProtocol);
You can’t perform that action at this time.
0 commit comments