File 0197-Fix-unsafe-optimization-of-try.after.patch of Package erlang

From 34ee7d1b0becdcf324db2a9e2ef24750b16021f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Fri, 13 Jan 2023 05:21:34 +0100
Subject: [PATCH] Fix unsafe optimization of try...after

Closes #6660
---
 lib/compiler/src/beam_ssa_opt.erl    |  8 +++++++-
 lib/compiler/test/bs_match_SUITE.erl | 15 +++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/lib/compiler/src/beam_ssa_opt.erl b/lib/compiler/src/beam_ssa_opt.erl
index 24a6465078..ad8db602d2 100644
--- a/lib/compiler/src/beam_ssa_opt.erl
+++ b/lib/compiler/src/beam_ssa_opt.erl
@@ -1654,13 +1654,19 @@ sink_try_is(Is) ->
 sink_try_is_1([#b_set{op=kill_try_tag}=Kill | Is], Acc) ->
     [Kill | reverse(Acc, Is)];
 sink_try_is_1([I | Is], Acc) ->
-    case beam_ssa:no_side_effect(I) of
+    case is_safe_sink_try(I) of
         true -> sink_try_is_1(Is, [I | Acc]);
         false -> reverse(Acc, [I | Is])
     end;
 sink_try_is_1([], Acc) ->
     reverse(Acc).
 
+is_safe_sink_try(#b_set{op=Op}=I) ->
+    case Op of
+        bs_extract -> false;
+        _ -> beam_ssa:no_side_effect(I)
+    end.
+
 %% Does a strength reduction of try/catch and catch.
 %%
 %% In try/catch constructs where the expression is restricted
-- 
2.35.3

openSUSE Build Service is sponsored by