public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Lazy allocation of DECL_ASSEMBLER_NAME
@ 2004-03-01 19:10 Mark Mitchell
  2004-03-01 19:47 ` Geoff Keating
  2004-03-01 20:20 ` Jan Hubicka
  0 siblings, 2 replies; 28+ messages in thread
From: Mark Mitchell @ 2004-03-01 19:10 UTC (permalink / raw)
  To: jh; +Cc: gcc


Jan --

I believe that your cgraph stuff has caused us to be much less lazy
about allocating DECL_ASSEMBLER_NAME than we used to be.  

A while back, I changed DECL_ASSEMBLER_NAME to allocate lazily because
I observed that we were allocating a ton of space for mangled names
for entities that were never omitted.  Now, it looks like cgraph has
gone back to using DECL_ASSEMBLER_NAME unconditionally.

It is basically a bug for any part of the code in the compiler to use
DECL_ASSEMBLER_NAME other than the routines that actually emity
assembly code.  It should be possible to assign DECL_ASSEMBLER_NAMEs
only after the entire translation unit has been parsed, analyzed, and
it has been decided what functions and variables need to be omitted to
the object file.  All other uses are either wrong, or hacks that
should be replaced with a cleaner mechanism.

To check for whether two declarations are the same, just compare their
addresses.  If a front end creates two FUNCTION_DECLs or VAR_DECLs
that happen to have the same DECL_ASSEMBLER_NAME that's either a bug
or an intentional trick on the part of the front end: by the time
things get to the middle end there should be only one DECL for each
declared entity.

Would you please see if you can fix this problem -- after fixing some
of the wrong-code/ICE problems in 3.4?

Thanks,

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com


^ permalink raw reply	[flat|nested] 28+ messages in thread
* Re: Lazy allocation of DECL_ASSEMBLER_NAME
@ 2004-03-01 22:21 Chris Lattner
  2004-03-01 23:26 ` Mark Mitchell
  0 siblings, 1 reply; 28+ messages in thread
From: Chris Lattner @ 2004-03-01 22:21 UTC (permalink / raw)
  To: Mark Mitchell, Geoff Keating, zack, dalej, gcc


Mark Mitchell wrote:
> There are lots of things that are hard about inter-module analysis, as
> you of course know. :-) It's an inherent design problem: we're
> essentially trying to combine multiple C translation units into a single
> C translation unit, and C is not a language that permits that. Most
> object file formats are designed to support C, so we see these problems
> at that level too.

Just to be clear, this is not a problem with IMA, this is a problem with
doing it at the source level.  C is just a really ugly language and never
really defined what happens if two structs or other declarations don't
agree.

In LLVM we address this by doing IPO on a non-source-level representation,
which fixes the issue, but since LLVM is a type-safe representation, our
linker has to be able to handle cases where you are linking two things
with different types.  In the case of LLVM, the semantics are clearly
defined so this isn't a problem, it just took implementation.  FWIW, this
was aluded to in my GCC summit paper (sec 4.4).

In GCC, perhaps the best way to do it is to make the IMA and normal
optimizer not depend on the source-level types as much as possible, they
simply cannot be trusted.  Silently breaking the program is obviously a
bad alternative.

> In the example that you give, the program is not conforming if the
> definitions of "struct foo" are not identical across translation units.
> (Or, at least, that would be true in ISO C++. It might not have to be
> true in ISO C. You may know more than I.) In any case, if the structures
> do not match up across the translation units, we should just not combine
> them.  That is certainly not the common case.

This comes up all of the time in real-world programs.  zlib and 300.twolf
are examples that spring to mind immediately.  libstdc++ does some other
funky things declaring "std::cin" as an array of characters in one .o
file, etc.  Unfortunately, though compiler venders might like to not
handle this, we _have to_.  It's just not acceptable to base optimization
decisions on type-equality, unless there are conservative fallbacks.

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/

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

end of thread, other threads:[~2004-03-02 17:22 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-01 19:10 Lazy allocation of DECL_ASSEMBLER_NAME Mark Mitchell
2004-03-01 19:47 ` Geoff Keating
2004-03-01 19:57   ` Zack Weinberg
2004-03-01 20:21     ` Geoff Keating
2004-03-01 20:25       ` Mark Mitchell
2004-03-01 21:15         ` Zack Weinberg
2004-03-01 21:46           ` Geoff Keating
2004-03-01 22:03             ` Mark Mitchell
2004-03-01 22:54               ` Geoff Keating
2004-03-02  0:03                 ` Mark Mitchell
2004-03-01 21:02       ` Dale Johannesen
2004-03-01 21:45         ` Mark Mitchell
2004-03-01 21:48           ` Dale Johannesen
2004-03-01 20:11   ` Mark Mitchell
2004-03-01 20:19     ` Zack Weinberg
2004-03-02 17:04   ` Mark Mitchell
2004-03-02 17:11     ` Jan Hubicka
2004-03-02 17:18       ` Mark Mitchell
2004-03-02 17:22         ` Jan Hubicka
2004-03-01 20:20 ` Jan Hubicka
2004-03-01 20:27   ` Mark Mitchell
2004-03-01 20:33     ` Jan Hubicka
2004-03-01 21:19     ` Zack Weinberg
2004-03-01 21:19     ` Geoff Keating
2004-03-01 22:21 Chris Lattner
2004-03-01 23:26 ` Mark Mitchell
2004-03-01 23:58   ` Chris Lattner
2004-03-02  0:09     ` Mark Mitchell

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).