@@ -441,6 +441,8 @@ isStringStoreToIdentifyableObject(SILInstruction *inst) {
441441 case SILInstructionKind::DeallocStackInst:
442442 case SILInstructionKind::LoadInst:
443443 break ;
444+ case SILInstructionKind::LoadBorrowInst:
445+ break ;
444446 case SILInstructionKind::DebugValueInst:
445447 if (DebugValueInst::hasAddrVal (user))
446448 break ;
@@ -579,12 +581,13 @@ StringOptimization::getStringFromStaticLet(SILValue value) {
579581 // %ptr_to_global = apply %addressor()
580582 // %global_addr = pointer_to_address %ptr_to_global
581583 // %value = load %global_addr
582- auto *load = dyn_cast<LoadInst>(value);
583- if (!load)
584- return StringInfo::unknown ();
584+ if (!isa<LoadInst>(value) && !isa<LoadBorrowInst>(value)) {
585+ return StringInfo::unknown ();
586+ }
587+ auto *load = value->getDefiningInstruction ();
585588
586589 SILFunction *initializer = nullptr ;
587- auto *globalAddr = dyn_cast<GlobalAddrInst>(load->getOperand ());
590+ auto *globalAddr = dyn_cast<GlobalAddrInst>(load->getOperand (0 ));
588591 if (globalAddr) {
589592 // The global accessor is inlined.
590593
@@ -600,7 +603,7 @@ StringOptimization::getStringFromStaticLet(SILValue value) {
600603 } else {
601604 // The global accessor is not inlined, yet.
602605
603- auto *pta = dyn_cast<PointerToAddressInst>(load->getOperand ());
606+ auto *pta = dyn_cast<PointerToAddressInst>(load->getOperand (0 ));
604607 if (!pta)
605608 return StringInfo::unknown ();
606609
@@ -651,7 +654,7 @@ StringOptimization::getStringFromStaticLet(SILValue value) {
651654 // This check is probably not needed, but let's be on the safe side:
652655 // it prevents an infinite recursion if the initializer of the global is
653656 // itself a load of another global, and so on.
654- if (isa<LoadInst>(initVal))
657+ if (isa<LoadInst>(initVal) || isa<LoadBorrowInst>(initVal) )
655658 return StringInfo::unknown ();
656659
657660 return getStringInfo (initVal);
0 commit comments