File 2902-compiler-Remove-unnecessary-uses-of-is_exit_instruct.patch of Package erlang
From 20c7b02664220d3655c76c538cd971550979fcdc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org>
Date: Mon, 11 Jan 2021 11:25:49 +0100
Subject: [PATCH 2/8] compiler: Remove unnecessary uses of
is_exit_instruction/1
is_exit_instruction/1 always returns false for call_ext
instructions, and they no longer need special handling since
they're always expanded to call+deallocate+return nowadays.
---
lib/compiler/src/beam_jump.erl | 1 -
lib/compiler/src/beam_trim.erl | 11 ++++-------
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/lib/compiler/src/beam_jump.erl b/lib/compiler/src/beam_jump.erl
index 8738ce718f..da7641cb81 100644
--- a/lib/compiler/src/beam_jump.erl
+++ b/lib/compiler/src/beam_jump.erl
@@ -22,7 +22,6 @@
-module(beam_jump).
-export([module/2,
- is_exit_instruction/1,
remove_unused_labels/1]).
%%% The following optimisations are done:
diff --git a/lib/compiler/src/beam_trim.erl b/lib/compiler/src/beam_trim.erl
index 7dae102181..47223c404a 100644
--- a/lib/compiler/src/beam_trim.erl
+++ b/lib/compiler/src/beam_trim.erl
@@ -400,11 +400,8 @@ frame_size([{call_fun,_}|Is], Safe) ->
frame_size(Is, Safe);
frame_size([{call,_,_}|Is], Safe) ->
frame_size(Is, Safe);
-frame_size([{call_ext,_,_}=I|Is], Safe) ->
- case beam_jump:is_exit_instruction(I) of
- true -> throw(not_possible);
- false -> frame_size(Is, Safe)
- end;
+frame_size([{call_ext,_,_}|Is], Safe) ->
+ frame_size(Is, Safe);
frame_size([{apply,_}|Is], Safe) ->
frame_size(Is, Safe);
frame_size([{bif,_,{f,L},_,_}|Is], Safe) ->
@@ -485,8 +482,8 @@ is_not_used(Y, [{bs_set_position,Src1,Src2}|Is]) ->
is_not_used(Y, Is);
is_not_used(Y, [{call,_,_}|Is]) ->
is_not_used(Y, Is);
-is_not_used(Y, [{call_ext,_,_}=I|Is]) ->
- beam_jump:is_exit_instruction(I) orelse is_not_used(Y, Is);
+is_not_used(Y, [{call_ext,_,_}|Is]) ->
+ is_not_used(Y, Is);
is_not_used(Y, [{call_fun,_}|Is]) ->
is_not_used(Y, Is);
is_not_used(_Y, [{deallocate,_}|_]) ->
--
2.26.2