linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] sparse-llvm: avoid SIGSEGV for function prototypes
@ 2015-05-16 22:32 Azat Khuzhin
  2015-05-16 22:32 ` [PATCH 1/2] sparse, llvm: compile: skip function prototypes to avoid SIGSEGV Azat Khuzhin
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Azat Khuzhin @ 2015-05-16 22:32 UTC (permalink / raw)
  To: Sparse ML; +Cc: Azat Khuzhin

Description is in the first patch, and the second patch contains regression.

Thanks!

Azat Khuzhin (2):
  sparse, llvm: compile: skip function prototypes to avoid SIGSEGV
  validation/prototype: regression for skipping prototypes

 sparse-llvm.c          | 11 +++++++++++
 validation/prototype.c |  6 ++++++
 2 files changed, 17 insertions(+)
 create mode 100644 validation/prototype.c

-- 
2.1.4


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] sparse, llvm: compile: skip function prototypes to avoid SIGSEGV
  2015-05-16 22:32 [PATCH 0/2] sparse-llvm: avoid SIGSEGV for function prototypes Azat Khuzhin
@ 2015-05-16 22:32 ` Azat Khuzhin
  2015-06-12  0:50   ` Christopher Li
  2015-05-16 22:32 ` [PATCH 2/2] validation/prototype: regression for skipping prototypes Azat Khuzhin
  2015-06-12  5:20 ` [PATCH 1/2 v2] sparse, llvm: compile: skip function prototypes to avoid SIGSEGV Azat Khuzhin
  2 siblings, 1 reply; 9+ messages in thread
From: Azat Khuzhin @ 2015-05-16 22:32 UTC (permalink / raw)
  To: Sparse ML; +Cc: Azat Khuzhin

You can't pass function to LLVMConstNull(), according to
Constant::getNullValue, and sparse-llvm already handle functions differently
(i.e. there will be no call to LLVMConstNull(), but this is not true for
function prototypes, because of how linearize_fn() works:
```
static struct entrypoint *linearize_fn(...)
{
  ...
  if (!base_type->stmt)
    return NULL;
  ...
}
```

```
Constant *Constant::getNullValue(Type *Ty) {
  switch (Ty->getTypeID()) {
  ...
  default:
    // Function, Label, or Opaque type?
    llvm_unreachable("Cannot create a null constant of that type!");
  }
}
```
---
 sparse-llvm.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sparse-llvm.c b/sparse-llvm.c
index ecb5b28..6b41afd 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -1070,6 +1070,13 @@ static LLVMValueRef output_data(LLVMModuleRef module, struct symbol *sym)
 	return data;
 }
 
+static int is_prototype(struct symbol *sym)
+{
+	if (sym->type == SYM_NODE)
+		sym = sym->ctype.base_type;
+	return sym && sym->type == SYM_FN && !sym->stmt;
+}
+
 static int compile(LLVMModuleRef module, struct symbol_list *list)
 {
 	struct symbol *sym;
@@ -1077,6 +1084,10 @@ static int compile(LLVMModuleRef module, struct symbol_list *list)
 	FOR_EACH_PTR(list, sym) {
 		struct entrypoint *ep;
 		expand_symbol(sym);
+
+		if (is_prototype(sym))
+			continue;
+
 		ep = linearize_symbol(sym);
 		if (ep)
 			output_fn(module, ep);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] validation/prototype: regression for skipping prototypes
  2015-05-16 22:32 [PATCH 0/2] sparse-llvm: avoid SIGSEGV for function prototypes Azat Khuzhin
  2015-05-16 22:32 ` [PATCH 1/2] sparse, llvm: compile: skip function prototypes to avoid SIGSEGV Azat Khuzhin
