diff options
author | Björn Gustavsson <[email protected]> | 2019-07-29 14:21:51 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2019-07-29 15:34:17 +0200 |
commit | e553fbc8d6e55773172358f75c7e83ab38f0cb4c (patch) | |
tree | 02b6709ff7b155c84643245702eb3b0bed553fca /lib/compiler/src | |
parent | 3967d28c05dae77db30b15e56eb4ececf4f1afef (diff) | |
download | otp-e553fbc8d6e55773172358f75c7e83ab38f0cb4c.tar.gz otp-e553fbc8d6e55773172358f75c7e83ab38f0cb4c.tar.bz2 otp-e553fbc8d6e55773172358f75c7e83ab38f0cb4c.zip |
Fix unsafe code sharing
Diffstat (limited to 'lib/compiler/src')
-rw-r--r-- | lib/compiler/src/beam_ssa_share.erl | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/compiler/src/beam_ssa_share.erl b/lib/compiler/src/beam_ssa_share.erl index 426efa2cc9..73983bd34a 100644 --- a/lib/compiler/src/beam_ssa_share.erl +++ b/lib/compiler/src/beam_ssa_share.erl @@ -303,8 +303,12 @@ canonical_is([#b_ret{arg=Arg}], VarMap, Acc0) -> Acc0 end, {{ret,canonical_arg(Arg, VarMap),Acc1},VarMap}; -canonical_is([#b_br{bool=#b_var{},fail=Fail}], VarMap, Acc) -> - {{br,succ,Fail,Acc},VarMap}; +canonical_is([#b_br{bool=#b_var{}=Arg,fail=Fail}], VarMap, Acc) -> + %% A previous buggy version of this code omitted the canonicalized + %% argument in the return value. Unfortunately, that worked most + %% of the time, except when `br` terminator referenced a variable + %% defined in a previous block instead of in the same block. + {{br,canonical_arg(Arg, VarMap),succ,Fail,Acc},VarMap}; canonical_is([#b_br{succ=Succ}], VarMap, Acc) -> {{br,Succ,Acc},VarMap}; canonical_is([], VarMap, Acc) -> |