File tree 1 file changed +11
-9
lines changed
1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -66,18 +66,20 @@ class MemoryBehaviorVisitor
66
66
// If we do not have any more information, just use the general memory
67
67
// behavior implementation.
68
68
auto Behavior = Inst->getMemoryBehavior ();
69
- if (!isLetPointer (V))
69
+ bool ReadOnlyAccess = isLetPointer (V);
70
+
71
+ // If this is a regular read-write access then return the computed memory
72
+ // behavior.
73
+ if (!ReadOnlyAccess)
70
74
return Behavior;
71
75
76
+ // If this is a read-only access to 'let variable' then we can strip away
77
+ // the write access.
72
78
switch (Behavior) {
73
- case MemBehavior::MayHaveSideEffects:
74
- return MemBehavior::MayRead;
75
- case MemBehavior::MayReadWrite:
76
- return MemBehavior::MayRead;
77
- case MemBehavior::MayWrite:
78
- return MemBehavior::None;
79
- default :
80
- return Behavior;
79
+ case MemBehavior::MayHaveSideEffects: return MemBehavior::MayRead;
80
+ case MemBehavior::MayReadWrite: return MemBehavior::MayRead;
81
+ case MemBehavior::MayWrite: return MemBehavior::None;
82
+ default : return Behavior;
81
83
}
82
84
}
83
85
You can’t perform that action at this time.
0 commit comments