@ 2015-05-16 22:32 ` Azat Khuzhin
  2015-05-17 18:40   ` Jonathan Neuschäfer
  2015-06-12  5:20 ` [PATCH 1/2 v2] sparse, llvm: compile: skip function prototypes to avoid SIGSEGV Azat Khuzhin
  2 siblings, 1 reply; 9+ messages in thread
From: Azat Khuzhin @ 2015-05-16 22:32 UTC (permalink / raw)
  To: Sparse ML; +Cc: Azat Khuzhin

---
 validation/prototype.c | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 validation/prototype.c

diff --git a/validation/prototype.c b/validation/prototype.c
new file mode 100644
index 0000000..481cc93
--- /dev/null
+++ b/validation/prototype.c
@@ -0,0 +1,6 @@
+static int prototype(void);
+
+/*
+ * check-name: Compile skip function prototype
+ * check-command: ./sparsec -c $file -o tmp.o
+ */
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] validation/prototype: regression for skipping prototypes
  2015-05-16 22:32 ` [PATCH 2/2] validation/prototype: regression for skipping prototypes Azat Khuzhin
@ 2015-05-17 18:40   ` Jonathan Neuschäfer
  2015-05-17 18:53     ` Azat Khuzhin
  0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Neuschäfer @ 2015-05-17 18:40 UTC (permalink / raw)
  To: Azat Khuzhin; +Cc: linux-sparse

> Subject: [PATCH 2/2] validation/prototype: regression for skipping prototypes

This is not a regression, but a regression test.

A regression means that previously working functionality breaks, and
regression tests can detect regressions by testing that certain
functionality still works.


Best regards,
Jonathan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] validation/prototype: regression for skipping prototypes
  2015-05-17 18:40   ` Jonathan Neuschäfer
@ 2015-05-17 18:53     ` Azat Khuzhin
  0 siblings, 0 replies; 9+ messages in thread
From: Azat Khuzhin @ 2015-05-17 18:53 UTC (permalink / raw)
  To: Jonathan Neuschäfer; +Cc: linux-sparse

On Sun, May 17, 2015 at 08:40:05PM +0200, Jonathan Neuschäfer wrote:
> > Subject: [PATCH 2/2] validation/prototype: regression for skipping prototypes
> 
> This is not a regression, but a regression test.

Yep, it is a regression test, thanks!
By some reason, I though that "validation" prefix will be enough.
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] sparse, llvm: compile: skip function prototypes to avoid SIGSEGV
  2015-05-16 22:32 ` [PATCH 1/2] sparse, llvm: compile: skip function prototypes to avoid SIGSEGV Azat Khuzhin
@ 2015-06-12  0:50   ` Christopher Li
  2015-06-12  5:18     ` Azat Khuzhin
  0 siblings, 1 reply; 9+ messages in thread
From: Christopher Li @ 2015-06-12  0:50 UTC (permalink / raw)
  To: Azat Khuzhin; +Cc: Sparse ML

On Sat, May 16, 2015 at 3:32 PM, Azat Khuzhin <a3at.mail@gmail.com> wrote:
>
> You can't pass function to LLVMConstNull(), according to
> Constant::getNullValue, and sparse-llvm already handle functions differently
> (i.e. there will be no call to LLVMConstNull(), but this is not true for


The patch looks good. I am applying it. However I just notice that you did not
provide the signed-off-by line.

Can you resend both patch with the signed off line?

Thanks

Chris

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] sparse, llvm: compile: skip function prototypes to avoid SIGSEGV
  2015-06-12  0:50   ` Christopher Li
