move check_access() to late_warnings()
PATCH 1/1 move check_access() to late_warnings()
check_access() is called at each run of simplify_loads().
However, a bad access can belong to a dead branch and thus a bad access warning can be issued for code that is not executed, maybe specifically excluded.
So, move check_access() to late_warnings(), where all optimizations have been done.
Signed-off-by Luc Van Oostenryck <[email protected]>
--- linearize.c | 6 ++++++ memops.c | 3 --- validation/bad-check-access0.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 validation/bad-check-access0.c
linearize.c +6 -0
@@ -2532,6 +2532,12 @@ static void late_warnings(struct entrypoint *ep)continue ;if (insn->tainted)check_tainted_insn (insn); +switch (insn->opcode) { +case OP_LOAD : +// Check for illegal offsets. +check_access (insn); +break ; + } }END_FOR_EACH_PTR (insn); }END_FOR_EACH_PTR (bb); }
memops.c +0 -3
@@ -147,9 +147,6 @@ static void simplify_loads(struct basic_block *bb)struct pseudo_list *dominators;unsigned long generation; -/* Check for illegal offsets.. */ -check_access (insn); -if (insn->is_volatile)continue ;
validation/bad-check-access0.c new file +31 -0
@@ -0,0 +1,31 @@ +#define SIZE 2 +static int buf[SIZE ]; + +static inline int swt (int i) +{ +switch (i) { + case 0 ... (SIZE-1): +return buf[i]; +default : +return 0 ; + } +} + +static int switch_ok (void ) {return swt (1 ); } +static int switch_ko (void ) {return swt (2 ); } + + +static inline int cbr (int i,int p) +{ +if (p) +return buf[i]; +else +return 0 ; +} + +static int branch_ok (int x) {return cbr (1 , x != x); } +static int branch_ko (int x) {return cbr (2 , x != x); } + +/* +* check-name: bad-check-access0 +*/
Signature · 1 line
2.29.2