Updated mangling specs

Christophe de Dinechin ddd at cup.hp.com
Tue Feb 22 19:28:23 UTC 2000


Jason Merrill wrote:
> 
> dehnert at baalbek.engr.sgi.com (Jim Dehnert) writes:
> 
> > > > Also, to allow cross-.o file inlining, you need to extend that to
> > > > any function (not only those explicitly marked inline.) Strictly
> > > > speaking, this is outside the ABI, but unless there are strong
> > > > reasons not to, I'd advocate mangling any static data, regardless of
> > > > whether the function is tagged inline or not.
> > >
> > > We should mangle the static data for any function that may be inlined;
> > > which functions those are depends on the compiler.
> >
> > I don't think that we can or should require that the static data
> > always have mangled symbols emitted -- that should be the responsibility
> > of an implementation that chooses to inline routines not declared
> > inline.  However, once the compiler chooses to emit them, it should use
> > the defined mangling for inline routines.
> 
> I'm not sure that we're disagreeing here.
> 
> If the compiler decides to inline the function in one translation
> unit, and not in another, we still need to share statics between
> inline and out-of-line copies.  Either we can say that the compiler
> should recognize that the function might be inlined in another TU and
> mangle the locals accordingly, or we can say that we should always
> mangle locals.  The latter might be the only way to deal with inlining
> differences between implementations...if we care.

Again, my point was that mangling statics is not well-defined enough for that.
Consider:

// File f1.C

static inline int foo()
{
	static int i = 0;
	return ++i;
}

extern int bar1()
{
	return foo();
}


// File f2.C

static inline int foo()
{
	static int i = 0;
	return --i;
}

extern int bar2()
{
	return foo();
}


// File f3.C
extern int bar1(), bar2();
int main()
{
	return bar1() + bar2();
}


Consider what happens if you want to inline bar1 and bar2. Our name mangling for
statics is not good enough, because i would be mangled the same. We need a file
name too. To me, it's good enough to use the 'escape' mechanism for that, but it
has to be there.



Regards
Christophe




More information about the cxx-abi-dev mailing list