aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test
AgeCommit message (Collapse)Author
2018-01-29Fix incorrect type interference of integer rangesBjörn Gustavsson
2018-01-04Remove unsafe is_record/test_arity optimizationsJohn Högberg
The type optimizations for is_record and test_arity checked whether the arity was equal to the size stored in the type information, which is incorrect since said size is the *minimum* size of the tuple (as determined by previous instructions) and not its exact size. A future patch to the 'master' branch will restore these optimizations in a safe manner.
2017-11-20Merge branch 'lukas/compiler/add_to_dis/OTP-14784' into maintLukas Larsson
* lukas/compiler/add_to_dis/OTP-14784: compiler: Add +to_dis option that dumps loaded asm
2017-11-20compiler: Add +to_dis option that dumps loaded asmLukas Larsson
2017-11-10Recognize 'deterministic' when given in a -compile() attributeBjörn Gustavsson
The compiler option 'deterministic' was only recognized when given as an option to the compiler, not when it was specified in a -compile() attribute in the source file. https://bugs.erlang.org/browse/ERL-498
2017-09-29Fix incorrect internal consistency failure for binary matching codeBjörn Gustavsson
4c31fd0b9665 made the merging of match contexts stricter; in fact, a little bit too strict. Two match contexts with different number of slots would be downgraded to the 'term' type. The correct way is to keep the match context but set the number of slots to the lowest number of slots of the two match contexts. https://bugs.erlang.org/browse/ERL-490
2017-08-24Merge branch 'maint-20' into maintRaimo Niskanen
* maint-20: Updated OTP version Prepare release Accept non-binary options as socket-options Bump version Fix broken handling of default values in extensions for PER compiler: Fix live regs update on allocate in validator Take fail labels into account when determining liveness in block ops Check for overflow when appending binaries, and error out with system_limit
2017-08-23Merge branch ↵Erlang/OTP
'john/compiler/fail-labels-in-blocks-otp-19/ERIERL-48/OTP-14522' into maint-20 * john/compiler/fail-labels-in-blocks-otp-19/ERIERL-48/OTP-14522: compiler: Fix live regs update on allocate in validator Take fail labels into account when determining liveness in block ops
2017-08-16Take fail labels into account when determining liveness in block opsJohn Högberg
2017-08-07sys_core_fold: Fix unsafe optimization of non-variable applyBjörn Gustavsson
The sys_core_fold pass would do an unsafe "optimization" when an apply operation did not have a variable in the function position as in the following example: > cat test1.core module 'test1' ['test1'/2] attributes [] 'i'/1 = fun (_f) -> _f 'test1'/2 = fun (_f, _x) -> apply apply 'i'/1 (_f) (_x) end > erlc test1.core no_file: Warning: invalid function call Reported-by: Mikael Pettersson
2017-06-14Update copyright yearHans Nilsson
2017-06-12beam_type_SUITE: Add a test case for an already fixed bugBjörn Gustavsson
https://bugs.erlang.org/browse/ERL-433
2017-06-07Fix unsafe bit syntax matching optimizationBjörn Gustavsson
As part of sys_core_fold, variables involved in bit syntax matching would be annotated when it would be safe for a later pass to do the delayed sub-binary creation optimization. An implicit assumption regarding the annotation was that the code must not be further optimized. That assumption was broken in 05130e48555891, which introduced a fixpoint iteration (applying the optimizations until there were no more changes). That means that a variable could be annotated as safe for reusing the match context in one iteration, but a later iteration could rewrite the code in a way that would make the optimization unsafe. One way to fix this would be to clear all reuse_for_context annotations before each iteration. But that would be wasteful. Instead I chose to fix the problem by moving out the annotation code to a separate pass (sys_core_bsm) that is run later after all major optimizations of Core Erlang has been done.
2017-05-23Correct handling of module name in compile:forms/1,2Björn Gustavsson
compile:forms/1,2 is documented to return: {ok,ModuleName,BinaryOrCode} However, if one of the options 'from_core', 'from_asm', or 'from_beam' is given, ModuleName will be returned as []. A worse problem is that is that if one those options are combined with the 'native' option, compilation will crash. Correct compile:forms/1,2 to pick up the module name from the forms provided (either Core Erlang, Beam assembly code, or a Beam file). Reported here: https://bugs.erlang.org/browse/ERL-417
2017-05-17compile_SUITE: Don't create a directory called 'core'Björn Gustavsson
A core dump can't be created with the name 'core' if there is a directory named 'core'. Rename the test case from core/1 to core_pp/1 so that the directory name can be the same as the test case name. It also makes sense to use a less generic name for the test case.
2017-05-10compiler.cover: Remove deleted module sys_pre_expandBjörn Gustavsson
2017-05-10Cover the first clause of v3_core:bin_expand_string/4Björn Gustavsson
The uncovered clause was introduced in bee8f839296e.
2017-05-10compile_SUITE: Test the r16, r17, r18, r19 optionsBjörn Gustavsson
Also test other options that turns off certain optimizations or instruction sets.
2017-05-09Merge pull request #1439 from josevalim/jv-atu8-functionBjörn Gustavsson
Add a test for utf8 function names
2017-05-08Add a test for utf8 function namesJosé Valim
The test found a bug in v3_kernel_pp which was not taking into account utf8 atoms. The bug has also been fixed.
2017-05-05Merge pull request #1438 from josevalim/patch-10Björn Gustavsson
Remove unused variable warning in compile_SUITE
2017-05-04Update copyright yearRaimo Niskanen
2017-05-04Remove unused variable warning in compile_SUITEJosé Valim
2017-04-26Merge pull request #1367 from josevalim/jv-dbgi-chunkBjörn Gustavsson
Introduce new "Dbgi" chunk OTP-14369
2017-04-25Store abstract code in the Dbgi chunkJosé Valim
The new Dbgi chunk returns data in the following format: {debug_info_v1, Backend, Data} This allows compilers to store the debug info in different formats. In order to retrieve a particular format, for instance, Erlang Abstract Format, one may invoke: Backend:debug_info(erlang_v1, Module, Data, Opts) Besides introducing the chunk above, this commit also: * Changes beam_lib:chunk(Beam, [:abstract_code]) to read from the new Dbgi chunk while keeping backwards compatibility with old .beams * Adds the {debug_info, {Backend, Data}} option to compile:file/2 and friends that are stored in the Dbgi chunk. This allows the debug info encryption mechanism to work across compilers * Improves dialyzer to work directly on Core Erlang, allowing languages that do not have the Erlang Abstract Format to be dialyzer as long as they emit the new chunk and their backend implementation is available Backwards compatibility is kept across the board except for those calling beam_lib:chunk(Beam, ["Abst"]), as the old chunk is no longer available. Note however the "Abst" chunk has always been optional. Future OTP versions may remove parsing the "Abst" chunk altogether from beam_lib once Erlang 19 and earlier is no longer supported. The current Dialyzer implementation still supports earlier .beam files and such may also be removed in future versions.
2017-04-22Make beam_validator track type formation for binary operationsMichal Muskala
Fixes https://bugs.erlang.org/browse/ERL-406 - a bug introduced in 0377592dc2238f561291be854d2ce859dd9a5fb1
2017-04-12Correct compile_SUITE:core_roundtrip/1Björn Gustavsson
The test is supposed to compare the Core Erlang code that has been printed and parsed back. It did compare and print any differences, but it did not fail when there were differences. Also fix problems with variable names and maps not comparing equal when the inliner has been used.
2017-03-24compiler: Cover beam_record in testsBjörn-Egil Dahlberg
2017-03-21compiler tests: Eliminate creation of untracked filesBjörn Gustavsson
Two dummy .erl files are created while releasing the tests for the compiler. Remove the files after they have been copied to the release directory to avoid that they show up as untracked files in the output of "git status".
2017-03-15Merge pull request #1374 from bjorng/bjorn/compiler/fix-beam_typeBjörn Gustavsson
beam_type: Avoid an internal consistency check failure
2017-03-13beam_type: Avoid an internal consistency check failureBjörn Gustavsson
Code such as the following: -record(x, {a}). f(R, N0) -> N = N0 / 100, if element(1, R#x.a) =:= 0 -> N end. would fail to compile with the following message: m: function f/2+19: Internal consistency check failed - please report this bug. Instruction: {fmove,{fr,0},{x,1}} Error: {uninitialized_reg,{fr,0}}: This bug was introduced in 348b5e6bee2f. Basically, the beam_type pass placed the fmove instruction in the wrong place. Instructions that store to floating point registers and instructions that read from floating point registers are supposed to be in the same basic block. Fix the problem by flushing all floating points instruction before a call the pseudo-BIF is_record/3, thus making sure that the fmove instruction is placed in the correct block. Here is an annotated listing of the relevant part of the .S file (before the fix): {test_heap,{alloc,[{words,0},{floats,1}]},2}. {fconv,{x,1},{fr,0}}. {fmove,{float,100.0},{fr,1}}. fclearerror. {bif,fdiv,{f,0},[{fr,0},{fr,1}],{fr,0}}. {fcheckerror,{f,0}}. %% The instruction {fmove,{fr,0},{x,1}} should have %% been here. %% Block of instructions expanded from a call to %% the pseudo-BIF is_record/3. (Expanded in a later %% compiler pass.) {test,is_tuple,{f,3},[{x,0}]}. {test,test_arity,{f,3},[{x,0},2]}. {get_tuple_element,{x,0},0,{x,2}}. {test,is_eq_exact,{f,3},[{x,2},{atom,x}]}. {move,{atom,true},{x,2}}. {jump,{f,4}}. {label,3}. {move,{atom,false},{x,2}}. {label,4}. %% End of expansion. %% The fmove instruction that beam_validator complains %% about. {fmove,{fr,0},{x,1}}. Reported-by: Richard Carlsson
2017-03-08compiler: Fix handling of locations and annotationsHans Bolinder
2017-02-12Add extra_chunks option to compileJosé Valim
This allow languages such as Elixir and LFE to attach extra chunks to the .beam file without having to parse the beam file after compilation. This commit also cleans up the interface to beam_asm, allowing chunks to be passed from the compiler without a need to change beam_asm API on every new chunk.
2017-02-01Merge branch 'josevalim/atu8-chunk/PR-1078/OTP-14178'Björn Gustavsson
* josevalim/atu8-chunk/PR-1078/OTP-14178: Add new AtU8 beam chunk
2017-01-30Add new AtU8 beam chunkJosé Valim
The new chunk stores atoms encoded in UTF-8. beam_lib has also been modified to handle the new 'utf8_atoms' attribute while the 'atoms' attribute may be a missing chunk from now on. The binary_to_atom/2 BIF can now encode any utf8 binary with up to 255 characters. The list_to_atom/1 BIF can now accept codepoints higher than 255 with up to 255 characters (thanks to Björn Gustavsson).
2017-01-25Update test cases for erlang:hash/2 removalBjörn-Egil Dahlberg
2017-01-17Merge branch 'maint'Björn-Egil Dahlberg
2017-01-17Merge branch 'egil/cuddle-tests' into maintBjörn-Egil Dahlberg
* egil/cuddle-tests: stdlib: Increase timetrap for rand_SUITE common_test: Increase timetrap for cth_hooks_SUITE compiler: Increase timetrap timeouts for lc_SUITE
2016-12-07Add option 'deterministic' for reproducible buildsBjörn Gustavsson
Add the option 'deterministic' to make it easier to achieve reproducible builds. This option omits the {options,...} and {source,...} tuples in M:module_info(compile), because those options may contain absolute paths. The author of ERL-310 suggested that only compiler options that may contain absolute paths (such as {i,...}) should be excluded. But I find it confusing to keep only some options. Alternatives considered: Always omitting this information. Since this information has been available for a long time, that would probably break some workflows. As an example that some people care about {source,...}, 2d785c07fbf9 made it possible to give a compiler option to set {source,...}. ERL-310
2016-12-07Merge branch 'maint'Dan Gudmundsson
* maint: Update copyright-year Conflicts: lib/dialyzer/src/dialyzer.hrl lib/dialyzer/src/dialyzer_options.erl lib/dialyzer/test/opaque_SUITE_data/src/recrec/dialyzer.hrl lib/dialyzer/test/opaque_SUITE_data/src/recrec/dialyzer_races.erl lib/hipe/icode/hipe_icode.erl lib/hipe/main/hipe.erl lib/hipe/main/hipe.hrl.src lib/hipe/main/hipe_main.erl
2016-12-07Update copyright-yearErlang/OTP
2016-12-02Merge branch 'egil/compiler/opt-maps-pattern-matching/OTP-14072'Björn-Egil Dahlberg
* egil/compiler/opt-maps-pattern-matching/OTP-14072: compiler: Add regression tests compiler: Optimize maps pattern matching compiler: Allow for unaligned match argument in value groups
2016-12-01compiler: Add regression testsBjörn-Egil Dahlberg
2016-11-28Merge branch 'egil/compiler/maps-warn-repeated-keys/OTP-14058'Björn-Egil Dahlberg
* egil/compiler/maps-warn-repeated-keys/OTP-14058: compiler: Test repeated map key warnings compiler: Warn for repeated identical map keys
2016-11-23compiler: Test repeated map key warningsBjörn-Egil Dahlberg
2016-11-23Merge branch 'maint'Björn Gustavsson
* maint: Update primary bootstrap document {yield/nb_yield}() limitation Suppress warnings from v3_kernel when inlining is turned on
2016-11-18compile_SUITE: Make sure that guards are optimizedBjörn Gustavsson
Guards should use the more efficient 'test' instructions, not 'bif' instructions. Add a test to make sure that the optimizations don't degrade. We do have to keep an exception list for functions where we can't replace all 'bif' calls with 'test' instructions. We try to keep that list a short as practically possible.
2016-11-18Add test using LFE-generated Core Erlang modulesBjörn Gustavsson
Ensure that correct (not necessarily optimal) code is generated for Core Erlang code not originating from v3_core.
2016-11-18Remove beam_boolBjörn Gustavsson
The guard optimizations in v3_kernel has removed the need for beam_bool.
2016-11-18v3_kernel: Generate optimized code for guardsBjörn Gustavsson
The compiler produces poor code for complex guard expressions with andalso/orelse. Here is an example from the filename module: -define(IS_DRIVELETTER(Letter),(((Letter >= $A) andalso (Letter =< $Z)) orelse ((Letter >= $a) andalso (Letter =< $z)))). skip_prefix(Name, false) -> Name; skip_prefix([L, DrvSep|Name], DrvSep) when ?IS_DRIVELETTER(L) -> Name; skip_prefix(Name, _) -> Name. beam_bool fails to simplify the code for the guard, leaving several 'bif' instructions: {function, skip_prefix, 2, 49}. {label,48}. {line,[{location,"filename.erl",187}]}. {func_info,{atom,filename},{atom,skip_prefix},2}. {label,49}. {test,is_ne_exact,{f,52},[{x,1},{atom,false}]}. {test,is_nonempty_list,{f,52},[{x,0}]}. {get_list,{x,0},{x,2},{x,3}}. {test,is_nonempty_list,{f,52},[{x,3}]}. {get_list,{x,3},{x,4},{x,5}}. {bif,'=:=',{f,52},[{x,1},{x,4}],{x,6}}. {test,is_ge,{f,50},[{x,2},{integer,65}]}. {bif,'=<',{f,52},[{x,2},{integer,90}],{x,7}}. {test,is_eq_exact,{f,51},[{x,7},{atom,false}]}. {test,is_ge,{f,50},[{x,2},{integer,97}]}. {bif,'=<',{f,52},[{x,2},{integer,122}],{x,7}}. {jump,{f,51}}. {label,50}. {move,{atom,false},{x,7}}. {label,51}. {bif,'=:=',{f,52},[{x,7},{atom,true}],{x,7}}. {test,is_eq_exact,{f,52},[{x,6},{atom,true}]}. {test,is_eq_exact,{f,52},[{x,7},{atom,true}]}. {move,{x,5},{x,0}}. return. {label,52}. return. We can add optimizations of guard tests to v3_kernel to achive a better result: {function, skip_prefix, 2, 49}. {label,48}. {line,[{location,"filename.erl",187}]}. {func_info,{atom,filename},{atom,skip_prefix},2}. {label,49}. {test,is_ne_exact,{f,51},[{x,1},{atom,false}]}. {test,is_nonempty_list,{f,51},[{x,0}]}. {get_list,{x,0},{x,2},{x,3}}. {test,is_nonempty_list,{f,51},[{x,3}]}. {get_list,{x,3},{x,4},{x,5}}. {test,is_eq_exact,{f,51},[{x,1},{x,4}]}. {test,is_ge,{f,51},[{x,2},{integer,65}]}. {test,is_lt,{f,50},[{integer,90},{x,2}]}. {test,is_ge,{f,51},[{x,2},{integer,97}]}. {test,is_ge,{f,51},[{integer,122},{x,2}]}. {label,50}. {move,{x,5},{x,0}}. return. {label,51}. return. Looking at the STDLIB application, there were 112 lines of BIF calls in guards that beam_bool failed to convert to test instructions. This commit eliminates all those BIF calls. Here is how I counted the instructions: $ PATH=$ERL_TOP/bin:$PATH erlc -I ../include -I ../../kernel/include -S *.erl $ grep "bif,'[=<>]" *.S | grep -v f,0 dets.S: {bif,'=:=',{f,547},[{x,4},{atom,read_write}],{x,4}}. dets.S: {bif,'=:=',{f,547},[{x,5},{atom,saved}],{x,5}}. dets.S: {bif,'=:=',{f,589},[{x,5},{atom,read}],{x,5}}. . . . $ grep "bif,'[=<>]" *.S | grep -v f,0 | wc 112 224 6765 $