Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:25
erlang
0157-Eliminate-internal-error-in-sub-pass-ssa_o...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0157-Eliminate-internal-error-in-sub-pass-ssa_opt_ranges.patch of Package erlang
From 0cff4a3636f80c6b2ec037f80f8fe78ea163e2c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Fri, 4 Nov 2022 07:06:40 +0100 Subject: [PATCH] Eliminate internal error in sub pass ssa_opt_ranges Closes #6427 --- lib/compiler/src/beam_ssa_type.erl | 14 ++++++++++- lib/compiler/test/beam_type_SUITE.erl | 34 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/lib/compiler/src/beam_ssa_type.erl b/lib/compiler/src/beam_ssa_type.erl index dc38c23256..01120a6e10 100644 --- a/lib/compiler/src/beam_ssa_type.erl +++ b/lib/compiler/src/beam_ssa_type.erl @@ -920,8 +920,20 @@ update_anno_types_1([#b_var{}=V|As], Ts, Index, ArgTypes) -> case beam_types:meet(T0, T1) of any -> update_anno_types_1(As, Ts, Index + 1, ArgTypes); + none -> + %% This instruction will never be reached. This happens when + %% compiling code such as the following: + %% + %% f(X) when is_integer(X), 0 =< X, X < 64 -> + %% (X = bnot X) + 1. + %% + %% The main type optimization sub pass will not find out + %% that `(X = bnot X)` will never succeed and that the `+` + %% operator is never executed, but this sub pass will. + %% This happens very rarely; therefore, don't bother removing + %% the unreachable instruction. + update_anno_types_1(As, Ts, Index + 1, ArgTypes); T -> - true = T =/= none, %Assertion. update_anno_types_1(As, Ts, Index + 1, ArgTypes#{Index => T}) end; update_anno_types_1([_|As], Ts, Index, ArgTypes) -> diff --git a/lib/compiler/test/beam_type_SUITE.erl b/lib/compiler/test/beam_type_SUITE.erl index 8e0e964185..35ecdaa4a7 100644 --- a/lib/compiler/test/beam_type_SUITE.erl +++ b/lib/compiler/test/beam_type_SUITE.erl @@ -119,6 +119,11 @@ integers(_Config) -> -693 = do_integers_9(id(7), id(1)), + {'EXIT',{{badmatch,42},_}} = catch do_integers_13(-43), + {'EXIT',{{badmatch,0},_}} = catch do_integers_13(-1), + {'EXIT',{{badmatch,-1},_}} = catch do_integers_13(0), + {'EXIT',{{badmatch,-18},_}} = catch do_integers_13(17), + ok. do_integers_1(B0) -> @@ -202,6 +207,35 @@ do_integers_11(V) -> do_integers_9(X, Y) -> X * (-100 bor (Y band 1)). +%% GH-6427. +do_integers_13(X) -> + try do_integers_13_1(<<X>>) of + _ -> error(should_fail) + catch + C:R:_ -> + try do_integers_13_2(X) of + _ -> error(should_fail) + catch + C:R:_ -> + try do_integers_13_3(X) of + _ -> error(should_fail) + catch + C:R:Stk -> + erlang:raise(C, R, Stk) + end + end + end. + +do_integers_13_1(<<X>>) -> + <<(X = bnot X)>>. + +do_integers_13_2(X) when is_integer(X), -64 < X, X < 64 -> + (X = bnot X) + 1. + +do_integers_13_3(X) when is_integer(X), -64 < X, X < 64 -> + X = bnot X, + X + 1. + numbers(_Config) -> Int = id(42), true = is_integer(Int), -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor