This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: how to use expand_builtin_alloca
- From: fche at redhat dot com (Frank Ch. Eigler)
- To: Ian Lance Taylor <iant at google dot com>
- Cc: Janboe Ye <yuan-bo dot ye at motorola dot com>, gcc at gcc dot gnu dot org, janboe dot ye at gmail dot com
- Date: Thu, 16 Jul 2009 18:31:57 -0400
- Subject: Re: how to use expand_builtin_alloca
- References: <1247519293.4414.16.camel@debian-nb> <m37hycwads.fsf@google.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