@ 2015-06-12  5:18     ` Azat Khuzhin
  0 siblings, 0 replies; 9+ messages in thread
From: Azat Khuzhin @ 2015-06-12  5:18 UTC (permalink / raw)
  To: Christopher Li; +Cc: Sparse ML

On Thu, Jun 11, 2015 at 05:50:16PM -0700, Christopher Li wrote:
> On Sat, May 16, 2015 at 3:32 PM, Azat Khuzhin <a3at.mail@gmail.com> wrote:
> >
> > You can't pass function to LLVMConstNull(), according to
> > Constant::getNullValue, and sparse-llvm already handle functions differently
> > (i.e. there will be no call to LLVMConstNull(), but this is not true for
> 
> 
> The patch looks good. I am applying it. However I just notice that you did not
> provide the signed-off-by line.
> 
> Can you resend both patch with the signed off line?

Sure, I'm doing this right now!

Thanks,
Azat.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2 v2] sparse, llvm: compile: skip function prototypes to avoid SIGSEGV
  2015-05-16 22:32 [PATCH 0/2] sparse-llvm: avoid SIGSEGV for function prototypes Azat Khuzhin
  2015-05-16 22:32 ` [PATCH 1/2] sparse, llvm: compile: skip function prototypes to avoid SIGSEGV Azat Khuzhin
  2015-05-16 22:32 ` [PATCH 2/2] validation/prototype: regression for skipping prototypes Azat Khuzhin
@ 2015-06-12  5:20 ` Azat Khuzhin
  2015-06-12  5:20   ` [PATCH 2/2 v2] validation/prototype: regression for skipping prototypes Azat Khuzhin
  2 siblings, 1 reply; 9+ messages in thread
From: Azat Khuzhin @ 2015-06-12  5:20 UTC (permalink / raw)
  To: linux-sparse; +Cc: sparse, Azat Khuzhin

You can't pass function to LLVMConstNull(), according to
Constant::getNullValue, and sparse-llvm already handle functions differently
(i.e. there will be no call to LLVMConstNull(), but this is not true for
function prototypes, because of how linearize_fn() works:
```
static struct entrypoint *linearize_fn(...)
{
  ...
  if (!base_type->stmt)
    return NULL;
  ...
}
```

```
Constant *Constant::getNullValue(Type *Ty) {
  switch (Ty->getTypeID()) {
  ...
  default:
    // Function, Label, or Opaque type?
    llvm_unreachable("Cannot create a null constant of that type!");
  }
}
```

Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
---
v2: Add SOF.

 sparse-llvm.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sparse-llvm.c b/sparse-llvm.c
index ecb5b28..6b41afd 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -1070,6 +1070,13 @@ static LLVMValueRef output_data(LLVMModuleRef module, struct symbol *sym)
 	return data;
 }
 
+static int is_prototype(struct symbol *sym)
+{
+	if (sym->type == SYM_NODE)
+		sym = sym->ctype.base_type;
+	return sym && sym->type == SYM_FN && !sym->stmt;
+}
+
 static int compile(LLVMModuleRef module, struct symbol_list *list)
 {
 	struct symbol *sym;
@@ -1077,6 +1084,10 @@ static int compile(LLVMModuleRef module, struct symbol_list *list)
 	FOR_EACH_PTR(list, sym) {
 		struct entrypoint *ep;
 		expand_symbol(sym);
+
+		if (is_prototype(sym))
+			continue;
+
 		ep = linearize_symbol(sym);
 		if (ep)
 			output_fn(module, ep);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2 v2] validation/prototype: regression for skipping prototypes
  2015-06-12  5:20 ` [PATCH 1/2 v2] sparse, llvm: compile: skip function prototypes to avoid SIGSEGV Azat Khuzhin
@ 2015-06-12  5:20   ` Azat Khuzhin
  0 siblings, 0 replies; 9+ messages in thread
From: Azat Khuzhin @ 2015-06-12  5:20 UTC (permalink / raw)
  To: linux-sparse; +Cc: sparse, Azat Khuzhin

Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
---
v2: Add SOF.

 validation/prototype.c | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 validation/prototype.c

diff --git a/validation/prototype.c b/validation/prototype.c
new file mode 100644
index 0000000..481cc93
--- /dev/null
+++ b/validation/prototype.c
@@ -0,0 +1,6 @@
+static int prototype(void);
+
+/*
+ * check-name: Compile skip function prototype
+ * check-command: ./sparsec -c $file -o tmp.o
+ */
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-06-12  5:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-16 22:32 [PATCH 0/2] sparse-llvm: avoid SIGSEGV for function prototypes Azat Khuzhin
2015-05-16 22:32 ` [PATCH 1/2] sparse, llvm: compile: skip function prototypes to avoid SIGSEGV Azat Khuzhin
2015-06-12  0:50   ` Christopher Li
2015-06-12  5:18     ` Azat Khuzhin
2015-05-16 22:32 ` [PATCH 2/2] validation/prototype: regression for skipping prototypes Azat Khuzhin
2015-05-17 18:40   ` Jonathan Neuschäfer
2015-05-17 18:53     ` Azat Khuzhin
2015-06-12  5:20 ` [PATCH 1/2 v2] sparse, llvm: compile: skip function prototypes to avoid SIGSEGV Azat Khuzhin
2015-06-12  5:20   ` [PATCH 2/2 v2] validation/prototype: regression for skipping prototypes Azat Khuzhin

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).