linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Fwd: [problem] sparse llvm loop conditions
       [not found] <CAOJsxLF351XvYE6Av3hxMsqXeu2nT4vRjbLgwNAguNLEfgLQvQ@mail.gmail.com>
@ 2012-08-19 17:21 ` Jeff Garzik
  2012-08-19 19:48   ` Jonathan Neuschäfer
  2013-05-18 18:42   ` Jonathan Neuschäfer
  0 siblings, 2 replies; 4+ messages in thread
From: Jeff Garzik @ 2012-08-19 17:21 UTC (permalink / raw)
  To: Sparse Mailing-list; +Cc: Pekka Enberg, Jonathan Neuschäfer

Here is a testcase that should get into the mailing list archives...

	Jeff




-------- Original Message --------
Subject: [problem] sparse llvm loop conditions
Date: Wed, 23 Nov 2011 08:56:25 +0200
From: Pekka Enberg <penberg@kernel.org>
To: Jeff Garzik <jeff@garzik.org>

Hi Jeff,

Have you seen this already?

[penberg@tux sparse]$ cat loop.c
struct list_node {
	struct list_node *next;
};

int foo(struct list_node *node)
{
	int ret = 0;
	while (node) {
		node = node->next;
		ret++;
	}
	return ret;
}
[penberg@tux sparse]$ ./sparse-llvm loop.c
loop.c:5:5: warning: symbol 'foo' was not declared. Should it be static?
sparse-llvm: Instructions.cpp:730: void llvm::BranchInst::AssertOK():
Assertion `getCondition()->getType()->isIntegerTy(1) && "May only
branch on boolean predicates!"' failed.
Aborted

                                 Pekka




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

* Re: Fwd: [problem] sparse llvm loop conditions
  2012-08-19 17:21 ` Fwd: [problem] sparse llvm loop conditions Jeff Garzik
@ 2012-08-19 19:48   ` Jonathan Neuschäfer
  2013-05-18 18:42   ` Jonathan Neuschäfer
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Neuschäfer @ 2012-08-19 19:48 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Sparse Mailing-list, Pekka Enberg, Jonathan Neuschäfer

On Sun, Aug 19, 2012 at 01:21:23PM -0400, Jeff Garzik wrote:
> Hi Jeff,
> 
> Have you seen this already?
> 
> [penberg@tux sparse]$ cat loop.c
> struct list_node {
> 	struct list_node *next;
> };
> 
> int foo(struct list_node *node)
> {
> 	int ret = 0;
> 	while (node) {
> 		node = node->next;
> 		ret++;
> 	}
> 	return ret;
> }
> [penberg@tux sparse]$ ./sparse-llvm loop.c
> loop.c:5:5: warning: symbol 'foo' was not declared. Should it be static?
> sparse-llvm: Instructions.cpp:730: void llvm::BranchInst::AssertOK():
> Assertion `getCondition()->getType()->isIntegerTy(1) && "May only
> branch on boolean predicates!"' failed.
> Aborted

It doesn't print this particular message anymore, but the llvm
verification detects some other things that could cause problems:

> jonathan@debian:~/dev/sparse/validation$ (../sparse-llvm backend/penberg-loop.c | llvm-dis) 2>&1
> backend/penberg-loop.c:5:5: warning: symbol 'foo' was not declared. Should it be static?
> PHI node operands are not the same type as the result!
>   %phi = phi %list_node* [ %0, %L0 ], [ %load_target, %L2 ]
> Instruction does not dominate all uses!
>   %phi = phi %list_node* [ %0, %L0 ], [ %load_target, %L2 ]
>   %cond = icmp ne %list_node* %phi, null
> Instruction does not dominate all uses!
>   %cond = icmp ne %list_node* %phi, null
>   br i1 %cond, label %L2, label %L3
> Broken module found, verification continues.
> PHI node operands are not the same type as the result!
>   %phi = phi %list_node* [ %0, %L0 ], [ %load_target, %L2 ]
> Instruction does not dominate all uses!
>   %phi = phi %list_node* [ %0, %L0 ], [ %load_target, %L2 ]
>   %cond = icmp ne %list_node* %phi, null
> Instruction does not dominate all uses!
>   %cond = icmp ne %list_node* %phi, null
>   br i1 %cond, label %L2, label %L3
> Broken module found, verification continues.
> Broken module found, verification continues.
> ; ModuleID = '<stdin>'
> 
> %list_node = type { %list_node* }
> 
> define i32 @foo(%list_node*) {
> L0:
>   br label %L1
> 
> L1:                                               ; preds = %L2, %L0
>   %phi = phi %list_node* [ %0, %L0 ], [ %load_target, %L2 ]
>   %phi1 = phi i32 [ 0, %L0 ], [ %R5, %L2 ]
>   %cond = icmp ne %list_node* %phi, null
>   br i1 %cond, label %L2, label %L3
> 
> L2:                                               ; preds = %L1
>   %src_i = ptrtoint %list_node* %phi to i32
>   %addr_i = add i32 %src_i, 0
>   %addr = inttoptr i32 %addr_i to i32*
>   %load_target = load i32* %addr
This load instruction should use %list_node*.
>   %R5 = add i32 %phi1, 1
>   br label %L1
> 
> L3:                                               ; preds = %L1
>   ret i32 %phi1
> }

