* [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
* 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 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
* [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