diff options
author | Björn Gustavsson <[email protected]> | 2017-06-07 14:27:15 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2017-06-07 16:32:35 +0200 |
commit | 09112806c15a81be86730503af36e304ac11d1ed (patch) | |
tree | 8f66b637b02762737f4e91bd7077428c736fed0e /lib/compiler/src/compile.erl | |
parent | 1ee59088c52ff18e3917d7f453a5947d0fe1cadd (diff) | |
download | otp-09112806c15a81be86730503af36e304ac11d1ed.tar.gz otp-09112806c15a81be86730503af36e304ac11d1ed.tar.bz2 otp-09112806c15a81be86730503af36e304ac11d1ed.zip |
Fix unsafe bit syntax matching optimization
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.
Diffstat (limited to 'lib/compiler/src/compile.erl')
-rw-r--r-- | lib/compiler/src/compile.erl | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index c6e61d543e..d05b8a9530 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -718,8 +718,10 @@ core_passes() -> | kernel_passes()]. kernel_passes() -> - %% Destructive setelement/3 optimization and core lint. - [{pass,sys_core_dsetel}, + %% Optimizations that must be done after all other optimizations. + [{pass,sys_core_bsm}, + {iff,dcbsm,{listing,"core_bsm"}}, + {pass,sys_core_dsetel}, {iff,dsetel,{listing,"dsetel"}}, {iff,clint,?pass(core_lint_module)}, @@ -1919,6 +1921,7 @@ pre_load() -> erl_lint, erl_parse, erl_scan, + sys_core_bsm, sys_core_dsetel, sys_core_fold, v3_codegen, |