summaryrefslogtreecommitdiff
path: root/lib/compiler/test/beam_validator_SUITE_data
diff options
context:
space:
mode:
authorErlang/OTP <otp@erlang.org>2009-11-20 14:54:40 +0000
committerErlang/OTP <otp@erlang.org>2009-11-20 14:54:40 +0000
commit84adefa331c4159d432d22840663c38f155cd4c1 (patch)
treebff9a9c66adda4df2106dfd0e5c053ab182a12bd /lib/compiler/test/beam_validator_SUITE_data
downloaderlang-84adefa331c4159d432d22840663c38f155cd4c1.tar.gz
The R13B03 release.OTP_R13B03
Diffstat (limited to 'lib/compiler/test/beam_validator_SUITE_data')
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/accessing_tags.S31
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/bad_catch_try.S168
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/bad_dsetel.S52
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/bin_aligned.S47
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/bin_match.S64
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/call_last.S71
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/cons.S38
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/dead_code.S48
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/erl_prim_loader.beambin0 -> 17460 bytes
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/freg_range.S53
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/freg_state.S59
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/freg_uninit.S32
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/illegal_instruction.S26
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/merge_undefined.S84
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/no_exception_in_catch.S209
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/overwrite_catchtag.S38
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/overwrite_trytag.S53
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/stack.S89
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/state_after_fault_in_catch.S58
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/undef_label.S22
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/uninit.S48
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/unsafe_catch.S67
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/xrange.S44
-rw-r--r--lib/compiler/test/beam_validator_SUITE_data/yrange.S76
24 files changed, 1477 insertions, 0 deletions
diff --git a/lib/compiler/test/beam_validator_SUITE_data/accessing_tags.S b/lib/compiler/test/beam_validator_SUITE_data/accessing_tags.S
new file mode 100644
index 0000000000..2728a2fa32
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/accessing_tags.S
@@ -0,0 +1,31 @@
+{module, accessing_tags}. %% version = 0
+
+{exports, [{foo,1},{bar,1}]}.
+
+{attributes, []}.
+
+{function, foo, 1, 2}.
+ {label,1}.
+ {func_info,{atom,accessing_tags},{atom,foo},1}.
+ {label,2}.
+ {allocate,1,1}.
+ {'catch',{y,0},{f,3}}.
+ {move,{y,0},{x,0}}. %Retrieve the catch tag.
+ {call,1,{f,2}}.
+ {label,3}.
+ {catch_end,{y,0}}.
+ {deallocate,1}.
+ return.
+
+{function, bar, 1, 5}.
+ {label,4}.
+ {func_info,{atom,accessing_tags},{atom,bar},1}.
+ {label,5}.
+ {allocate,1,1}.
+ {'try',{y,0},{f,6}}.
+ {move,{y,0},{x,0}}. %Retrieve the try tag.
+ {call,5,{f,2}}.
+ {label,6}.
+ {catch_end,{y,0}}.
+ {deallocate,1}.
+ return.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/bad_catch_try.S b/lib/compiler/test/beam_validator_SUITE_data/bad_catch_try.S
new file mode 100644
index 0000000000..2a53f0dd93
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/bad_catch_try.S
@@ -0,0 +1,168 @@
+{module, bad_catch_try}. %% version = 0
+
+{exports, [{bad_1,1},
+ {bad_2,1},
+ {bad_3,1},
+ {bad_4,1},
+ {bad_5,1},
+ {bad_6,1},
+ {foo,1},
+ {module_info,0},
+ {module_info,1}]}.
+
+{attributes, []}.
+
+{labels, 31}.
+
+
+{function, bad_1, 1, 2}.
+ {label,1}.
+ {func_info,{atom,bad_catch_try},{atom,bad_1},1}.
+ {label,2}.
+ {allocate,1,1}.
+ {'catch',{x,0},{f,3}}.
+ {call,1,{f,26}}.
+ {label,3}.
+ {catch_end,{x,0}}.
+ {test,is_tuple,{f,4},[{x,0}]}.
+ {test,test_arity,{f,4},[{x,0},2]}.
+ {get_tuple_element,{x,0},0,{x,1}}.
+ {test,is_eq_exact,{f,4},[{x,1},{atom,'EXIT'}]}.
+ {move,{atom,error},{x,0}}.
+ {deallocate,1}.
+ return.
+ {label,4}.
+ {move,{atom,ok},{x,0}}.
+ {deallocate,1}.
+ return.
+
+
+{function, bad_2, 1, 6}.
+ {label,5}.
+ {func_info,{atom,bad_catch_try},{atom,bad_2},1}.
+ {label,6}.
+ {allocate,1,1}.
+ {'catch',{y,0},{f,7}}.
+ {call,1,{f,26}}.
+ {label,7}.
+ {catch_end,{x,9}}.
+ {test,is_tuple,{f,8},[{x,0}]}.
+ {test,test_arity,{f,8},[{x,0},2]}.
+ {get_tuple_element,{x,0},0,{x,1}}.
+ {test,is_eq_exact,{f,8},[{x,1},{atom,'EXIT'}]}.
+ {move,{atom,error},{x,0}}.
+ {deallocate,1}.
+ return.
+ {label,8}.
+ {move,{atom,ok},{x,0}}.
+ {deallocate,1}.
+ return.
+
+
+{function, bad_3, 1, 10}.
+ {label,9}.
+ {func_info,{atom,bad_catch_try},{atom,bad_3},1}.
+ {label,10}.
+ {allocate,1,1}.
+ {'catch',{y,0},{f,11}}.
+ {call,1,{f,26}}.
+ {label,11}.
+ {move,{atom,kalle},{y,1}}.
+ {catch_end,{y,1}}.
+ {test,is_tuple,{f,12},[{x,0}]}.
+ {test,test_arity,{f,12},[{x,0},2]}.
+ {get_tuple_element,{x,0},0,{x,1}}.
+ {test,is_eq_exact,{f,12},[{x,1},{atom,'EXIT'}]}.
+ {move,{atom,error},{x,0}}.
+ {deallocate,1}.
+ return.
+ {label,12}.
+ {move,{atom,ok},{x,0}}.
+ {deallocate,1}.
+ return.
+
+
+{function, bad_4, 1, 14}.
+ {label,13}.
+ {func_info,{atom,bad_catch_try},{atom,bad_4},1}.
+ {label,14}.
+ {allocate_zero,1,1}.
+ {'try',{x,0},{f,15}}.
+ {call,1,{f,26}}.
+ {try_end,{y,0}}.
+ {move,{atom,ok},{x,0}}.
+ {jump,{f,16}}.
+ {label,15}.
+ {try_case,{y,0}}.
+ {test,is_ne_exact,{f,16},[{x,0},{atom,error}]}.
+ {bif,raise,{f,0},[{x,2},{x,1}],{x,0}}.
+ {'%live',1}.
+ {label,16}.
+ {deallocate,1}.
+ return.
+
+
+{function, bad_5, 1, 18}.
+ {label,17}.
+ {func_info,{atom,bad_catch_try},{atom,bad_5},1}.
+ {label,18}.
+ {allocate_zero,1,1}.
+ {'try',{y,0},{f,19}}.
+ {call,1,{f,26}}.
+ {try_end,{y,0}}.
+ {move,{atom,ok},{x,0}}.
+ {jump,{f,20}}.
+ {label,19}.
+ {move,{x,0},{y,1}}.
+ {try_case,{y,1}}.
+ {test,is_ne_exact,{f,20},[{x,0},{atom,error}]}.
+ {bif,raise,{f,0},[{x,2},{x,1}],{x,0}}.
+ {'%live',1}.
+ {label,20}.
+ {deallocate,1}.
+ return.
+
+
+{function, bad_6, 1, 22}.
+ {label,21}.
+ {func_info,{atom,bad_catch_try},{atom,bad_6},1}.
+ {label,22}.
+ {allocate_zero,1,1}.
+ {'try',{y,0},{f,23}}.
+ {call,1,{f,26}}.
+ {move,{integer,1},{y,1}}.
+ {try_end,{y,1}}.
+ {move,{atom,ok},{x,0}}.
+ {jump,{f,24}}.
+ {label,23}.
+ {try_case,{y,0}}.
+ {test,is_ne_exact,{f,24},[{x,0},{atom,error}]}.
+ {bif,raise,{f,0},[{x,2},{x,1}],{x,0}}.
+ {'%live',1}.
+ {label,24}.
+ {deallocate,1}.
+ return.
+
+
+{function, foo, 1, 26}.
+ {label,25}.
+ {func_info,{atom,bad_catch_try},{atom,foo},1}.
+ {label,26}.
+ return.
+
+
+{function, module_info, 0, 28}.
+ {label,27}.
+ {func_info,{atom,bad_catch_try},{atom,module_info},0}.
+ {label,28}.
+ {move,{atom,bad_catch_try},{x,0}}.
+ {call_ext_only,1,{extfunc,erlang,get_module_info,1}}.
+
+
+{function, module_info, 1, 30}.
+ {label,29}.
+ {func_info,{atom,bad_catch_try},{atom,module_info},1}.
+ {label,30}.
+ {move,{x,0},{x,1}}.
+ {move,{atom,bad_catch_try},{x,0}}.
+ {call_ext_only,2,{extfunc,erlang,get_module_info,2}}.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/bad_dsetel.S b/lib/compiler/test/beam_validator_SUITE_data/bad_dsetel.S
new file mode 100644
index 0000000000..279b2fa97f
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/bad_dsetel.S
@@ -0,0 +1,52 @@
+{module, t}. %% version = 0
+
+{exports, [{module_info,0},{module_info,1},{t,1}]}.
+
+{attributes, []}.
+
+{labels, 8}.
+
+
+{function, t, 1, 2}.
+ {label,1}.
+ {func_info,{atom,t},{atom,t},1}.
+ {label,2}.
+ {test,is_tuple,{f,3},[{x,0}]}.
+ {test,test_arity,{f,3},[{x,0},7]}.
+ {get_tuple_element,{x,0},0,{x,1}}.
+ {test,is_eq_exact,{f,3},[{x,1},{atom,r}]}.
+ {allocate,0,1}.
+ {move,{x,0},{x,1}}.
+ {move,{integer,1},{x,2}}.
+ {move,{integer,3},{x,0}}.
+ {call_ext,3,{extfunc,erlang,setelement,3}}.
+ {test_heap,6,1}.
+ {put_string,3,{string,"abc"},{x,1}}.
+ {set_tuple_element,{x,1},{x,0},1}.
+ {'%live',1}.
+ {deallocate,0}.
+ return.
+ {label,3}.
+ {test_heap,3,0}.
+ {put_tuple,2,{x,0}}.
+ {put,{atom,badrecord}}.
+ {put,{atom,r}}.
+ {'%live',1}.
+ {call_ext_only,1,{extfunc,erlang,error,1}}.
+
+
+{function, module_info, 0, 5}.
+ {label,4}.
+ {func_info,{atom,t},{atom,module_info},0}.
+ {label,5}.
+ {move,{atom,t},{x,0}}.
+ {call_ext_only,1,{extfunc,erlang,get_module_info,1}}.
+
+
+{function, module_info, 1, 7}.
+ {label,6}.
+ {func_info,{atom,t},{atom,module_info},1}.
+ {label,7}.
+ {move,{x,0},{x,1}}.
+ {move,{atom,t},{x,0}}.
+ {call_ext_only,2,{extfunc,erlang,get_module_info,2}}.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/bin_aligned.S b/lib/compiler/test/beam_validator_SUITE_data/bin_aligned.S
new file mode 100644
index 0000000000..2f353fbd25
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/bin_aligned.S
@@ -0,0 +1,47 @@
+{module, t}. %% version = 0
+
+{exports, [{decode,1},{module_info,0},{module_info,1}]}.
+
+{attributes, []}.
+
+{labels, 7}.
+
+
+{function, decode, 1, 2}.
+ {label,1}.
+ {func_info,{atom,t},{atom,decode},1}.
+ {label,2}.
+ {move,{integer,1},{x,1}}.
+ {bif,size,{f,0},[{x,0}],{x,2}}.
+ {bs_add,{f,0},[{x,1},{x,2},1],{x,1}}.
+ {bs_init2,{f,0},{x,1},0,1,{field_flags,[]},{x,1}}.
+ {bs_put_integer,{f,0},
+ {integer,3},
+ 1,
+ {field_flags,[aligned,unsigned,big]},
+ {integer,0}}.
+ {bs_put_binary,{f,0},{atom,all},8,{field_flags,[unsigned,big]},{x,0}}.
+ {bs_put_integer,{f,0},
+ {integer,5},
+ 1,
+ {field_flags,[unsigned,big,aligned]},
+ {integer,0}}.
+ {move,{x,1},{x,0}}.
+ return.
+
+
+{function, module_info, 0, 4}.
+ {label,3}.
+ {func_info,{atom,t},{atom,module_info},0}.
+ {label,4}.
+ {move,{atom,t},{x,0}}.
+ {call_ext_only,1,{extfunc,erlang,get_module_info,1}}.
+
+
+{function, module_info, 1, 6}.
+ {label,5}.
+ {func_info,{atom,t},{atom,module_info},1}.
+ {label,6}.
+ {move,{x,0},{x,1}}.
+ {move,{atom,t},{x,0}}.
+ {call_ext_only,2,{extfunc,erlang,get_module_info,2}}.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/bin_match.S b/lib/compiler/test/beam_validator_SUITE_data/bin_match.S
new file mode 100644
index 0000000000..96df0f7933
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/bin_match.S
@@ -0,0 +1,64 @@
+{module, bin_match}. %% version = 0
+
+{exports, [{t,1}]}.
+
+{attributes, []}.
+
+{labels, 8}.
+
+
+{function, t, 1, 2}.
+ {label,1}.
+ {func_info,{atom,t},{atom,t},1}.
+ {label,2}.
+%% {test,bs_start_match,{f,1},[{x,0}]}.
+ {bs_save,0}.
+ {test,bs_get_integer,
+ {f,3},
+ [{integer,8},1,{field_flags,[aligned,unsigned,big]},{x,1}]}.
+ {test,bs_get_integer,
+ {f,3},
+ [{integer,8},1,{field_flags,[aligned,unsigned,big]},{x,2}]}.
+ {test,bs_test_tail,{f,3},[0]}.
+ {test_heap,3,3}.
+ {put_tuple,2,{x,0}}.
+ {put,{x,1}}.
+ {put,{x,2}}.
+ {'%live',1}.
+ return.
+ {label,3}.
+ {bs_restore,0}.
+ {test,bs_get_integer,
+ {f,1},
+ [{integer,32},1,{field_flags,[aligned,unsigned,big]},{x,1}]}.
+ {test,bs_test_tail,{f,1},[0]}.
+ {move,{x,1},{x,0}}.
+ return.
+
+{function, x, 1, 5}.
+ {label,4}.
+ {func_info,{atom,t},{atom,x},1}.
+ {label,5}.
+ {test,bs_start_match,{f,4},[{x,0}]}.
+ {bs_save,0}.
+ {test,bs_get_integer,
+ {f,6},
+ [{integer,8},1,{field_flags,[aligned,unsigned,big]},{x,1}]}.
+ {test,bs_get_integer,
+ {f,6},
+ [{integer,8},1,{field_flags,[aligned,unsigned,big]},{x,2}]}.
+ {test,bs_test_tail,{f,6},[0]}.
+ {test_heap,3,3}.
+ {put_tuple,2,{x,0}}.
+ {put,{x,1}}.
+ {put,{x,2}}.
+ {'%live',1}.
+ return.
+ {label,6}.
+ {bs_restore,1}.
+ {test,bs_get_integer,
+ {f,4},
+ [{integer,32},1,{field_flags,[aligned,unsigned,big]},{x,1}]}.
+ {test,bs_test_tail,{f,4},[0]}.
+ {move,{x,1},{x,0}}.
+ return.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/call_last.S b/lib/compiler/test/beam_validator_SUITE_data/call_last.S
new file mode 100644
index 0000000000..827b6c0ae6
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/call_last.S
@@ -0,0 +1,71 @@
+{module, call_last}. %% version = 0
+
+{exports, [{a,1},{b,1},{bar,1},{foo,1},{module_info,0},{module_info,1}]}.
+
+{attributes, []}.
+
+{labels, 13}.
+
+
+{function, a, 1, 2}.
+ {label,1}.
+ {func_info,{atom,t},{atom,a},1}.
+ {label,2}.
+ {allocate,1,1}.
+ {move,{x,0},{y,0}}.
+ {bif,'+',{f,0},[{y,0},{integer,1}],{x,0}}.
+ {'%live',1}.
+ {call,1,{f,6}}.
+ {bif,'+',{f,0},[{y,0},{integer,2}],{x,0}}.
+ {'%live',1}.
+ {call_last,1,{f,8},2}.
+
+
+{function, b, 1, 4}.
+ {label,3}.
+ {func_info,{atom,t},{atom,b},1}.
+ {label,4}.
+ {allocate,1,1}.
+ {move,{x,0},{y,0}}.
+ {bif,'+',{f,0},[{y,0},{integer,1}],{x,0}}.
+ {'%live',1}.
+ {call,1,{f,6}}.
+ {move,{y,0},{x,1}}.
+ {move,{integer,0},{x,0}}.
+ {call_ext_last,2,{extfunc,lists,seq,2},2}.
+
+
+{function, foo, 1, 6}.
+ {label,5}.
+ {func_info,{atom,t},{atom,foo},1}.
+ {label,6}.
+ {move,{x,0},{x,1}}.
+ {move,{atom,glurf},{x,0}}.
+ {call_ext_only,2,{extfunc,erlang,put,2}}.
+
+
+{function, bar, 1, 8}.
+ {label,7}.
+ {func_info,{atom,t},{atom,bar},1}.
+ {label,8}.
+ {bif,get,{f,0},[{atom,glurf}],{x,1}}.
+ {bif,'+',{f,0},[{x,0},{x,1}],{x,0}}.
+ {'%live',1}.
+ return.
+
+
+{function, module_info, 0, 10}.
+ {label,9}.
+ {func_info,{atom,t},{atom,module_info},0}.
+ {label,10}.
+ {move,{atom,t},{x,0}}.
+ {call_ext_only,1,{extfunc,erlang,get_module_info,1}}.
+
+
+{function, module_info, 1, 12}.
+ {label,11}.
+ {func_info,{atom,t},{atom,module_info},1}.
+ {label,12}.
+ {move,{x,0},{x,1}}.
+ {move,{atom,t},{x,0}}.
+ {call_ext_only,2,{extfunc,erlang,get_module_info,2}}.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/cons.S b/lib/compiler/test/beam_validator_SUITE_data/cons.S
new file mode 100644
index 0000000000..83b9daa6f5
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/cons.S
@@ -0,0 +1,38 @@
+{module, cons}. %% version = 0
+
+{exports, [{foo,1},{module_info,0},{module_info,1}]}.
+
+{attributes, []}.
+
+{labels, 7}.
+
+
+{function, foo, 1, 2}.
+ {label,1}.
+ {func_info,{atom,cons},{atom,foo},1}.
+ {label,2}.
+% {test,is_nonempty_list,{f,1},[{x,0}]}.
+ {test_heap,3,1}.
+ {get_list,{x,0},{x,1},{x,2}}. % <= {bad_type,{needed,cons},{actual,term}}
+ {put_tuple,2,{x,0}}.
+ {put,{x,1}}.
+ {put,{x,2}}.
+ {'%live',1}.
+ return.
+
+
+{function, module_info, 0, 4}.
+ {label,3}.
+ {func_info,{atom,cons},{atom,module_info},0}.
+ {label,4}.
+ {move,{atom,cons},{x,0}}.
+ {call_ext_only,1,{extfunc,erlang,get_module_info,1}}.
+
+
+{function, module_info, 1, 6}.
+ {label,5}.
+ {func_info,{atom,cons},{atom,module_info},1}.
+ {label,6}.
+ {move,{x,0},{x,1}}.
+ {move,{atom,cons},{x,0}}.
+ {call_ext_only,2,{extfunc,erlang,get_module_info,2}}.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/dead_code.S b/lib/compiler/test/beam_validator_SUITE_data/dead_code.S
new file mode 100644
index 0000000000..f964f98fba
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/dead_code.S
@@ -0,0 +1,48 @@
+{module, dead_code}. %% version = 0
+
+{exports, [{execute,0},{module_info,0},{module_info,1}]}.
+
+{attributes, []}.
+
+{labels, 10}.
+
+
+{function, execute, 0, 2}.
+ {label,1}.
+ {func_info,{atom,dead_code},{atom,execute},0}.
+ {label,2}.
+ {allocate,0,0}.
+ {'%live',0}.
+ {call_ext,0,{extfunc,foo,fie,0}}.
+ {test,is_ne,{f,4},[{x,0},{integer,0}]}.
+ {test,is_ne,{f,4},[{x,0},{integer,1}]}.
+ {label,3}.
+ {test,is_ne,{f,4},[{x,0},{integer,2}]}.
+ {test,is_ne,{f,4},[{x,0},{integer,3}]}.
+ {case_end,{x,0}}.
+ {label,4}.
+ {move,{atom,ok},{x,0}}.
+ {'%live',1}.
+ {deallocate,0}.
+ return.
+ {'%','Moved code'}.
+ {label,5}.
+ {case_end,{x,0}}.
+
+
+{function, module_info, 0, 7}.
+ {label,6}.
+ {func_info,{atom,dead_code},{atom,module_info},0}.
+ {label,7}.
+ {move,nil,{x,0}}.
+ {'%live',1}.
+ return.
+
+
+{function, module_info, 1, 9}.
+ {label,8}.
+ {func_info,{atom,dead_code},{atom,module_info},1}.
+ {label,9}.
+ {move,nil,{x,0}}.
+ {'%live',1}.
+ return.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/erl_prim_loader.beam b/lib/compiler/test/beam_validator_SUITE_data/erl_prim_loader.beam
new file mode 100644
index 0000000000..dd58a88e42
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/erl_prim_loader.beam
Binary files differ
diff --git a/lib/compiler/test/beam_validator_SUITE_data/freg_range.S b/lib/compiler/test/beam_validator_SUITE_data/freg_range.S
new file mode 100644
index 0000000000..ee583a923e
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/freg_range.S
@@ -0,0 +1,53 @@
+{module, freg_range}. %% version = 0
+
+{exports, [{module_info,0},{module_info,1},{prod,2},{sum,2},{sum_prod,3}]}.
+
+{attributes, []}.
+
+{labels, 8}.
+
+
+{function, sum_1, 2, 2}.
+ {label,1}.
+ {func_info,{atom,t},{atom,sum_1},2}.
+ {label,2}.
+ fclearerror.
+ {bif,fadd,{f,0},[{fr,-1},{fr,1}],{fr,0}}.
+ {'%live',1}.
+ return.
+
+
+{function, sum_2, 2, 4}.
+ {label,3}.
+ {func_info,{atom,t},{atom,sum_2},2}.
+ {label,4}.
+ {fconv,{x,0},{fr,0}}.
+ fclearerror.
+ {bif,fadd,{f,0},[{fr,0},{fr,1024}],{fr,0}}.
+ {'%live',1}.
+ return.
+
+
+{function, sum_3, 2, 6}.
+ {label,5}.
+ {func_info,{atom,t},{atom,sum_3},2}.
+ {label,6}.
+ {fconv,{x,0},{fr,0}}.
+ {fconv,{x,1},{fr,1}}.
+ fclearerror.
+ {bif,fadd,{f,0},[{fr,0},{fr,1}],{fr,-1}}.
+ {'%live',1}.
+ return.
+
+
+{function, sum_4, 2, 8}.
+ {label,7}.
+ {func_info,{atom,t},{atom,sum_4},2}.
+ {label,8}.
+ {fconv,{x,0},{fr,0}}.
+ {fconv,{x,1},{fr,1}}.
+ fclearerror.
+ {bif,fadd,{f,0},[{fr,0},{fr,1}],{fr,1024}}.
+ {'%live',1}.
+ return.
+
diff --git a/lib/compiler/test/beam_validator_SUITE_data/freg_state.S b/lib/compiler/test/beam_validator_SUITE_data/freg_state.S
new file mode 100644
index 0000000000..ff4d7548ae
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/freg_state.S
@@ -0,0 +1,59 @@
+{module, freg_state}. %% version = 0
+
+{exports, []}.
+
+{attributes, []}.
+
+
+{function, sum_1, 2, 2}.
+ {label,1}.
+ {func_info,{atom,t},{atom,sum_1},2}.
+ {label,2}.
+ {fconv,{x,0},{fr,0}}.
+ {fconv,{x,1},{fr,1}}.
+ {bif,fmul,{f,0},[{fr,0},{fr,1}],{fr,0}}.
+ {'%live',1}.
+ return.
+
+{function, sum_2, 2, 4}.
+ {label,3}.
+ {func_info,{atom,t},{atom,sum_2},2}.
+ {label,4}.
+ {fconv,{x,0},{fr,0}}.
+ {fconv,{x,1},{fr,1}}.
+ fclearerror.
+ {bif,fmul,{f,0},[{fr,0},{fr,1}],{fr,0}}.
+ {fmove,{fr,0},{x,0}}.
+ {'%live',1}.
+ return.
+
+{function, sum_3, 2, 6}.
+ {label,5}.
+ {func_info,{atom,t},{atom,sum_3},2}.
+ {label,6}.
+ {fconv,{x,0},{fr,0}}.
+ {fconv,{x,1},{fr,1}}.
+ fclearerror.
+ {bif,fmul,{f,0},[{fr,0},{fr,1}],{fr,0}}.
+ {bif,'-',{f,0},[{x,1},{x,0}],{x,1}}.
+ {fcheckerror,{f,0}}.
+ {fmove,{fr,0},{x,0}}.
+ {'%live',1}.
+ return.
+
+{function, sum_4, 2, 8}.
+ {label,6}.
+ {func_info,{atom,t},{atom,sum_4},2}.
+ {label,8}.
+ {fcheckerror,{f,0}}.
+ {fmove,{fr,0},{x,0}}.
+ {'%live',1}.
+ return.
+
+{function, sum_5, 2, 10}.
+ {label,9}.
+ {func_info,{atom,t},{atom,sum_5},2}.
+ {label,10}.
+ fclearerror.
+ fclearerror.
+ return.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/freg_uninit.S b/lib/compiler/test/beam_validator_SUITE_data/freg_uninit.S
new file mode 100644
index 0000000000..f8d805d9ec
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/freg_uninit.S
@@ -0,0 +1,32 @@
+{module, freg_uninit}. %% version = 0
+
+{exports, []}.
+
+{attributes, []}.
+
+{labels, 8}.
+
+
+{function, sum_1, 2, 2}.
+ {label,1}.
+ {func_info,{atom,t},{atom,sum_1},2}.
+ {label,2}.
+ {fconv,{x,0},{fr,0}}.
+ fclearerror.
+ {bif,fadd,{f,0},[{fr,0},{fr,1}],{fr,0}}.
+ {'%live',1}.
+ return.
+
+
+{function, sum_2, 2, 4}.
+ {label,3}.
+ {func_info,{atom,t},{atom,sum_2},2}.
+ {label,4}.
+ {fconv,{x,0},{fr,0}}.
+ {fconv,{x,1},{fr,1}}.
+ fclearerror.
+ {fcheckerror,{f,0}}.
+ {call,2,{f,8}}.
+ {bif,fadd,{f,0},[{fr,0},{fr,1}],{fr,0}}.
+ {'%live',1}.
+ return.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/illegal_instruction.S b/lib/compiler/test/beam_validator_SUITE_data/illegal_instruction.S
new file mode 100644
index 0000000000..d6e92abc71
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/illegal_instruction.S
@@ -0,0 +1,26 @@
+{module, illegal_instruction}. %% version = 0
+
+{exports, []}.
+
+{attributes, []}.
+
+{labels, 7}.
+
+
+{function, t, 1, 2}.
+ {label,1}.
+ {func_info,{atom,illegal_instruction},{atom,t},1}.
+ {label,2}.
+ {my_illegal_instruction,{x,0}}.
+ return.
+
+
+{function, x, 1, 4}.
+ {label,3}.
+ bad_func_info.
+ {label,4}.
+ {my_illegal_instruction,{x,0}}.
+ return.
+
+{function, y, 0, 17}.
+ \ No newline at end of file
diff --git a/lib/compiler/test/beam_validator_SUITE_data/merge_undefined.S b/lib/compiler/test/beam_validator_SUITE_data/merge_undefined.S
new file mode 100644
index 0000000000..3d76127824
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/merge_undefined.S
@@ -0,0 +1,84 @@
+{module, merge_undefined}. %% version = 0
+
+{exports, [{bar,2},{foo,1},{handle_call,2},{module_info,0},{module_info,1}]}.
+
+{attributes, []}.
+
+{labels, 15}.
+
+
+{function, handle_call, 2, 2}.
+ {label,1}.
+ {func_info,{atom,t},{atom,handle_call},2}.
+ {label,2}.
+ {test,is_atom,{f,1},[{x,0}]}.
+ {select_val,{x,0},{f,1},{list,[{atom,gurka},{f,3},{atom,delete},{f,4}]}}.
+ {label,3}.
+ {allocate_heap,2,6,2}.
+ %% The Y registers are not initialized here.
+ {test,is_eq_exact,{f,5},[{x,0},{atom,ok}]}.
+ {move,{atom,nisse},{x,0}}.
+ {call_ext,1,{extfunc,erlang,exit,1}}.
+ {label,4}.
+ {allocate_heap,1,6,2}.
+ {move,{x,1},{y,0}}.
+ {put_string,2,{string,"~p"},{x,0}}.
+ {put_list,{y,0},nil,{x,1}}.
+ {'%live',2}.
+ {call_ext,2,{extfunc,io,format,2}}.
+ {test,is_ne_exact,{f,6},[{x,0},{atom,ok}]}.
+ {label,5}.
+ {move,{atom,logReader},{x,1}}.
+ {move,{atom,console},{x,0}}.
+ {call_ext,2,{extfunc,debug,filter,2}}.
+ {test_heap,14,1}.
+ {put_list,{atom,logReader},nil,{x,1}}.
+ {put_list,{atom,console},{x,1},{x,1}}.
+ {put_tuple,3,{x,2}}.
+ {put,{atom,debug}}.
+ {put,{atom,filter}}.
+ {put,{x,1}}.
+ {put_tuple,2,{x,1}}.
+ {put,{x,2}}.
+ {put,{x,0}}.
+ {put_tuple,2,{x,0}}.
+ {put,{atom,badmatch}}.
+ {put,{x,1}}.
+ {'%live',1}.
+ {call_ext,1,{extfunc,erlang,exit,1}}.
+ {label,6}.
+ {move,{y,0},{x,0}}.
+ {call_last,1,{f,8},1}.
+
+
+{function, foo, 1, 8}.
+ {label,7}.
+ {func_info,{atom,t},{atom,foo},1}.
+ {label,8}.
+ {move,{atom,ok},{x,0}}.
+ return.
+
+
+{function, bar, 2, 10}.
+ {label,9}.
+ {func_info,{atom,t},{atom,bar},2}.
+ {label,10}.
+ {move,{atom,ok},{x,0}}.
+ return.
+
+
+{function, module_info, 0, 12}.
+ {label,11}.
+ {func_info,{atom,t},{atom,module_info},0}.
+ {label,12}.
+ {move,{atom,t},{x,0}}.
+ {call_ext_only,1,{extfunc,erlang,get_module_info,1}}.
+
+
+{function, module_info, 1, 14}.
+ {label,13}.
+ {func_info,{atom,t},{atom,module_info},1}.
+ {label,14}.
+ {move,{x,0},{x,1}}.
+ {move,{atom,t},{x,0}}.
+ {call_ext_only,2,{extfunc,erlang,get_module_info,2}}.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/no_exception_in_catch.S b/lib/compiler/test/beam_validator_SUITE_data/no_exception_in_catch.S
new file mode 100644
index 0000000000..e08a718a39
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/no_exception_in_catch.S
@@ -0,0 +1,209 @@
+{module, no_exception_in_catch}. %% version = 0
+
+{exports, [{foo,1},{module_info,0},{module_info,1},{nested_of_1,4}]}.
+
+{attributes, []}.
+
+{labels, 22}.
+
+
+{function, nested_of_1, 4, 2}.
+ {label,1}.
+ {func_info,{atom,no_exception_in_catch},{atom,nested_of_1},4}.
+ {label,2}.
+ {test,is_tuple,{f,1},[{x,0}]}.
+ {test,test_arity,{f,1},[{x,0},3]}.
+ {allocate_zero,15,4}.
+ {get_tuple_element,{x,0},0,{y,9}}.
+ {get_tuple_element,{x,0},1,{y,10}}.
+ {get_tuple_element,{x,0},2,{y,11}}.
+ {move,{x,3},{y,14}}.
+ {move,{x,2},{y,13}}.
+ {move,{x,1},{y,12}}.
+ {move,{atom,nested3},{x,0}}.
+ {call_ext,1,{extfunc,erlang,erase,1}}.
+ {move,{atom,nested4},{x,0}}.
+ {call_ext,1,{extfunc,erlang,erase,1}}.
+ {move,{atom,nested},{x,0}}.
+ {call_ext,1,{extfunc,erlang,erase,1}}.
+ {bif,self,nofail,[],{x,0}}.
+ {'try',{y,8},{f,13}}.
+ {'try',{y,7},{f,11}}.
+ {'try',{y,6},{f,9}}.
+ {'try',{y,5},{f,7}}.
+%% Because the following instructions can't possible throw an exception,
+%% label 7 used to get no state. Now the try_end itself will save the state.
+ {move,{x,0},{y,4}}.
+ {bif,self,nofail,[],{x,0}}.
+ {'%live',1}.
+ {try_end,{y,5}}.
+ {test,is_eq_exact,{f,15},[{x,0},{y,4}]}.
+ {'try',{y,5},{f,6}}.
+ {'try',{y,3},{f,3}}.
+ {move,{y,9},{x,0}}.
+ {call,1,{f,17}}.
+ {try_end,{y,3}}.
+ {test,is_eq_exact,{f,15},[{x,0},{y,11}]}.
+ {move,{y,12},{x,0}}.
+ {call,1,{f,17}}.
+ {test_heap,3,1}.
+ {put_tuple,2,{x,1}}.
+ {put,{atom,value1}}.
+ {put,{x,0}}.
+ {move,{x,1},{x,0}}.
+ {jump,{f,5}}.
+ {label,3}.
+ {try_case,{y,3}}.
+ {move,{x,1},{y,1}}.
+ {move,{x,0},{y,2}}.
+ {move,{x,2},{y,3}}.
+ {bif,'=:=',{f,4},[{x,0},{y,10}],{x,3}}.
+ {move,{x,3},{y,0}}.
+ {bif,'=:=',{f,4},[{x,1},{y,11}],{x,4}}.
+ {bif,'and',{f,4},[{x,3},{x,4}],{x,3}}.
+ {test,is_eq_exact,{f,4},[{x,3},{atom,true}]}.
+ {kill,{y,0}}.
+ {kill,{y,1}}.
+ {kill,{y,2}}.
+ {kill,{y,3}}.
+ {move,{y,12},{x,0}}.
+ {call,1,{f,17}}.
+ {test_heap,3,1}.
+ {put_tuple,2,{x,1}}.
+ {put,{atom,caught1}}.
+ {put,{x,0}}.
+ {move,{x,1},{x,0}}.
+ {jump,{f,5}}.
+ {label,4}.
+ {bif,raise,{f,0},[{x,2},{x,1}],{x,0}}.
+ {'%live',1}.
+ {label,5}.
+ {try_end,{y,5}}.
+ {move,{x,0},{y,5}}.
+ {move,{y,13},{x,0}}.
+ {call,1,{f,17}}.
+ {move,{x,0},{x,1}}.
+ {move,{atom,nested3},{x,0}}.
+ {call_ext,2,{extfunc,erlang,put,2}}.
+ {move,{y,5},{x,0}}.
+ {jump,{f,8}}.
+ {label,6}.
+ {try_case,{y,5}}.
+ {move,{x,2},{y,5}}.
+ {move,{x,1},{y,3}}.
+ {move,{y,13},{x,0}}.
+ {call,1,{f,17}}.
+ {move,{x,0},{x,1}}.
+ {move,{atom,nested3},{x,0}}.
+ {call_ext,2,{extfunc,erlang,put,2}}.
+ {bif,raise,{f,0},[{y,5},{y,3}],{x,0}}.
+ {'%live',1}.
+ {jump,{f,8}}.
+ {label,7}.
+%% The instructions here used to be not checked.
+ {move,{x,3},{x,0}}.
+ {try_case,{y,5}}.
+ {bif,raise,{f,0},[{x,2},{x,1}],{x,0}}.
+ {'%live',1}.
+ {label,8}.
+ {try_end,{y,6}}.
+ {move,{x,0},{y,13}}.
+ {kill,{y,3}}.
+ {kill,{y,4}}.
+ {kill,{y,5}}.
+ {kill,{y,9}}.
+ {kill,{y,10}}.
+ {kill,{y,11}}.
+ {kill,{y,12}}.
+ {move,{y,14},{x,0}}.
+ {call,1,{f,17}}.
+ {move,{x,0},{x,1}}.
+ {move,{atom,nested4},{x,0}}.
+ {call_ext,2,{extfunc,erlang,put,2}}.
+ {move,{y,13},{x,0}}.
+ {jump,{f,10}}.
+ {label,9}.
+ {try_case,{y,6}}.
+ {move,{x,2},{y,13}}.
+ {move,{x,1},{y,12}}.
+ {kill,{y,3}}.
+ {kill,{y,4}}.
+ {kill,{y,5}}.
+ {kill,{y,9}}.
+ {kill,{y,10}}.
+ {kill,{y,11}}.
+ {move,{y,14},{x,0}}.
+ {call,1,{f,17}}.
+ {move,{x,0},{x,1}}.
+ {move,{atom,nested4},{x,0}}.
+ {call_ext,2,{extfunc,erlang,put,2}}.
+ {bif,raise,{f,0},[{y,13},{y,12}],{x,0}}.
+ {'%live',1}.
+ {label,10}.
+ {try_end,{y,7}}.
+ {test_heap,3,1}.
+ {put_tuple,2,{x,1}}.
+ {put,{atom,value}}.
+ {put,{x,0}}.
+ {move,{x,1},{x,0}}.
+ {jump,{f,12}}.
+ {label,11}.
+ {try_case,{y,7}}.
+ {test_heap,6,3}.
+ {put_tuple,2,{x,3}}.
+ {put,{x,0}}.
+ {put,{x,1}}.
+ {put_tuple,2,{x,0}}.
+ {put,{atom,caught}}.
+ {put,{x,3}}.
+ {'%live',1}.
+ {label,12}.
+ {try_end,{y,8}}.
+ {move,{x,0},{y,14}}.
+ {move,{atom,finalized},{x,1}}.
+ {kill,{y,12}}.
+ {kill,{y,13}}.
+ {move,{atom,nested},{x,0}}.
+ {call_ext,2,{extfunc,erlang,put,2}}.
+ {move,{y,14},{x,0}}.
+ {jump,{f,14}}.
+ {label,13}.
+ {try_case,{y,8}}.
+ {move,{x,2},{y,14}}.
+ {move,{x,1},{y,13}}.
+ {move,{atom,finalized},{x,1}}.
+ {kill,{y,12}}.
+ {move,{atom,nested},{x,0}}.
+ {call_ext,2,{extfunc,erlang,put,2}}.
+ {bif,raise,{f,0},[{y,14},{y,13}],{x,0}}.
+ {'%live',1}.
+ {label,14}.
+ {move,{x,0},{y,14}}.
+ {kill,{y,13}}.
+ {move,{atom,nested3},{x,0}}.
+ {call_ext,1,{extfunc,erlang,erase,1}}.
+ {move,{x,0},{y,13}}.
+ {move,{atom,nested4},{x,0}}.
+ {call_ext,1,{extfunc,erlang,erase,1}}.
+ {move,{x,0},{y,12}}.
+ {move,{atom,nested},{x,0}}.
+ {call_ext,1,{extfunc,erlang,erase,1}}.
+ {test_heap,5,1}.
+ {put_tuple,4,{x,1}}.
+ {put,{y,14}}.
+ {put,{y,13}}.
+ {put,{y,12}}.
+ {put,{x,0}}.
+ {move,{x,1},{x,0}}.
+ {deallocate,15}.
+ return.
+ {label,15}.
+ {try_case_end,{x,0}}.
+
+
+{function, foo, 1, 17}.
+ {label,16}.
+ {func_info,{atom,no_exception_in_catch},{atom,foo},1}.
+ {label,17}.
+ {move,{atom,ok},{x,0}}.
+ return.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/overwrite_catchtag.S b/lib/compiler/test/beam_validator_SUITE_data/overwrite_catchtag.S
new file mode 100644
index 0000000000..f6ad0ac50a
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/overwrite_catchtag.S
@@ -0,0 +1,38 @@
+{module, overwrite_catchtag}. %% version = 0
+
+{exports, [{foo,1},{module_info,0},{module_info,1}]}.
+
+{attributes, []}.
+
+{labels, 8}.
+
+
+{function, foo, 1, 2}.
+ {label,1}.
+ {func_info,{atom,overwrite_catchtag},{atom,foo},1}.
+ {label,2}.
+ {allocate,1,1}.
+ {'catch',{y,0},{f,3}}.
+ {move,{x,0},{y,0}}. % <= {catchtag,3}
+ {call,1,{f,2}}.
+ {label,3}.
+ {catch_end,{y,0}}.
+ {deallocate,1}.
+ return.
+
+
+{function, module_info, 0, 5}.
+ {label,4}.
+ {func_info,{atom,overwrite_catchtag},{atom,module_info},0}.
+ {label,5}.
+ {move,{atom,overwrite_catchtag},{x,0}}.
+ {call_ext_only,1,{extfunc,erlang,get_module_info,1}}.
+
+
+{function, module_info, 1, 7}.
+ {label,6}.
+ {func_info,{atom,overwrite_catchtag},{atom,module_info},1}.
+ {label,7}.
+ {move,{x,0},{x,1}}.
+ {move,{atom,overwrite_catchtag},{x,0}}.
+ {call_ext_only,2,{extfunc,erlang,get_module_info,2}}.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/overwrite_trytag.S b/lib/compiler/test/beam_validator_SUITE_data/overwrite_trytag.S
new file mode 100644
index 0000000000..db552d5418
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/overwrite_trytag.S
@@ -0,0 +1,53 @@
+{module, overwrite_trytag}. %% version = 0
+
+{exports, [{foo,1},{module_info,0},{module_info,1}]}.
+
+{attributes, []}.
+
+{labels, 9}.
+
+
+{function, foo, 1, 2}.
+ {label,1}.
+ {func_info,{atom,overwrite_trytag},{atom,foo},1}.
+ {label,2}.
+ {allocate_zero,3,1}.
+ {'try',{y,2},{f,3}}.
+ {move,{x,0},{y,1}}.
+ {'%live',1}.
+ {call,1,{f,2}}.
+ {kill,{y,2}}.
+ {try_end,{y,2}}.
+ {move,{x,0},{y,2}}.
+ {move,{y,1},{x,0}}.
+ {call,1,{f,2}}.
+ {move,{y,2},{x,0}}.
+ {jump,{f,4}}.
+ {label,3}.
+ {try_case,{y,2}}.
+ {move,{x,2},{y,2}}.
+ {move,{x,1},{y,0}}.
+ {move,{y,1},{x,0}}.
+ {call,1,{f,2}}.
+ {bif,raise,{f,0},[{y,2},{y,0}],{x,0}}.
+ {'%live',1}.
+ {label,4}.
+ {deallocate,3}.
+ return.
+
+
+{function, module_info, 0, 6}.
+ {label,5}.
+ {func_info,{atom,overwrite_trytag},{atom,module_info},0}.
+ {label,6}.
+ {move,{atom,overwrite_trytag},{x,0}}.
+ {call_ext_only,1,{extfunc,erlang,get_module_info,1}}.
+
+
+{function, module_info, 1, 8}.
+ {label,7}.
+ {func_info,{atom,overwrite_trytag},{atom,module_info},1}.
+ {label,8}.
+ {move,{x,0},{x,1}}.
+ {move,{atom,overwrite_trytag},{x,0}}.
+ {call_ext_only,2,{extfunc,erlang,get_module_info,2}}.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/stack.S b/lib/compiler/test/beam_validator_SUITE_data/stack.S
new file mode 100644
index 0000000000..244c22a2f9
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/stack.S
@@ -0,0 +1,89 @@
+{module, stack}. %% version = 0
+
+{exports, [{a,2},{b,2},{c,2},{d,2},{e,2}]}.
+
+{attributes, []}.
+
+{labels, 21}.
+
+
+{function, a, 2, 2}.
+ {label,1}.
+ {func_info,{atom,t},{atom,a},2}.
+ {label,2}.
+ {allocate,2,2}.
+ {move,{x,1},{y,1}}.
+ {move,{x,0},{y,0}}.
+ {'%live',0}.
+ {call,0,{f,16}}.
+ {bif,'+',{f,0},[{y,0},{y,1}],{x,0}}.
+ {'%live',1}.
+ return.
+
+
+{function, b, 2, 4}.
+ {label,3}.
+ {func_info,{atom,t},{atom,b},2}.
+ {label,4}.
+ {deallocate,2}.
+ return.
+
+
+{function, c, 2, 6}.
+ {label,5}.
+ {func_info,{atom,t},{atom,c},2}.
+ {label,6}.
+ {allocate,2,2}.
+ {move,{x,1},{y,1}}.
+ {move,{x,0},{y,0}}.
+ {'%live',0}.
+ {call,0,{f,16}}.
+ {bif,'+',{f,0},[{y,0},{y,1}],{x,0}}.
+ {'%live',1}.
+ {deallocate,2}.
+ {deallocate,2}.
+ return.
+
+
+{function, d, 2, 8}.
+ {label,7}.
+ {func_info,{atom,t},{atom,d},2}.
+ {label,8}.
+ {allocate,2,2}.
+ {allocate,2,2}.
+ {deallocate,2}.
+ return.
+
+{function, e, 2, 14}.
+ {label,13}.
+ {func_info,{atom,t},{atom,e},2}.
+ {label,14}.
+ {allocate,2,2}.
+ {move,{atom,ok},{x,0}}.
+ {deallocate,5}.
+ return.
+
+
+{function, bad_1, 0, 10}.
+ {label,9}.
+ {func_info,{atom,t},{atom,bad_1},0}.
+ {label,10}.
+ {allocate_zero,2,10}.
+ {move,{y,0},{x,0}}.
+ return.
+
+
+{function, bad_2, 0, 12}.
+ {label,11}.
+ {func_info,{atom,t},{atom,bad_2},0}.
+ {label,12}.
+ {allocate_zero,2,0}.
+ {move,{y,0},{x,0}}.
+ return.
+
+{function, foo, 0, 16}.
+ {label,15}.
+ {func_info,{atom,t},{atom,foo},0}.
+ {label,16}.
+ {move,{atom,ok},{x,0}}.
+ return.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/state_after_fault_in_catch.S b/lib/compiler/test/beam_validator_SUITE_data/state_after_fault_in_catch.S
new file mode 100644
index 0000000000..8e27347ed5
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/state_after_fault_in_catch.S
@@ -0,0 +1,58 @@
+{module, state_after_fault_in_catch}. %% version = 0
+
+{exports, [{foo,1},{if_end,1},{case_end,1},{badmatch,1}]}.
+
+{attributes, []}.
+
+{labels, 12}.
+
+
+{function, foo, 1, 2}.
+ {label,1}.
+ {func_info,{atom,t},{atom,foo},1}.
+ {label,2}.
+ {allocate,1,0}.
+ {'catch',{y,0},{f,3}}.
+ {move,{atom,apa},{x,0}}.
+ {call_ext,1,{extfunc,erlang,fault,1}}.
+ {label,3}.
+ {catch_end,{y,0}}.
+ {move,{x,1},{x,0}}.
+ return.
+
+{function, if_end, 1, 5}.
+ {label,4}.
+ {func_info,{atom,state_after_fault_in_catch},{atom,if_end},1}.
+ {label,5}.
+ {allocate,1,0}.
+ {'catch',{y,0},{f,6}}.
+ if_end.
+ {label,6}.
+ {catch_end,{y,0}}.
+ {move,{x,1},{x,0}}.
+ return.
+
+{function, case_end, 1, 8}.
+ {label,7}.
+ {func_info,{atom,state_after_fault_in_catch},{atom,case_end},1}.
+ {label,8}.
+ {allocate,1,1}.
+ {'catch',{y,0},{f,9}}.
+ {case_end,{x,0}}.
+ {label,9}.
+ {catch_end,{y,0}}.
+ {move,{x,1},{x,0}}.
+ return.
+
+{function, badmatch, 1, 11}.
+ {label,10}.
+ {func_info,{atom,state_after_fault_in_catch},{atom,badmatch},1}.
+ {label,11}.
+ {allocate,1,1}.
+ {'catch',{y,0},{f,12}}.
+ {badmatch,{x,0}}.
+ {label,12}.
+ {catch_end,{y,0}}.
+ {move,{x,1},{x,0}}.
+ return.
+
diff --git a/lib/compiler/test/beam_validator_SUITE_data/undef_label.S b/lib/compiler/test/beam_validator_SUITE_data/undef_label.S
new file mode 100644
index 0000000000..dd29066bf4
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/undef_label.S
@@ -0,0 +1,22 @@
+{module, undef_label}. %% version = 0
+
+{exports, []}.
+
+{attributes, []}.
+
+{labels, 7}.
+
+
+{function, t, 1, 2}.
+ {label,1}.
+ {func_info,{atom,undef_label},{atom,t},1}.
+ {label,2}.
+ {test,is_eq_exact,{f,42},[{x,0},{atom,x}]}.
+ {move,{atom,ok},{x,0}}.
+ return.
+
+{function, x, 1, 17}.
+ {label,3}.
+ {func_info,{atom,undef_label},{atom,x},1}.
+ {label,4}.
+ return.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/uninit.S b/lib/compiler/test/beam_validator_SUITE_data/uninit.S
new file mode 100644
index 0000000000..1a45c31411
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/uninit.S
@@ -0,0 +1,48 @@
+{module, uninit}. %% version = 0
+
+{exports, []}.
+
+{attributes, []}.
+
+{function, sum_1, 2, 2}.
+ {label,1}.
+ {func_info,{atom,t},{atom,sum_1},2}.
+ {label,2}.
+ {allocate,1,2}.
+ {move,{y,0},{x,0}}.
+ {'%live',1}.
+ {call,1,{f,10}}.
+ {bif,'+',{f,0},[{x,0},{y,0}],{x,0}}.
+ {'%live',1}.
+ {deallocate,1}.
+ return.
+
+{function, sum_2, 2, 4}.
+ {label,3}.
+ {func_info,{atom,t},{atom,sum_2},2}.
+ {label,4}.
+ {allocate,1,2}.
+ {'%live',1}.
+ {call,1,{f,10}}.
+ {bif,'+',{f,0},[{x,0},{y,0}],{x,0}}.
+ {'%live',1}.
+ {deallocate,1}.
+ return.
+
+{function, sum_3, 2, 6}.
+ {label,5}.
+ {func_info,{atom,t},{atom,sum_3},2}.
+ {label,6}.
+ {allocate_zero,1,2}.
+ {'%live',1}.
+ {call,1,{f,10}}.
+ {bif,'+',{f,0},[{x,0},{y,0}],{x,0}}.
+ {'%live',1}.
+ {deallocate,1}.
+ return.
+
+{function, id, 1, 10}.
+ {label,9}.
+ {func_info,{atom,t},{atom,id},1}.
+ {label,10}.
+ return.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/unsafe_catch.S b/lib/compiler/test/beam_validator_SUITE_data/unsafe_catch.S
new file mode 100644
index 0000000000..500ac11377
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/unsafe_catch.S
@@ -0,0 +1,67 @@
+{module, unsafe_catch}. %% version = 0
+
+{exports, [{small,2}]}.
+
+{attributes, []}.
+
+{labels, 14}.
+
+
+{function, small, 2, 5}.
+ {label,4}.
+ {func_info,{atom,t},{atom,small},2}.
+ {label,5}.
+ {allocate_zero,2,2}.
+ {'catch',{y,1},{f,6}}.
+ {bs_init2,{f,0},1,0,2,{field_flags,[]},{x,2}}.
+ {bs_put_integer,{f,0},
+ {integer,8},
+ 1,
+ {field_flags,[aligned,unsigned,big]},
+ {x,0}}.
+ {move,{x,1},{y,0}}.
+ {move,{x,2},{x,0}}.
+ {label,6}.
+ {catch_end,{y,1}}.
+ {test,is_tuple,{f,7},[{x,0}]}.
+ {test,test_arity,{f,7},[{x,0},2]}.
+ {get_tuple_element,{x,0},0,{x,1}}.
+ {test,is_eq_exact,{f,7},[{x,1},{atom,'EXIT'}]}.
+ {bs_init2,{f,0},0,0,0,{field_flags,[]},{x,0}}.
+ {label,7}.
+ {'catch',{y,1},{f,8}}.
+ {bs_init2,{f,0},2,0,1,{field_flags,[]},{x,1}}.
+ {bs_put_integer,{f,0},
+ {integer,16},
+ 1,
+ {field_flags,[aligned,unsigned,big]},
+ {y,0}}.
+ {move,{x,0},{y,0}}.
+ {move,{x,1},{x,0}}.
+ {label,8}.
+ {catch_end,{y,1}}.
+ {test,is_tuple,{f,9},[{x,0}]}.
+ {test,test_arity,{f,9},[{x,0},2]}.
+ {get_tuple_element,{x,0},0,{x,1}}.
+ {test,is_eq_exact,{f,9},[{x,1},{atom,'EXIT'}]}.
+ {bs_init2,{f,0},0,0,0,{field_flags,[]},{x,0}}.
+ {label,9}.
+ {move,{integer,0},{x,1}}.
+ {bif,size,{f,0},[{x,0}],{x,2}}.
+ {bs_add,{f,0},[{x,1},{x,2},1],{x,1}}.
+ {bif,size,{f,0},[{y,0}],{x,2}}.
+ {bs_add,{f,0},[{x,1},{x,2},1],{x,1}}.
+ {bs_init2,{f,0},{x,1},0,2,{field_flags,[]},{x,1}}.
+ {bs_put_binary,{f,0},
+ {atom,all},
+ 8,
+ {field_flags,[aligned,unsigned,big]},
+ {y,0}}.
+ {bs_put_binary,{f,0},
+ {atom,all},
+ 8,
+ {field_flags,[aligned,unsigned,big]},
+ {x,0}}.
+ {move,{x,1},{x,0}}.
+ {deallocate,2}.
+ return.
diff --git a/lib/compiler/test/beam_validator_SUITE_data/xrange.S b/lib/compiler/test/beam_validator_SUITE_data/xrange.S
new file mode 100644
index 0000000000..3abbdffbc2
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/xrange.S
@@ -0,0 +1,44 @@
+{module, xrange}. %% version = 0
+
+{exports, [{module_info,0},{module_info,1},{prod,2},{sum,2},{sum_prod,3}]}.
+
+{attributes, []}.
+
+{labels, 8}.
+
+
+{function, sum_1, 2, 2}.
+ {label,1}.
+ {func_info,{atom,t},{atom,sum_1},2}.
+ {label,2}.
+ {bif,'+',{f,0},[{x,-1},{x,1}],{x,0}}.
+ {'%live',1}.
+ return.
+
+
+{function, sum_2, 2, 4}.
+ {label,3}.
+ {func_info,{atom,t},{atom,sum_2},2}.
+ {label,4}.
+ {bif,'+',{f,0},[{x,0},{x,1024}],{x,0}}.
+ {'%live',1}.
+ return.
+
+
+{function, sum_3, 2, 6}.
+ {label,5}.
+ {func_info,{atom,t},{atom,sum_3},2}.
+ {label,6}.
+ {bif,'+',{f,0},[{x,0},{x,1}],{x,-1}}.
+ {'%live',1}.
+ return.
+
+
+{function, sum_4, 2, 8}.
+ {label,7}.
+ {func_info,{atom,t},{atom,sum_4},2}.
+ {label,8}.
+ {bif,'+',{f,0},[{x,0},{x,1}],{x,1024}}.
+ {'%live',1}.
+ return.
+
diff --git a/lib/compiler/test/beam_validator_SUITE_data/yrange.S b/lib/compiler/test/beam_validator_SUITE_data/yrange.S
new file mode 100644
index 0000000000..483b14ebd3
--- /dev/null
+++ b/lib/compiler/test/beam_validator_SUITE_data/yrange.S
@@ -0,0 +1,76 @@
+{module, yrange}. %% version = 0
+
+{exports, [{id,1},
+ {module_info,0},
+ {module_info,1},
+ {sum_1,2},
+ {sum_2,2},
+ {sum_3,2},
+ {sum_4,2}]}.
+
+{attributes, []}.
+
+{labels, 15}.
+
+
+{function, sum_1, 2, 2}.
+ {label,1}.
+ {func_info,{atom,t},{atom,sum_1},2}.
+ {label,2}.
+ {allocate,1,2}.
+ {move,{x,1},{y,-1}}.
+ {'%live',1}.
+ {call,1,{f,10}}.
+ {bif,'+',{f,0},[{x,0},{y,0}],{x,0}}.
+ {'%live',1}.
+ {deallocate,1}.
+ return.
+
+
+{function, sum_2, 2, 4}.
+ {label,3}.
+ {func_info,{atom,t},{atom,sum_2},2}.
+ {label,4}.
+ {allocate,1,2}.
+ {move,{x,1},{y,0}}.
+ {'%live',1}.
+ {call,1,{f,10}}.
+ {bif,'+',{f,0},[{x,0},{y,1024}],{x,0}}.
+ {'%live',1}.
+ {deallocate,1}.
+ return.
+
+
+{function, sum_3, 2, 6}.
+ {label,5}.
+ {func_info,{atom,t},{atom,sum_3},2}.
+ {label,6}.
+ {allocate,1,2}.
+ {move,{x,1},{y,1024}}.
+ {'%live',1}.
+ {call,1,{f,10}}.
+ {bif,'+',{f,0},[{x,0},{y,0}],{x,0}}.
+ {'%live',1}.
+ {deallocate,1}.
+ return.
+
+
+{function, sum_4, 2, 8}.
+ {label,7}.
+ {func_info,{atom,t},{atom,sum_4},2}.
+ {label,8}.
+ {allocate,1,2}.
+ {move,{x,1},{y,-1}}.
+ {'%live',1}.
+ {call,1,{f,10}}.
+ {bif,'+',{f,0},[{x,0},{y,0}],{x,0}}.
+ {'%live',1}.
+ {deallocate,1}.
+ return.
+
+
+{function, id, 1, 10}.
+ {label,9}.
+ {func_info,{atom,t},{atom,id},1}.
+ {label,10}.
+ return.