aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2018-08-10 12:14:49 +0200
committerGitHub <[email protected]>2018-08-10 12:14:49 +0200
commit77d307e6c3e705e14843101d4c5348c6c079ace0 (patch)
treeecca1ae568abdf6c3a2d57bff6b6f5f10cd07064 /lib/compiler/src
parente030c276981d19de5d02dd84265a292516bb7df7 (diff)
parent2e40d8d1c51ad1c3d3750490ecac6b290233f085 (diff)
downloadotp-77d307e6c3e705e14843101d4c5348c6c079ace0.tar.gz
otp-77d307e6c3e705e14843101d4c5348c6c079ace0.tar.bz2
otp-77d307e6c3e705e14843101d4c5348c6c079ace0.zip
Merge pull request #1911 from bjorng/bjorn/compiler/binary-syntax/ERL-689/OTP-15219
Fix bug in binary matching
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/beam_bsm.erl13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/compiler/src/beam_bsm.erl b/lib/compiler/src/beam_bsm.erl
index 1c8e0e9854..abc6e96c85 100644
--- a/lib/compiler/src/beam_bsm.erl
+++ b/lib/compiler/src/beam_bsm.erl
@@ -310,7 +310,18 @@ btb_reaches_match_2([{test,bs_start_match2,{f,F},Live,[Bin,_],Ctx}|Is],
end;
btb_reaches_match_2([{test,_,{f,F},Ss}=I|Is], Regs, D0) ->
btb_ensure_not_used(Ss, I, Regs),
- D = btb_follow_branch(F, Regs, D0),
+ D1 = btb_follow_branch(F, Regs, D0),
+ D = case Is of
+ [{bs_context_to_binary,_}|_] ->
+ %% bs_context_to_binary following a test instruction
+ %% probably needs the current position to be saved as
+ %% the new start position, but we can't be sure.
+ %% Therefore, conservatively disable the optimization
+ %% (instead of forcing a saving of the position).
+ D1#btb{must_save=true,must_not_save=true};
+ _ ->
+ D1
+ end,
btb_reaches_match_1(Is, Regs, D);
btb_reaches_match_2([{test,_,{f,F},_,Ss,_}=I|Is], Regs, D0) ->
btb_ensure_not_used(Ss, I, Regs),