From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Christopher Li <sparse@chrisli.org>,
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH] fix usage in simplify_seteq_setne()
Date: Fri, 24 Feb 2017 07:54:34 +0100 [thread overview]
Message-ID: <20170224065434.46976-1-luc.vanoostenryck@gmail.com> (raw)
The usage was removed before the new operands were used
which can lead to undefined pseudos.
Fix this by moving the call to remove_usage() where
it should always have been: after the call to use_pseudo().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
simplify.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/simplify.c b/simplify.c
index 3bc9985e8..76a599e50 100644
--- a/simplify.c
+++ b/simplify.c
@@ -432,7 +432,8 @@ static int compare_opcode(int opcode, int inverse)
static int simplify_seteq_setne(struct instruction *insn, long long value)
{
- struct instruction *def = insn->src1->def;
+ pseudo_t old = insn->src1;
+ struct instruction *def = old->def;
pseudo_t src1, src2;
int inverse;
int opcode;
@@ -456,10 +457,10 @@ static int simplify_seteq_setne(struct instruction *insn, long long value)
// and similar for setne/eq ... 0/1
src1 = def->src1;
src2 = def->src2;
- remove_usage(insn->src1, &insn->src1);
insn->opcode = compare_opcode(opcode, inverse);
use_pseudo(insn, src1, &insn->src1);
use_pseudo(insn, src2, &insn->src2);
+ remove_usage(old, &insn->src1);
return REPEAT_CSE;
default:
--
2.11.1
reply other threads:[~2017-02-24 6:56 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=20170224065434.46976-1-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.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).