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: [tree-ssa] dead const/pure/alloca call removal


"Zack Weinberg" <zack@codesourcery.com> writes:

| Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
| 
| > | At least in C, and presumably in C++ with direct calls to malloc/free.
| >
| > Again, that is fine *if* GCC is a whole implementation of the compiler
| > plus the library.  Currently, it is not.  It relies on third party
| > libraries, and such libraries might be doing additional things like
| > tracing or implement their own view of memory allocation.
| 
| I think this is a bit much.  malloc's behavior is specified by the
| C standard.

And the C standard also says the implementation provides malloc().  
Which GCC does not.  

In reality, the specification of malloc() as found in the C standard
does not provide sufficient ground for GCC to willy-nilly elide calls
to malloc, given that GCC actually does not provide a malloc
implementation.

[...]

| Now, if all you're saying is there ought to be a switch to turn this
| optimization off,

Given, current GCC, that transformation cannot be called an
optimisation.  

As a side remark, Jan claimed that

                         For C++ programs it is not at all that uncommon to
   allocate something just to pass it around and with scalar replacement we
   may simply elliminate all needs for the memory location.

but in reality, for C++ programs, the most recuring pattern is
new/delete, so I don't actually what is being "optimzed" for.
 
-- Gaby


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