Jonathan

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

* Re: Fwd: [problem] sparse llvm loop conditions
  2012-08-19 17:21 ` Fwd: [problem] sparse llvm loop conditions Jeff Garzik
  2012-08-19 19:48   ` Jonathan Neuschäfer
@ 2013-05-18 18:42   ` Jonathan Neuschäfer
  2013-05-19  8:16     ` Pekka Enberg
  1 sibling, 1 reply; 4+ messages in thread
From: Jonathan Neuschäfer @ 2013-05-18 18:42 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Sparse Mailing-list, Pekka Enberg, Jonathan Neuschäfer

Hi Jeff, Pekka,

On Sun, Aug 19, 2012 at 01:21:23PM -0400, Jeff Garzik wrote:
> Here is a testcase that should get into the mailing list archives...
> 
> 	Jeff
> 
> 
> 
> 
> -------- Original Message --------
> Subject: [problem] sparse llvm loop conditions
> Date: Wed, 23 Nov 2011 08:56:25 +0200
> From: Pekka Enberg <penberg@kernel.org>
> To: Jeff Garzik <jeff@garzik.org>
> 
> Hi Jeff,
> 
> Have you seen this already?
> 
> [penberg@tux sparse]$ cat loop.c
> struct list_node {
> 	struct list_node *next;
> };
> 
> int foo(struct list_node *node)
> {
> 	int ret = 0;
> 	while (node) {
> 		node = node->next;
> 		ret++;
> 	}
> 	return ret;
> }
> [penberg@tux sparse]$ ./sparse-llvm loop.c
> loop.c:5:5: warning: symbol 'foo' was not declared. Should it be static?
> sparse-llvm: Instructions.cpp:730: void llvm::BranchInst::AssertOK():
> Assertion `getCondition()->getType()->isIntegerTy(1) && "May only
> branch on boolean predicates!"' failed.
> Aborted
> 
>                                 Pekka

With my patchset of today, sparse-llvm compiles this code. It turned out
that struct accesses didn't work, because the address computed for
load/store instructions didn't have the right LLVM type.

[ On a side note, array access doesn't work yet. ]

regards,
Jonathan

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

* Re: Fwd: [problem] sparse llvm loop conditions
  2013-05-18 18:42   ` Jonathan Neuschäfer
@ 2013-05-19  8:16     ` Pekka Enberg
  0 siblings, 0 replies; 4+ messages in thread
From: Pekka Enberg @ 2013-05-19  8:16 UTC (permalink / raw)
  To: Jonathan Neuschäfer; +Cc: Jeff Garzik, Sparse Mailing-list, Xi Wang

On Sat, May 18, 2013 at 9:42 PM, Jonathan Neuschäfer
<j.neuschaefer@gmx.net> wrote:
> Hi Jeff, Pekka,
>
> On Sun, Aug 19, 2012 at 01:21:23PM -0400, Jeff Garzik wrote:
>> Here is a testcase that should get into the mailing list archives...
>>
>>       Jeff
>>
>> -------- Original Message --------
>> Subject: [problem] sparse llvm loop conditions
>> Date: Wed, 23 Nov 2011 08:56:25 +0200
>> From: Pekka Enberg <penberg@kernel.org>
>> To: Jeff Garzik <jeff@garzik.org>
>>
>> Hi Jeff,
>>
>> Have you seen this already?
>>
>> [penberg@tux sparse]$ cat loop.c
>> struct list_node {
>>       struct list_node *next;
>> };
>>
>> int foo(struct list_node *node)
>> {
>>       int ret = 0;
>>       while (node) {
>>               node = node->next;
>>               ret++;
>>       }
>>       return ret;
>> }
>> [penberg@tux sparse]$ ./sparse-llvm loop.c
>> loop.c:5:5: warning: symbol 'foo' was not declared. Should it be static?
>> sparse-llvm: Instructions.cpp:730: void llvm::BranchInst::AssertOK():
>> Assertion `getCondition()->getType()->isIntegerTy(1) && "May only
>> branch on boolean predicates!"' failed.
>> Aborted
>
> With my patchset of today, sparse-llvm compiles this code. It turned out
> that struct accesses didn't work, because the address computed for
> load/store instructions didn't have the right LLVM type.

Indeed it does! :-)

Just in case people want to try it out, the code is in my llvm/core branch here:

https://github.com/penberg/sparse-llvm/tree/llvm/core

                         Pekka
--
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] 4+ messages in thread

end of thread, other threads:[~2013-05-19  8:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CAOJsxLF351XvYE6Av3hxMsqXeu2nT4vRjbLgwNAguNLEfgLQvQ@mail.gmail.com>
2012-08-19 17:21 ` Fwd: [problem] sparse llvm loop conditions Jeff Garzik
2012-08-19 19:48   ` Jonathan Neuschäfer
2013-05-18 18:42   ` Jonathan Neuschäfer
2013-05-19  8:16     ` Pekka Enberg

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