@@ -441,6 +441,8 @@ isStringStoreToIdentifyableObject(SILInstruction *inst) {
441
441
case SILInstructionKind::DeallocStackInst:
442
442
case SILInstructionKind::LoadInst:
443
443
break ;
444
+ case SILInstructionKind::LoadBorrowInst:
445
+ break ;
444
446
case SILInstructionKind::DebugValueInst:
445
447
if (DebugValueInst::hasAddrVal (user))
446
448
break ;
@@ -579,12 +581,13 @@ StringOptimization::getStringFromStaticLet(SILValue value) {
579
581
// %ptr_to_global = apply %addressor()
580
582
// %global_addr = pointer_to_address %ptr_to_global
581
583
// %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 ();
585
588
586
589
SILFunction *initializer = nullptr ;
587
- auto *globalAddr = dyn_cast<GlobalAddrInst>(load->getOperand ());
590
+ auto *globalAddr = dyn_cast<GlobalAddrInst>(load->getOperand (0 ));
588
591
if (globalAddr) {
589
592
// The global accessor is inlined.
590
593
@@ -600,7 +603,7 @@ StringOptimization::getStringFromStaticLet(SILValue value) {
600
603
} else {
601
604
// The global accessor is not inlined, yet.
602
605
603
- auto *pta = dyn_cast<PointerToAddressInst>(load->getOperand ());
606
+ auto *pta = dyn_cast<PointerToAddressInst>(load->getOperand (0 ));
604
607
if (!pta)
605
608
return StringInfo::unknown ();
606
609
@@ -651,7 +654,7 @@ StringOptimization::getStringFromStaticLet(SILValue value) {
651
654
// This check is probably not needed, but let's be on the safe side:
652
655
// it prevents an infinite recursion if the initializer of the global is
653
656
// itself a load of another global, and so on.
654
- if (isa<LoadInst>(initVal))
657
+ if (isa<LoadInst>(initVal) || isa<LoadBorrowInst>(initVal) )
655
658
return StringInfo::unknown ();
656
659
657
660
return getStringInfo (initVal);
0 commit comments