[llvm-commits] [patch] Refactoring of the llvm mangler

Chris Lattner clattner at apple.com
Thu Feb 17 14:08:57 PST 2011


On Feb 11, 2011, at 11:59 AM, Rafael Avila de Espindola wrote:

> My first idea for fixing PR9177 involved having clang know all about assembly names. Anton pointed me at how llvm-gcc does it and I think a similar hack might be sufficient.
> 
> In any case, I wrote a refactoring patch for the llvm mangler that might be a good thing even if it is not needed for PR9177.
> 
> The patch changes the mangler to use streams and explicitly separates the add prefix, mangle the name proper and add suffix steps. This makes it easier to identify (and maybe drop) some of its strange features.
> 
> It also fixes the "FIXME: This logic seems unlikely to be right." :-)

Hi Rafael,

Here are some first thoughts:

+  void GetPrefix(raw_ostream &Out, ManglerPrefixTy PrefixTy, StringRef Name);

Please follow the naming convention for new code, these should be "getPrefix".


+  Out.flush();
   return OutContext.GetOrCreateSymbol(NameStr.str());

You can just use Out.str(), which does a flush before returning the string.


How does this make LTO faster?

It seems that the major change here is to change the SmallString to a raw_ostream, which seems ok, but but also does seem to require adding raw_svector_ostream's around now.  Almost all the clients actually do want to fill in a SmallString after all :)

-Chris



More information about the llvm-commits mailing list