@@ -161,12 +161,7 @@ extension Function {
161
161
break
162
162
}
163
163
if isProgramTerminationPoint {
164
- // We can ignore any memory writes in a program termination point, because it's not relevant
165
- // for the caller. But we need to consider memory reads, otherwise preceding memory writes
166
- // would be eliminated by dead-store-elimination in the caller. E.g. String initialization
167
- // for error strings which are printed by the program termination point.
168
- // Regarding ownership: a program termination point must not touch any reference counted objects.
169
- return SideEffects . GlobalEffects ( memory: SideEffects . Memory ( read: true ) )
164
+ return SideEffects . GlobalEffects. worstEffects. forProgramTerminationPoints
170
165
}
171
166
var result = SideEffects . GlobalEffects. worstEffects
172
167
switch effectAttribute {
@@ -568,6 +563,18 @@ public struct SideEffects : CustomStringConvertible, NoReflectionChildren {
568
563
return result
569
564
}
570
565
566
+ /// Effects with all effects removed which are not relevant for program termination points (like `fatalError`).
567
+ public var forProgramTerminationPoints : GlobalEffects {
568
+ // We can ignore any memory writes in a program termination point, because it's not relevant
569
+ // for the caller. But we need to consider memory reads, otherwise preceding memory writes
570
+ // would be eliminated by dead-store-elimination in the caller. E.g. String initialization
571
+ // for error strings which are printed by the program termination point.
572
+ // Regarding ownership: a program termination point must not touch any reference counted objects.
573
+ // Also, the deinit-barrier effect is not relevant because functions like `fatalError` and `exit` are
574
+ // not accessing objects (except strings).
575
+ return GlobalEffects ( memory: Memory ( read: memory. read) )
576
+ }
577
+
571
578
public static var worstEffects : GlobalEffects {
572
579
GlobalEffects ( memory: . worstEffects, ownership: . worstEffects, allocates: true , isDeinitBarrier: true )
573
580
}
0 commit comments