From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Dibyendu Majumdar <mobile@majumdar.org.uk>,
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 03/13] llvm: fix output_op_store() which modify its operand
Date: Sun, 5 Mar 2017 12:20:37 +0100 [thread overview]
Message-ID: <20170305112047.3411-4-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170305112047.3411-1-luc.vanoostenryck@gmail.com>
In sparse-llvm the field 'priv' of a pseudo is used to store
the corresponding LLVMValueRef. This field is normaly assigned
when processing the instruction that produces the speudo.
In output_op_store(), the field insn->target->priv is overwritten
by the LLVMValueRef returned by LLVMBuildStore().
It's unclear what this return value is:
- this corrupts the pseudo, making it unusable in subsequent
instructions.
- there is no reason to change this field anyway.
Fix this by removing the assignment to insn->target->priv
in output_op_store().
Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
sparse-llvm.c | 6 ++----
validation/backend/store-x2.c | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 4 deletions(-)
create mode 100644 validation/backend/store-x2.c
diff --git a/sparse-llvm.c b/sparse-llvm.c
index d48b3b20a..665b6c7dc 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -646,16 +646,14 @@ static void output_op_load(struct function *fn, struct instruction *insn)
static void output_op_store(struct function *fn, struct instruction *insn)
{
- LLVMValueRef addr, target, target_in;
+ LLVMValueRef addr, target_in;
addr = calc_memop_addr(fn, insn);
target_in = pseudo_to_value(fn, insn, insn->target);
/* perform store */
- target = LLVMBuildStore(fn->builder, target_in, addr);
-
- insn->target->priv = target;
+ LLVMBuildStore(fn->builder, target_in, addr);
}
static LLVMValueRef bool_value(struct function *fn, LLVMValueRef value)
diff --git a/validation/backend/store-x2.c b/validation/backend/store-x2.c
new file mode 100644
index 000000000..5ccc9b43a
--- /dev/null
+++ b/validation/backend/store-x2.c
@@ -0,0 +1,16 @@
+void foo(int *p, int a, int b);
+void foo(int *p, int a, int b)
+{
+ int c = a + b;
+
+ p[0] = c;
+ p[1] = c;
+}
+
+/*
+ * check-name: store-x2
+ * check-command: sparsec -c $file -o tmp.o
+ * check-description: Verify in output_op_store() that
+ * the first store doesn't mess anymore with the
+ * 'target' and thus making the second store unusable.
+ */
--
2.11.1
next prev parent reply other threads:[~2017-03-05 11:30 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-05 11:20 [WIP 00/13] LLVM fixes Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 01/13] llvm: add a helper to convert an integer to a ValueRef Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 02/13] llvm: fix translation of PSEUDO_VALs into a ValueRefs Luc Van Oostenryck
2017-03-07 15:11 ` Christopher Li
2017-03-07 16:18 ` Luc Van Oostenryck
2017-03-07 22:48 ` Christopher Li
2017-03-05 11:20 ` Luc Van Oostenryck [this message]
2017-03-05 11:20 ` [PATCH 04/13] llvm: fix output_op_[ptr]cast() Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 05/13] add get_nth1_arg() Luc Van Oostenryck
2017-03-06 14:40 ` Christopher Li
2017-03-06 16:52 ` Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 06/13] llvm: fix type of literal integer passed as arguments Luc Van Oostenryck
2017-03-06 14:56 ` Christopher Li
2017-03-07 15:33 ` Christopher Li
2017-03-07 16:21 ` Luc Van Oostenryck
2017-03-07 19:41 ` Dibyendu Majumdar
2017-03-10 16:08 ` Dibyendu Majumdar
2017-03-10 17:47 ` Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 07/13] llvm: fix output OP_ADD mixed with pointers Luc Van Oostenryck
2017-03-06 15:16 ` Christopher Li
2017-03-06 15:32 ` Dibyendu Majumdar
2017-03-06 16:22 ` Christopher Li
2017-03-06 16:43 ` Luc Van Oostenryck
2017-03-06 17:06 ` Dibyendu Majumdar
2017-03-06 19:50 ` Luc Van Oostenryck
2017-03-06 17:07 ` Christopher Li
2017-03-06 19:52 ` Luc Van Oostenryck
2017-03-06 21:15 ` [PATCH v2] " Luc Van Oostenryck
2017-03-06 18:17 ` [PATCH 07/13] " Linus Torvalds
2017-03-06 20:09 ` Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 08/13] llvm: add support for OP_NEG Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 09/13] give a type to OP_PHISOURCE Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 10/13] give a type to OP_SEL, always Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 11/13] llvm: remove unneeded arg 'module' Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 12/13] llvm: remove unneeded arg 'fn' Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 13/13] llvm: fix: do not mix pointers and floats when doing compares Luc Van Oostenryck
2017-03-06 1:47 ` [WIP 00/13] LLVM fixes Christopher Li
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=20170305112047.3411-4-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=mobile@majumdar.org.uk \
/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).