diff options
author | Björn-Egil Dahlberg <[email protected]> | 2016-05-26 14:17:04 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2016-05-26 14:17:04 +0200 |
commit | 4d7b24dcb8f10ea8ddaa002601916fb389f0e87e (patch) | |
tree | fe7e75608465adbffd81e22ad7943b567a3caab4 /lib/hipe/test/opt_verify_SUITE.erl | |
parent | 1081e3881e3994f381d122600d5db129c0ad0266 (diff) | |
parent | f833a900897faae48230bc8c1e7572fb470a4a6f (diff) | |
download | otp-4d7b24dcb8f10ea8ddaa002601916fb389f0e87e.tar.gz otp-4d7b24dcb8f10ea8ddaa002601916fb389f0e87e.tar.bz2 otp-4d7b24dcb8f10ea8ddaa002601916fb389f0e87e.zip |
Merge branch 'margnus1/hipe/maps-is_key-opts/PR-1069/OTP-13625'
* margnus1/hipe/maps-is_key-opts/PR-1069/OTP-13625:
hipe: Add test suite for verifying optimisations
Added elimination of maps:is_key/2 calls to HiPE
Diffstat (limited to 'lib/hipe/test/opt_verify_SUITE.erl')
-rw-r--r-- | lib/hipe/test/opt_verify_SUITE.erl | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/hipe/test/opt_verify_SUITE.erl b/lib/hipe/test/opt_verify_SUITE.erl new file mode 100644 index 0000000000..61952e81d7 --- /dev/null +++ b/lib/hipe/test/opt_verify_SUITE.erl @@ -0,0 +1,62 @@ +-module(opt_verify_SUITE). + +-compile([export_all]). + +all() -> + [call_elim]. + +groups() -> + []. + +init_per_suite(Config) -> + case erlang:system_info(hipe_architecture) of + undefined -> {skip, "HiPE not available or enabled"}; + _ -> Config + end. + +end_per_suite(_Config) -> + ok. + +init_per_group(_GroupName, Config) -> + Config. + +end_per_group(_GroupName, Config) -> + Config. + +call_elim_test_file(Config, FileName, Option) -> + PrivDir = test_server:lookup_config(priv_dir, Config), + TempOut = test_server:temp_name(filename:join(PrivDir, "call_elim_out")), + {ok, TestCase} = compile:file(FileName), + {ok, TestCase} = hipe:c(TestCase, [Option, {pp_range_icode, {file, TempOut}}]), + {ok, Icode} = file:read_file(TempOut), + ok = file:delete(TempOut), + Icode. + +substring_count(Icode, Substring) -> + substring_count(Icode, Substring, 0). +substring_count(Icode, Substring, N) -> + case string:str(Icode, Substring) of + 0 -> N; + I -> substring_count(lists:nthtail(I, Icode), Substring, N+1) + end. + +call_elim() -> + [{doc, "Test that the call elimination optimization pass is ok"}]. +call_elim(Config) -> + DataDir = test_server:lookup_config(data_dir, Config), + F1 = filename:join(DataDir, "call_elim_test.erl"), + Icode1 = call_elim_test_file(Config, F1, icode_call_elim), + 0 = substring_count(binary:bin_to_list(Icode1), "is_key"), + Icode2 = call_elim_test_file(Config, F1, no_icode_call_elim), + true = (0 /= substring_count(binary:bin_to_list(Icode2), "is_key")), + F2 = filename:join(DataDir, "call_elim_test_branches_no_opt_poss.erl"), + Icode3 = call_elim_test_file(Config, F2, icode_call_elim), + 3 = substring_count(binary:bin_to_list(Icode3), "is_key"), + Icode4 = call_elim_test_file(Config, F2, no_icode_call_elim), + 3 = substring_count(binary:bin_to_list(Icode4), "is_key"), + F3 = filename:join(DataDir, "call_elim_test_branches_opt_poss.erl"), + Icode5 = call_elim_test_file(Config, F3, icode_call_elim), + 0 = substring_count(binary:bin_to_list(Icode5), "is_key"), + Icode6 = call_elim_test_file(Config, F3, no_icode_call_elim), + 3 = substring_count(binary:bin_to_list(Icode6), "is_key"), + ok. |