File 0171-compiler-Note-non-obvious-behavior-of-beam_ssa-split.patch of Package erlang

From d90b0b28376473e99e5fa4735af7551a2f28d3c2 Mon Sep 17 00:00:00 2001
From: Frej Drejhammar <frej.drejhammar@gmail.com>
Date: Wed, 23 Oct 2024 08:29:56 +0200
Subject: [PATCH] compiler: Note non-obvious behavior of
 beam_ssa:split_blocks/4

beam_ssa:split_blocks/4 does not split and create a new empty block if
the predicate returns true for the first instruction in a block. As I
have gotten tripped up on this for the second time, the first time was
at least a year ago, note this in the function comment.
---
 lib/compiler/src/beam_ssa.erl | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/compiler/src/beam_ssa.erl b/lib/compiler/src/beam_ssa.erl
index 4dd1255201..8bec65a4dc 100644
--- a/lib/compiler/src/beam_ssa.erl
+++ b/lib/compiler/src/beam_ssa.erl
@@ -696,8 +696,10 @@ rename_vars(Rename, Labels, Blocks) when is_map(Rename), is_map(Blocks) ->
 
 %% split_blocks(Labels, Predicate, Blocks0, Count0) -> {Blocks,Count}.
 %%  Call Predicate(Instruction) for each instruction in the given
-%%  blocks. If Predicate/1 returns true, split the block
-%%  before this instruction.
+%%  blocks. If Predicate/1 returns true, split the block before this
+%%  instruction. Note that this function won't create a new empty
+%%  block if the predicate returns true for the first instruction in a
+%%  block.
 
 -spec split_blocks(Labels, Pred, Blocks0, Count0) -> {Blocks,Count} when
       Labels :: [label()],
-- 
2.43.0

openSUSE Build Service is sponsored by