diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-07-23 15:12:22 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-07-23 20:24:42 +0200 |
| commit | 6123e95d79f0050befa6cfd69d5bcf198ca0a255 (patch) | |
| tree | 141b103f3de66d6e30cdfc28eedb8565cc6dd68c | |
| parent | f22be7c4b6f98605a7888eed55bf26955d866cc8 (diff) | |
| download | sparse-dev-6123e95d79f0050befa6cfd69d5bcf198ca0a255.tar.gz | |
big-shift: move shift count check in a separate function
No functional changes here.
Just moving code around to prepare the following patch.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | simplify.c | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -539,6 +539,21 @@ undef: return NULL; } +static long long check_shift_count(struct instruction *insn, unsigned long long uval) +{ + unsigned int size = insn->size; + + if (uval < size) + return uval; + if (insn->tainted) + return uval; + + if (Wshift_count_overflow) { + warning(insn->pos, "shift by bigger than operand's width"); + } + insn->tainted = 1; + return uval; +} static int simplify_shift(struct instruction *insn, pseudo_t pseudo, long long value) { @@ -546,13 +561,9 @@ static int simplify_shift(struct instruction *insn, pseudo_t pseudo, long long v if (!value) return replace_with_pseudo(insn, pseudo); + value = check_shift_count(insn, value); size = insn->size; - if (value >= size && !insn->tainted) { - if (Wshift_count_overflow) - warning(insn->pos, "shift by bigger than operand's width"); - insn->tainted = 1; - } switch (insn->opcode) { case OP_ASR: break; |
