public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* how to use expand_builtin_alloca
@ 2009-07-13 21:08 Janboe Ye
  2009-07-13 21:17 ` Ian Lance Taylor
  0 siblings, 1 reply; 6+ messages in thread
From: Janboe Ye @ 2009-07-13 21:08 UTC (permalink / raw)
  To: gcc; +Cc: janboe.ye

Hi,

normally gcc will use expand_builtin_alloca to handle variable array.
But mudflap will force this function to return immediately to invoke
alloca explicit.

Is there some way to still use expand_builtin_alloca without changing
gcc source code?

Thanks a lot!

Janboe Ye

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

* Re: how to use expand_builtin_alloca
  2009-07-13 21:08 how to use expand_builtin_alloca Janboe Ye
@ 2009-07-13 21:17 ` Ian Lance Taylor
  2009-07-13 21:27   ` Janboe Ye
  2009-07-16 22:32   ` Frank Ch. Eigler
  0 siblings, 2 replies; 6+ messages in thread
From: Ian Lance Taylor @ 2009-07-13 21:17 UTC (permalink / raw)
  To: Janboe Ye; +Cc: gcc, janboe.ye

Janboe Ye <yuan-bo.ye@motorola.com> writes:

> normally gcc will use expand_builtin_alloca to handle variable array.
> But mudflap will force this function to return immediately to invoke
> alloca explicit.
>
> Is there some way to still use expand_builtin_alloca without changing
> gcc source code?

mudflap can't check accesses to memory allocated using alloca unless it
overrides __builtin_alloca.  So if I understand your question correctly,
the answer is no.  Although, of course, you could simply not use mudflap
for the code in question.

Ian

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

* Re: how to use expand_builtin_alloca
  2009-07-13 21:17 ` Ian Lance Taylor
@ 2009-07-13 21:27   ` Janboe Ye
  2009-07-13 21:39     ` Ian Lance Taylor
  2009-07-16 22:32   ` Frank Ch. Eigler
  1 sibling, 1 reply; 6+ messages in thread
From: Janboe Ye @ 2009-07-13 21:27 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc, janboe.ye

Hi Ian

Thanks for reply.

Is it possible to override alloc to do the same thing as
expand_buitlin_alloca in application codes?



On Mon, 2009-07-13 at 14:17 -0700, Ian Lance Taylor wrote:
> Janboe Ye <yuan-bo.ye@motorola.com> writes:
> 
> > normally gcc will use expand_builtin_alloca to handle variable array.
> > But mudflap will force this function to return immediately to invoke
> > alloca explicit.
> >
> > Is there some way to still use expand_builtin_alloca without changing
> > gcc source code?
> 
> mudflap can't check accesses to memory allocated using alloca unless it
> overrides __builtin_alloca.  So if I understand your question correctly,
> the answer is no.  Although, of course, you could simply not use mudflap
> for the code in question.
> 
> Ian

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

* Re: how to use expand_builtin_alloca
  2009-07-13 21:27   ` Janboe Ye
@ 2009-07-13 21:39     ` Ian Lance Taylor
  0 siblings, 0 replies; 6+ messages in thread
From: Ian Lance Taylor @ 2009-07-13 21:39 UTC (permalink / raw)
  To: Janboe Ye; +Cc: gcc, janboe.ye

Janboe Ye <yuan-bo.ye@motorola.com> writes:

> Is it possible to override alloc to do the same thing as
> expand_buitlin_alloca in application codes?

I don't know of any way to do that when using mudflap.  If there were
such a way, it would imply that mudflap were broken, or that there is a
special way to work around it.

Can't you simply not use mudflap?

Ian

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

* Re: how to use expand_builtin_alloca
  2009-07-13 21:17 ` Ian Lance Taylor
  2009-07-13 21:27   ` Janboe Ye
@ 2009-07-16 22:32   ` Frank Ch. Eigler
  2009-07-19 20:08     ` ye janboe
  1 sibling, 1 reply; 6+ messages in thread
From: Frank Ch. Eigler @ 2009-07-16 22:32 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: Janboe Ye, gcc, janboe.ye


> Janboe Ye <yuan-bo.ye@motorola.com> writes:

>> normally gcc will use expand_builtin_alloca to handle variable array.
>> But mudflap will force this function to return immediately to invoke
>> alloca explicit.
>>
>> Is there some way to still use expand_builtin_alloca without changing
>> gcc source code?

I don't think so.


Ian Lance Taylor <iant@google.com> writes:

> mudflap can't check accesses to memory allocated using alloca unless
> it overrides __builtin_alloca.

It can't currently.  But instead of redirecting the call to a
heap-based alloca() wannabe in libmudflap/mf-hooks1.c, perhaps
mudflap could instrument alloca() by generating code like this
instead:

  __builtin_alloca(N)  -->  GIMPLE_TRY_FINALLY( try {
                                ptr = __builtin_alloca(N)
                                __mf_register(ptr ...)
                                ptr;
                           } finally (attached to the function scope) {
                                __mf_unregister(ptr ...)
                           }

Or perhaps not, if alloca() can be used in loops in way that
prevents clean nesting of the try/finally.  

OTOH, I believe the original poster's case came from gcc-synthesized
alloca's, coming from variable-length array allocation.  Those in turn
might be represented with almost the normal mf_xform_decls(), while
letting __builtin_alloca() remain.

Either of these requires gcc changes though.


> [...]  Although, of course, you could simply not use mudflap for the
> code in question.

The original poster's purpose is specifically to build bits of the
linux kernel with mudflap instrumentation.


- FChE

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

* Re: how to use expand_builtin_alloca
  2009-07-16 22:32   ` Frank Ch. Eigler
@ 2009-07-19 20:08     ` ye janboe
  0 siblings, 0 replies; 6+ messages in thread
From: ye janboe @ 2009-07-19 20:08 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: Ian Lance Taylor, Janboe Ye, gcc

Hi, Frank
>Those in turn
>might be represented with almost the normal mf_xform_decls(), while
>letting __builtin_alloca() remain.
How can we just remain __builtin_alloca() only for variable-length array?
Mudflap changes expand_builtin_alloca function.

I think it is enough for apply mudflap in Linux Kernel.

Janboe Ye


2009/7/16 Frank Ch. Eigler <fche@redhat.com>:
>
>> Janboe Ye <yuan-bo.ye@motorola.com> writes:
>
>>> normally gcc will use expand_builtin_alloca to handle variable array.
>>> But mudflap will force this function to return immediately to invoke
>>> alloca explicit.
>>>
>>> Is there some way to still use expand_builtin_alloca without changing
>>> gcc source code?
>
> I don't think so.
>
>
> Ian Lance Taylor <iant@google.com> writes:
>
>> mudflap can't check accesses to memory allocated using alloca unless
>> it overrides __builtin_alloca.
>
> It can't currently.  But instead of redirecting the call to a
> heap-based alloca() wannabe in libmudflap/mf-hooks1.c, perhaps
> mudflap could instrument alloca() by generating code like this
> instead:
>
>  __builtin_alloca(N)  -->  GIMPLE_TRY_FINALLY( try {
>                                ptr = __builtin_alloca(N)
>                                __mf_register(ptr ...)
>                                ptr;
>                           } finally (attached to the function scope) {
>                                __mf_unregister(ptr ...)
>                           }
>
> Or perhaps not, if alloca() can be used in loops in way that
> prevents clean nesting of the try/finally.
>
> OTOH, I believe the original poster's case came from gcc-synthesized
> alloca's, coming from variable-length array allocation.  Those in turn
> might be represented with almost the normal mf_xform_decls(), while
> letting __builtin_alloca() remain.
>
> Either of these requires gcc changes though.
>
>
>> [...]  Although, of course, you could simply not use mudflap for the
>> code in question.
>
> The original poster's purpose is specifically to build bits of the
> linux kernel with mudflap instrumentation.
>
>
> - FChE
>

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

end of thread, other threads:[~2009-07-19 20:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-13 21:08 how to use expand_builtin_alloca Janboe Ye
2009-07-13 21:17 ` Ian Lance Taylor
2009-07-13 21:27   ` Janboe Ye
2009-07-13 21:39     ` Ian Lance Taylor
2009-07-16 22:32   ` Frank Ch. Eigler
2009-07-19 20:08     ` ye janboe

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 read-only IMAP folder(s) and NNTP newsgroup(s).