summaryrefslogtreecommitdiff
path: root/lib/compiler
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | | | Merge branch 'john/erts/fix-hd-tl-loader-transformations/GH-7024/OTP-18519' ↵John Högberg2023-03-221-2/+26
| |\ \ \ \ \ | | | |_|_|/ | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | into maint * john/erts/fix-hd-tl-loader-transformations/GH-7024/OTP-18519: jit: Fix hd/1 and tl/1 BIF specialization
| | * | | | jit: Fix hd/1 and tl/1 BIF specializationJohn Högberg2023-03-161-2/+26
| | |/ / / | | | | | | | | | | | | | | | | | | | | While we're at it, remove related loader transformations that only kicks in for unoptimized code.
* | | | | Revert "Prepare release"Henrik Nord2023-03-223-87/+2
| | | | | | | | | | | | | | | | | | | | This reverts commit 1cf126f91eb533783409da95b117207d8c13d9aa.
* | | | | Prepare releaseErlang/OTP2023-03-213-2/+87
| | | | |
* | | | | Update copyright yearErlang/OTP2023-03-219-9/+9
| | | | |
* | | | | Merge branch 'john/compiler/inline-maps-get-3/OTP-18502'John Högberg2023-03-161-4/+6
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | * john/compiler/inline-maps-get-3/OTP-18502: sys_core_fold: Fix rewriting complex dynamic keys on maps:get/3
| * | | | | sys_core_fold: Fix rewriting complex dynamic keys on maps:get/3John Högberg2023-03-151-4/+6
| | | | | |
* | | | | | Merge branch 'maint'John Högberg2023-03-152-2/+19
|\ \ \ \ \ \ | |/ / / / / |/| / / / / | |/ / / / | | | | | * maint: beam_validator: Skip unnecessary type updates
| * | | | Merge branch 'john/compiler/fix-inert-update-type/GH-6969/OTP-18516' into maintJohn Högberg2023-03-152-2/+19
| |\ \ \ \ | | | |_|/ | | |/| | | | | | | | | | | | * john/compiler/fix-inert-update-type/GH-6969/OTP-18516: beam_validator: Skip unnecessary type updates
| | * | | beam_validator: Skip unnecessary type updatesJohn Högberg2023-03-032-2/+19
| | | | |
* | | | | Merge pull request #7003 from jhogberg/john/compiler/inline-maps-get-3/OTP-18502John Högberg2023-03-141-3/+30
|\ \ \ \ \ | | | | | | | | | | | | sys_core_fold: Inline maps:get/3
| * | | | | sys_core_fold: Inline maps:get/3John Högberg2023-03-101-3/+30
| | | | | |
* | | | | | compiler: Remove dead code in private appendFrej Drejhammar2023-03-131-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When 0bac830c937c7c39b6aae37a73bd135841dde969 was created, the element forms to be considered were taken from patch_literal_term/3. As the tuple_elements-form is only created after the tracking phase, it will never be encountered in get_results/5. Likewise the Element variable is never a list, as it is generated by patch_appends_ret/3
* | | | | | compiler: Avoid crash during value tracking in private appendFrej Drejhammar2023-03-132-2/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the private append pass we track values which could be bitstrings or a term containing a bitstring to find the operation where the bitstring is constructed. For the purpose of this description, we call such a value a potential bitstring. As tracking potential bitstrings is done without correlating type checks and flow-control, we can sometimes encounter values which are not potential bitstrings. In 0bac830c937c7c39b6aae37a73bd135841dde969 the tracking logic was refined to abort as soon as we detected that a returned literal could not be on an execution path returning a potential bitstring. This commit extends the tracking logic to abort tracking when a potential bitstring is constructed by an operation which cannot produce a bitstring or a term containing a bitstring. Closes #7011
* | | | | | compiler: Be stricter when tracking values in private appendFrej Drejhammar2023-03-102-9/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tracking values to patch into writable binaries in the private append pass doesn't make any attempt to use type information to exclude execution paths not relevant when tracking an appendable binary. In order to avoid later failed attempts to rewrite non-bitstring literals into bs_init_writable-created values during the rewrite phase, we change the tracking phase to preemptively abort tracking as soon as we detect that the element we are tracking can't apply to the literal. Closes #6999
* | | | | | Merge branch 'maint'Björn Gustavsson2023-03-102-18/+34
|\ \ \ \ \ \ | | |/ / / / | |/| | | | | | | | | | | | | | | | * maint: Fix lost exception from map update
| * | | | | Merge pull request #6965 from ↵Björn Gustavsson2023-03-102-17/+31
| |\ \ \ \ \ | | |_|_|/ / | |/| | | / | | | |_|/ | | |/| | bjorng/bjorn/compiler/fix-lost-map-exception/GH-6960/OTP-18497 Fix lost exception from map update
| | * | | Fix lost exception from map updateBjörn Gustavsson2023-03-032-17/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix an unsafe optimization that would remove a map update operation that is supposed fail. For example: foo() -> #{}#{key := value}, ok. Instead of raising an exception, `foo/0` would return `ok`. Closes #6960
* | | | | Merge pull request #6992 from bjorng/bjorn/compiler/fix-unfold-literalsBjörn Gustavsson2023-03-092-2/+18
|\ \ \ \ \ | | | | | | | | | | | | Eliminate assertion failure in beam_ssa_codegen
| * | | | | Eliminate assertion failure in beam_ssa_codegenBjörn Gustavsson2023-03-082-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the code in `?EXCEPTION_BLOCK` is modified in any way, the `beam_ssa_codegen:assert_exception_block/1` function will cause an internal compiler error. Ensure that the literal unfolding optimization in `beam_ssa_opt` will not modify the code in `?EXCEPTION_BLOCK`.
* | | | | | Merge pull request #6977 from bjorng/bjorn/compiler/use-map-comprehensionsBjörn Gustavsson2023-03-097-39/+25
|\ \ \ \ \ \ | |_|_|_|/ / |/| | | | | compiler: Use map comprehensions instead of maps:filter/2
| * | | | | compiler: Use map generators instead of maps:fold/3Björn Gustavsson2023-03-075-23/+14
| | | | | |
| * | | | | compiler: Use map comprehensions instead of maps:filter/2Björn Gustavsson2023-03-074-16/+11
| |/ / / /
* | | | | Merge branch 'maint' into masterHenrik Nord2023-03-082-1/+41
|\ \ \ \ \ | |/ / / / |/| / / / | |/ / / | | | | | | | | | | | | * maint: Updated OTP version Prepare release Update copyright year
| * | | Prepare releaseErlang/OTP2023-03-062-1/+41
| | | |
| * | | Update copyright yearErlang/OTP2023-03-066-6/+6
| | |/ | |/|
* | | Merge pull request #6964 from jhogberg/john/compiler/singleton-inference/GH-6962John Högberg2023-03-063-12/+44
|\ \ \ | | | | | | | | beam_validator: Fix inference on singleton types in registers
| * | | beam_validator: Fix inference on singleton types in registersJohn Högberg2023-03-023-12/+44
| | | | | | | | | | | | | | | | | | | | Type inference with singleton types in registers was weaker than inference on their corresponding literals.
* | | | Merge pull request #6968 from frej/frej/alias-optBjörn Gustavsson2023-03-061-10/+22
|\ \ \ \ | | | | | | | | | | compiler: Cache use/def sets in alias analysis pass
| * | | | compiler: Cache use/def sets in alias analysis passFrej Drejhammar2023-03-031-10/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reduce the cost of the alias analysis pass by hoisting the calculation of use and def sets out of the liveness fixpoint iteration using a cache. On the modules compiled by `scripts/diffable` the time spent in the alias analysis pass is reduced by 16%.
* | | | | Fix compilation error with disabled optimizationsBjörn Gustavsson2023-03-042-13/+37
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider this code: -module(t). -export([foo/0, bar/4]). foo() -> bar(ok, 0 div 0, node(), [-1]). bar(_, _, _, _) -> ok. It fails to compile when some optimizations are turned off: $ erlc +no_copt +no_ssa_opt t.erl t:1: function foo/0+7: Internal consistency check failed - please report this bug. Instruction: {test_heap,2,2} Error: {{x,0},not_live}:
* | | | compiler: Use map comprehensionsBjörn Gustavsson2023-03-011-2/+2
| | | |
* | | | Merge pull request #6934 from bjorng/bjorn/compiler/element/GH-6927Björn Gustavsson2023-03-012-27/+42
|\ \ \ \ | | | | | | | | | | beam_call_types: Fix inconsistency
| * | | | beam_call_types: Fix inconsistencyBjörn Gustavsson2023-02-272-27/+42
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `beam_validator` pass would reject the following code: f(X) -> element(42, case X of {_,_} -> X; _ -> ok end). The reason is an inconsistency between the return values of the functions `will_succeed/3` and `types/3` in the `beam_call_types` module. When `types/3` returns `none` (indicating that the call always fails), `will_succeed/3` MUST return `no`. Otherwise, `beam_validator` will reject the code. In this case, when asked whether the call to `element/2` would succeed, `will_succeed/3` answered `maybe`, while `types/3` returned `none`. To avoid similar bugs in the future, this commit not only fixes the inconsistency, but also refactors `will_succeed/3` to always let the new helper function `fails_on_conflict/3` handle the `maybe` case, ensuring that whenever `types/3` returns `none`, then `will_succeed/3` returns `no`. Closes #6927 Co-authored-by: John Högberg <john@erlang.org>
* | | | Merge pull request #6930 from frej/frej/gh-6925-fix-bincomprehension-appendBjörn Gustavsson2023-03-014-64/+108
|\ \ \ \ | | | | | | | | | | compiler: Avoid unsafe rewrite to bs_create_bin private_append
| * | | | compiler: Avoid unsafe rewrite to bs_create_bin private_appendFrej Drejhammar2023-02-274-64/+108
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Nick Vatamaniuc reported that the following Erlang snippet: ``` B1 = << <<"x">> || true >>, B2 = <<B1/binary, "z">>, ``` created identical `B1` and `B2` binaries. The error occurs because the private-append pass was missing the condition that for a transform from `bs_create_bin append, ...` to `bs_create_bin private_append, ...` to be safe, the first fragment must die with the `bs_create_bin` instruction, it is not enough that the fragment is unique and appendable. The error is avoided by having the alias analysis, which has access to liveness information, annotate `bs_create_bin` instructions with a boolean annotation indicating whether the first fragment dies with the instruction. The later private-append pass can then consult the annotation to determine if the transform is safe. The use of an annotation is more efficient than trying to reconstruct the information in the alias analysis kill map during the private-append pass. Fixes #6925
* | | | Correct unsafe optimization of binary matchingBjörn Gustavsson2023-02-272-7/+76
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When compiling generated code from forms where the line numbers in the annotations did not correspond to the actual order of the clauses, the compiler could rearrange clauses even when it was not safe. For example: match_route([<<"prefix">>, <<"action">>]) -> first; %Line 4 match_route([<<"prefix">>, _Ignore]) -> second. %Line 2 The compiler would rearrange that to: match_route([<<"prefix">>, _Ignore]) -> second; %Line 2 match_route([<<"prefix">>, <<"action">>]) -> first. %Line 4 which would make the second clause (former first clause) unreachable. This bug was introduced in cadd19e84478ed (#6538). Closes #6923
* | | compiler: Clean up development cruft in alias analysis, NFCFrej Drejhammar2023-02-241-4/+3
| | | | | | | | | | | | Remove unused variables and debug code, no functional change.
* | | compiler: Avoid unnecessary work in alias analysisFrej Drejhammar2023-02-241-8/+33
| | | | | | | | | | | | | | | | | | Avoid repeatedly traversing functions which are not directly influenced by changes in the alias information while iterating to find a fix point during alias analysis.
* | | compiler: Traverse call graph breadth first during alias analysisFrej Drejhammar2023-02-233-3/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During alias analysis the main data flow of alias information is from caller to callee when the aliasing status of function arguments are transferred. A smaller flow goes from the callee to the caller with the information about the returned value. As up to date alias status is needed at call sites (derived from the status of the caller's own arguments) and the status recorded at all callsites is what allows the analysis of the callee to provide a status for the returned result in the caller, convergence of the alias analysis can be greatly sped up by traversing the call graph breadth first.
* | | Merge branch 'maint' into masterIngela Anderton Andin2023-02-231-0/+22
|\ \ \ | |/ / | | | | | | | | | | | | | | | * maint: Updated OTP version Prepare release Update copyright year
| * | Merge branch 'maint-24' into maintIngela Anderton Andin2023-02-234-3/+25
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | * maint-24: Updated OTP version Prepare release Update copyright year
| | * | Prepare releaseErlang/OTP2023-02-222-1/+23
| | | |
| | * | Update copyright yearErlang/OTP2023-02-223-3/+3
| | | |
| | * | Merge branch 'bjorn/compiler/fix-mutable-variables/24/GH-6873/OTP-18470' ↵Erlang/OTP2023-02-223-90/+117
| | |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | into maint-24 * bjorn/compiler/fix-mutable-variables/24/GH-6873/OTP-18470: Eliminate "mutable variables"
* | | \ \ Merge pull request #6908 from frej/frej/alias-analysis-coverBjörn Gustavsson2023-02-232-1/+42
|\ \ \ \ \ | | | | | | | | | | | | compiler: Improve code coverage in alias analysis
| * | | | | compiler: Improve code coverage in alias analysisFrej Drejhammar2023-02-202-1/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a test case which exercises the portions of the alias analysis which deals with a non-converging fixpoint iteration.
* | | | | | Merge pull request #6905 from frej/frej/fix-broken-makefun-aliasBjörn Gustavsson2023-02-232-136/+177
|\ \ \ \ \ \ | | | | | | | | | | | | | | compiler: Fix mishandling of make_fun in alias analysis
| * | | | | | compiler: Fix mishandling of make_fun in alias analysisFrej Drejhammar2023-02-202-136/+177
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a value is copied into the environment of a fun, alias analysis should assume that it has been aliased as there is no obvious way to track and ensure that the value is only used once, even if the argument dies at the location of the make_fun. Closes #6890
* | | | | | Merge pull request #6842 from jhogberg/john/compiler/infer-more-arithmeticJohn Högberg2023-02-221-6/+20
|\ \ \ \ \ \ | | | | | | | | | | | | | | beam_call_types: Infer range of various arithmetic operations