This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -fno-tree-cselim not working?


From: Jakub Jelinek <jakub@redhat.com>
Date: Fri, 26 Oct 2007 09:48:25 +0200

> On Fri, Oct 26, 2007 at 12:27:01AM -0700, David Miller wrote:
> > From: Jakub Jelinek <jakub@redhat.com>
> > Date: Fri, 26 Oct 2007 09:09:03 +0200
> > 
> > > MEMs in current function's stack frame can be considered safe as
> > > well.
> > 
> > Unless they are passed by reference down into functions or
> > a reference to them is assigned into an externally visible
> > structure.
> 
> If they are passed by reference then the MEMs have some pointer
> as address, rather than argp/frame/sp + offset.

Even in cases like:

typedef unsigned char spinlock_t;
extern int spin_trylock(spinlock_t *);
extern int spin_unlock(spinlock_t *);

struct foo {
       spinlock_t lock;
       int a;
};

extern void foo_register(struct foo *p);
extern void foo_unregister(struct foo *p);

void example(void)
{
	struct foo local;

	foo_register(&local);

	if (spin_trylock(&local.lock)) {
		local.a++;
		spin_unlock(&local.lock);
	}

	foo_unregister(&local);
}


I suspect that local.a++ will be represented as a frame relative
access.  Test compiles show that gcc does update the on-stack
copy on Sparc, now just to check if the conditional memory
operation cases trigger here too.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]