@@ -161,12 +161,7 @@ extension Function {
161161 break
162162 }
163163 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
170165 }
171166 var result = SideEffects . GlobalEffects. worstEffects
172167 switch effectAttribute {
@@ -568,6 +563,18 @@ public struct SideEffects : CustomStringConvertible, NoReflectionChildren {
568563 return result
569564 }
570565
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+
571578 public static var worstEffects : GlobalEffects {
572579 GlobalEffects ( memory: . worstEffects, ownership: . worstEffects, allocates: true , isDeinitBarrier: true )
573580 }
0 commit comments