aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test/core_fold_SUITE.erl
AgeCommit message (Collapse)Author
2016-03-15update copyright-yearHenrik Nord
2016-02-25Remove ?line macrosBjörn Gustavsson
2016-02-25Eliminate use of ?config() macroBjörn Gustavsson
?config is ugly and not recommended. Use proplists:get_value/2 instead.
2016-02-17Eliminate use of test_server.hrl and test_server_line.hrlBjörn Gustavsson
As a first step to removing the test_server application as as its own separate application, change the inclusion of test_server.hrl to an inclusion of ct.hrl and remove the inclusion of test_server_line.hrl.
2015-06-18Change license text to APLv2Bruce Yinhe
2015-04-22test suite: Always place .core files in data directoriesBjörn Gustavsson
For tidiness, always place .core files in data directories.
2015-04-22test suites: Unload modules compiled from .core or .SBjörn Gustavsson
The .core or .S files that are compiled in the test cases may lack module_info/0,1 functions, which will cause problems if we (for example) try to run eprof later. To avoid that problem, unload each module directly after testing it.
2015-03-09Clean up evaluation of setelement/3Björn Gustavsson
The 'try' ... 'catch' is problematic. Firstly, if no optimization is possible, an exception will always be thrown. Secondly, bugs in the code will go unnoticed.
2015-03-09Update type information based on BIFs that returns integersBjörn Gustavsson
2015-02-12cerl: Teach is_literal_term/1 to handle mapsBjörn Gustavsson
2015-02-12sys_core_fold: Refactor type information accessBjörn Gustavsson
Introduce access functions to hide the low-level details of how type information is implemented.
2015-02-05Merge branch 'bjorn/compiler/dup-bug-fix/OTP-12453'Björn Gustavsson
* bjorn/compiler/dup-bug-fix/OTP-12453: Teach case_opt/3 to avoid unnecessary building sys_core_fold: Optimize let statements more aggressively Suppress warnings for expressions that are assigned to '_' trace_bif_SUITE: Ensure that a call to time/0 is not removed
2015-02-05Merge branch 'maint'Björn Gustavsson
* maint: Update primary bootstrap Correct unsafe optimization of '==' and '/=' Conflicts: bootstrap/lib/compiler/ebin/sys_core_fold.beam
2015-02-04Correct unsafe optimization of '==' and '/='Björn Gustavsson
Since '=:=' is cheaper than '==', the compiler tries to replace '==' with '=:=' if the result of comparison will be the same. As an example: V == {a,b} can be rewritten to: V =:= {a,b} since the literal on the right side contains no numeric values that '==' would compare differently to '=:='. With the introduction of maps, we will need to take them into account. Since the comparison of maps is planned to change in 18.0, we will be very conservative and only do the optimization if both keys and values are non-numeric.
2015-02-03Teach case_opt/3 to avoid unnecessary buildingBjörn Gustavsson
Given this code: f(S) -> F0 = F1 = {S,S}, [F0,F1]. case_opt/3 would "optimize" it like this: f(S) -> F1 = {S,S}, F0 = {S,S}, [F0,F1]. Similarly, this code: g({a,_,_}=T) -> {b, [_,_] = [T,none], x}. would be rewritten to: g({a,Tmp1,Tmp2}=T) -> Tmp3 = {a,Tmp1,Tmp2}, {b, [Tmp3,none], x}. where the tuple is rebuilt instead of using the T variable. Rewrite case_opt/3 to be more careful while optimizing.
2015-02-03sys_core_fold: Optimize let statements more aggressivelyBjörn Gustavsson
I originally decided that in 'value' context, rewriting a let statement where the variables were not in the body to a sequence was not worth it, because the variables would be unused in only one let in a thousand lets (roughly). I have reconsidered. The main reason is that if we do the rewrite, core_lib:is_var_used/2 will be used much more frequently, which will help us to find bugs in it sooner. Another reason is that the way letify/2 is currently implemented with its own calls to core_lib:is_var_used/2 is only safe as long as all the bindings are independent of each other. We could make letify/2 smarter, but if we introduce this new optimization there is no need. Measuring compilation speed, I have not seen any significant slowdown. It seems that although core_lib:is_var_used/2 is called much more frequently, most calls will be fast because is_var_used/2 will quickly find a use of the variable. Also add a test case to cover a line opt_guard_try/1 that was no longer covered.
2015-02-03Merge branch 'maint'Björn Gustavsson
* maint: Update primary bootstrap Be more careful about map patterns when evalutating element/2 Do not convert map patterns to map expressions Conflicts: bootstrap/lib/compiler/ebin/sys_core_fold.beam lib/compiler/test/match_SUITE.erl
2015-02-03Be more careful about map patterns when evalutating element/2Björn Gustavsson
We must not convert map patterns to map expressions.
2015-01-26Speed up running of compiler test suites in coverage modeBjörn Gustavsson
I have spent too much time lately waiting for 'cover' to finish, so now its time to optimize the running time of the tests suite in coverage mode. Basically, when 'cover' is running, the test suites would not run any tests in parallel. The reason is that using too many parallel processes when running 'cover' would be slower than running them sequentially. But those measurements were made several years ago, and many improvements have been made to improve the parallelism of the run-time system. Experimenting with the test_lib:p_run/2 function, I found that increasing the number of parallel processes would speed up the self_compile tests cases in compilation_SUITE. The difference between using 3 processes or 4 processes was slight, though, so it seems that we should not use more than 4 processes when running 'cover'. We don't want to change test_lib:parallel/0, because there is no way to limit the number of test cases that will be run in parallel by common_test. However, there as test suites (such as andor_SUITE) that don't invoke the compiler at run-time. We can run the cases in such test suites in parallel even if 'cover' is running.
2014-03-25Correctly handle non-matching patterns against literal valuesAnthony Ramine
The pass sys_core_fold did not correctly handle non-matching patterns in code such as: 0 = case <<>> of <<>> -> 0; a -> 1 end. Function case_opt_lit/3 is rewritten in two passes to first remove any non-matching clause and only then potentially remove the related patterns in each clause. Reported-by: Ulf Norell
2014-03-10Properly handle redundant boolean clauses in sys_core_foldAnthony Ramine
Boolean case expressions with redundant clauses could make the compiler crash: case X == 0 of false -> no; false -> no; true -> yes end. Reported-by: Ulf Norell
2014-02-04sys_core_fold: Prevent case expressions from being evaluated twiceBjörn Gustavsson
In e12b7d5331c58b41db06cadfa4af75b78b62a2b1, a bug was introduced that would cause case expressions to be evaluated more than once if there were aliases in the pattern. Example: X = Y = io:put_chars("some chars"), {X,Y} That would be rewritten to code similar to (but in Core Erlang): X = io:put_chars("some chars"), X = io:put_chars("some chars"), {X,Y} Make sure that we only evalute the expression once by doing a transformation similar to (but in Core Erlang): NewVar = io:put_chars("some chars"), X = NewVar, Y = NewVar, {X,Y} Reported-by: José Valim Reported-by: Anthony Ramine
2014-02-04sys_core_fold_SUITE: For cleanliness, move id/1 to the endBjörn Gustavsson
2014-01-16Generalize optimizations of case statementsBjörn Gustavsson
Case expressions such as: case {Expr1,Expr} of {V1,V2} -> ... end are already optimized to not actually build the tuple. Generalize the optimization to avoid building any kind of composite term, such as: case {ok,[A,B]} of {ok,[X,Y]} -> ... end We don't expect programmers to write such code directly, but inlining can produce such code. We need to be careful about the warnings we produce. If the case expression is a literal, it is expected that no warnings should be produced for clauses that don't match. We must make sure that we continue to suppress those warnings.
2013-09-05compiler: Conform returned errors to the documented formatBjörn Gustavsson
ErrorInfo is documented to be: {ErrorLine,Module,ErrorDescriptor} but for some errors with line numbers it would look like: {Module,ErrorDescriptor} Ensure that all ErrorInfo tuples have three elements. Use 'none' instead of a line number: {none,Module,ErrorDescriptor} There already are errors that return 'none' when no line number is available, but that convention was not documented. Mention it in the documentation. Also make sure that the compiler will not print 'none' as a line number in error messages (if the 'report_errors' option is given) as that looks stupid. That is, when attempting to compile a non-existing module, the error message should be: non-existing.erl: no such file or directory and not: non-existing.erl:none: no such file or directory
2013-02-06Merge branch 'nox/fix-seq-opt/OTP-10818'Fredrik Gustafsson
* nox/fix-seq-opt/OTP-10818: Add two tests for unused multiple values in effect context Forbid multiple values in Core Erlang sequence arguments
2013-02-04Add two tests for unused multiple values in effect contextAnthony Ramine
2013-01-30Test setelement(1, not_a_tuple, NewValue)Björn Gustavsson
2013-01-30Fix crash in the compiler when compiling element(2, not_a_tuple)Björn Gustavsson
2013-01-25Update copyright yearsBjörn-Egil Dahlberg
2012-10-23compiler: Run testcases in parallelBjörn Gustavsson
Run testcases in parallel will make the test suite run slightly faster. Another reason for this change is that we want more testing of parallel testcase support in common_test.
2012-01-11sys_core_fold: Fix opt_guard_try/1Björn Gustavsson
opt_guard_try/1 assumed that it was only operating on guards, and implicitly assumed that any function call was to BIFs without any side effects.
2012-01-04core_fold_SUITE: Cover sys_core_fold:is_safe_bool_expr_1/3Björn Gustavsson
2011-04-12compiler tests: Reinstate ?MODULE macro in calls to test_lib:recompile/1Björn Gustavsson
In 3d0f4a3085f11389e5b22d10f96f0cbf08c9337f (an update to conform with common_test), in all test_lib:recompile(?MODULE) calls, ?MODULE was changed to the actual name of the module. That would cause test_lib:recompile/1 to compile the module with the incorrect compiler options in cloned modules such as record_no_opt_SUITE, causing worse coverage.
2011-03-11Update copyright yearsBjörn-Egil Dahlberg
2011-02-17Rename Suite Callback to Common Test HookLukas Larsson
2011-02-17Fix formatting for compilerLukas Larsson
2011-02-17Add init_per_suite and end_per_suiteLukas Larsson
2011-02-17Add ts_install_scb to suite/0Lukas Larsson
2011-02-17Update compiler tests to conform with common_test standardLukas Larsson
2011-02-17Update all fin_per_testcase to end_per_testcase.Lukas Larsson
2009-11-20The R13B03 release.OTP_R13B03Erlang/OTP