From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH] unop: fix access to defining instruction in simplify_unop()
Date: Tue, 6 Oct 2020 18:43:58 +0200 [thread overview]
Message-ID: <20201006164358.37772-1-luc.vanoostenryck@gmail.com> (raw)
Only pseudos of type PSEUDO_REG have a defining instruction.
However, in commit 5425db10d4d3 ("simplify '~(~x)' and '-(-x)' to 'x'"),
this defining instruction of the 'src' of the outer unop
was accessed without checking the type.
Fixes: 5425db10d4d35895ba3ca390478c624233ec027d
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
simplify.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/simplify.c b/simplify.c
index 76c0558855a2..15452a585598 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1311,13 +1311,11 @@ static int simplify_unop(struct instruction *insn)
struct instruction *def;
case OP_NOT:
- def = insn->src->def;
- if (def && def->opcode == OP_NOT)
+ if (DEF_OPCODE(def, insn->src) == OP_NOT)
return replace_with_pseudo(insn, def->src);
break;
case OP_NEG:
- def = insn->src->def;
- if (def && def->opcode == OP_NEG)
+ if (DEF_OPCODE(def, insn->src) == OP_NEG)
return replace_with_pseudo(insn, def->src);
break;
default:
--
2.28.0
reply other threads:[~2020-10-06 16:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201006164358.37772-1-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).