From 7347790c9d99e71b342d981cec5110b4177190c2 Mon Sep 17 00:00:00 2001 From: "Tobias S. Josefowitz" <tobij@tobij.de> Date: Sat, 2 Nov 2019 20:14:57 +0100 Subject: [PATCH] Optimizer: Be more careful when optimizing away assignments Checking for SCOPE_SCOPED is too agressive, check for SCOPE_SCOPE_USED instead. --- CHANGES | 4 ++++ src/peep.in | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 2ef647fd73..541ba1a720 100644 --- a/CHANGES +++ b/CHANGES @@ -91,6 +91,10 @@ o Compiler - Fixed some corner cases where file names where missing from backtraces. + - Check the proper flag to determine if a local variable may be used + before optimizing away certain assignments if the assignment is + immediately followed by a return of the variable in question. + Crypto.ECC Now works against Nettle 3.5. diff --git a/src/peep.in b/src/peep.in index bb7e5d754e..7c27227e49 100644 --- a/src/peep.in +++ b/src/peep.in @@ -216,8 +216,8 @@ ASSIGN_GLOBAL_AND_POP GLOBAL_LVALUE($1a) DEC_AND_POP : ADD_NEG_INT(1) ASSIGN_GLO GLOBAL_LVALUE INC_AND_POP GLOBAL($1a) : GLOBAL_LVALUE($1a) INC GLOBAL_LVALUE DEC_AND_POP GLOBAL($1a) : GLOBAL_LVALUE($1a) DEC -ASSIGN_LOCAL RETURN [!(Pike_compiler->compiler_frame->lexical_scope & SCOPE_SCOPED)]: RETURN -ASSIGN_LOCAL VOLATILE_RETURN [!(Pike_compiler->compiler_frame->lexical_scope & SCOPE_SCOPED)]: VOLATILE_RETURN +ASSIGN_LOCAL RETURN [!(Pike_compiler->compiler_frame->lexical_scope & SCOPE_SCOPE_USED)]: RETURN +ASSIGN_LOCAL VOLATILE_RETURN [!(Pike_compiler->compiler_frame->lexical_scope & SCOPE_SCOPE_USED)]: VOLATILE_RETURN ASSIGN_LOCAL BRANCH_WHEN_ZERO LOCAL($1a) RETURN LABEL($2a): ASSIGN_LOCAL($1a) RETURN_IF_TRUE LABEL($2a) ASSIGN_LOCAL BRANCH_WHEN_ZERO LOCAL($1a) VOLATILE_RETURN LABEL($2a): ASSIGN_LOCAL($1a) RETURN_IF_TRUE LABEL($2a) -- GitLab