@@ -2727,6 +2727,7 @@ static ManagedValue drillIntoComponent(SILGenFunction &SGF,
2727
2727
ManagedValue base,
2728
2728
AccessKind accessKind,
2729
2729
TSanKind tsanKind) {
2730
+ bool isRValue = component.isRValue ();
2730
2731
ManagedValue addr;
2731
2732
if (component.isPhysical ()) {
2732
2733
addr = std::move (component.asPhysical ()).offset (SGF, loc, base, accessKind);
@@ -2737,7 +2738,7 @@ static ManagedValue drillIntoComponent(SILGenFunction &SGF,
2737
2738
2738
2739
if (!SGF.getASTContext ().LangOpts .DisableTsanInoutInstrumentation &&
2739
2740
SGF.getModule ().getOptions ().Sanitize == SanitizerKind::Thread &&
2740
- tsanKind == TSanKind::InoutAccess && !component. isRValue () ) {
2741
+ tsanKind == TSanKind::InoutAccess && !isRValue) {
2741
2742
emitTsanInoutAccess (SGF, loc, addr);
2742
2743
}
2743
2744
@@ -2777,6 +2778,9 @@ RValue SILGenFunction::emitLoadOfLValue(SILLocation loc, LValue &&src,
2777
2778
// Any writebacks should be scoped to after the load.
2778
2779
FormalEvaluationScope scope (*this );
2779
2780
2781
+ auto substFormalType = src.getSubstFormalType ();
2782
+ auto &rvalueTL = getTypeLowering (src.getTypeOfRValue ());
2783
+
2780
2784
ManagedValue addr;
2781
2785
PathComponent &&component =
2782
2786
drillToLastComponent (*this , loc, std::move (src), addr, AccessKind::Read);
@@ -2785,9 +2789,9 @@ RValue SILGenFunction::emitLoadOfLValue(SILLocation loc, LValue &&src,
2785
2789
if (component.isPhysical ()) {
2786
2790
addr = std::move (component.asPhysical ())
2787
2791
.offset (*this , loc, addr, AccessKind::Read);
2788
- return RValue (*this , loc, src. getSubstFormalType () ,
2792
+ return RValue (*this , loc, substFormalType ,
2789
2793
emitLoad (loc, addr.getValue (),
2790
- getTypeLowering (src. getTypeOfRValue ()) , C, IsNotTake,
2794
+ rvalueTL , C, IsNotTake,
2791
2795
isGuaranteedValid));
2792
2796
}
2793
2797
@@ -2886,6 +2890,8 @@ void SILGenFunction::emitAssignLValueToLValue(SILLocation loc, LValue &&src,
2886
2890
return ;
2887
2891
}
2888
2892
2893
+ auto &rvalueTL = getTypeLowering (src.getTypeOfRValue ());
2894
+
2889
2895
auto srcAddr = emitAddressOfLValue (loc, std::move (src), AccessKind::Read)
2890
2896
.getUnmanagedValue ();
2891
2897
auto destAddr = emitAddressOfLValue (loc, std::move (dest), AccessKind::Write)
@@ -2895,9 +2901,7 @@ void SILGenFunction::emitAssignLValueToLValue(SILLocation loc, LValue &&src,
2895
2901
B.createCopyAddr (loc, srcAddr, destAddr, IsNotTake, IsNotInitialization);
2896
2902
} else {
2897
2903
// If there's a semantic conversion necessary, do a load then assign.
2898
- auto loaded = emitLoad (loc, srcAddr, getTypeLowering (src.getTypeOfRValue ()),
2899
- SGFContext (),
2900
- IsNotTake);
2904
+ auto loaded = emitLoad (loc, srcAddr, rvalueTL, SGFContext (), IsNotTake);
2901
2905
loaded.assignInto (*this , loc, destAddr);
2902
2906
}
2903
2907
}
0 commit comments