This is the mail archive of the gcc-patches@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: RFA: new pass to warn on questionable uses of alloca() and VLAs


On 07/19/2016 05:03 AM, Aldy Hernandez wrote:
(Same thing with alloca).  There should be no warning for VLAs,
and for alloca, the warning should say "use of variable-length
array within a loop."  The VRP dump suggests the range information
is available within the loop.  Is the get_range_info() function
not returning the corresponding bounds?

This is a false positive, but there's little we can do with the current
range infrastructure.  The range information becomes less precise the
further down the optimization pipeline we get.  So, even though as far
as *.c.126t.crited1, we still see appropriate range information:
[ ... ]
So I think we can live with the false positive as an XFAIL while we wait for improved infrastructure.

I will note that you could use a two-stage approach to help with this kind of issue. You note the set of potential large allocations early (before PRE or anyone else messes it up). Then you allow the other optimizers to run, then go back and recheck the allocations after the last optimizer pass. You end up with

flagged early  && flagged late --> warn
flagged early && ! flagged late -> optimization eliminated the false positive (which you can optionally issue a diagnostic for)
! flagged early -- never warn

I don't think you strictly need it here, but it's a way to approach some of these problems where you want to run a warning pass late (to allow the optimizers to eliminate false positives).

jeff


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