This is an archive of the discontinued LLVM Phabricator instance.

PR30401: Fix substitutions for functions with abi_tag
ClosedPublic

Authored by DmitryPolukhin on Sep 18 2016, 1:08 AM.

Details

Reviewers
rsmith
Summary

Recursive mangling should use all existing substitutions and newly created substitutions should be copied outer mangler.

This patch should fix PR30401 and related cases but unfortunately it is ABI breaking change for Clang backward compatibility (I hope it is rare case in practice). Perhaps this patch will have to be back ported to 3.9.

Diff Detail

Event Timeline

DmitryPolukhin retitled this revision from to PR30401: Fix substitutions for functions with abi_tag.
DmitryPolukhin updated this object.
DmitryPolukhin added a reviewer: rsmith.
rsmith added inline comments.Sep 18 2016, 10:48 AM
lib/AST/ItaniumMangle.cpp
669

Maybe it'd be simpler to just override the output stream here rather than creating a new mangler?

lib/AST/ItaniumMangle.cpp
669

I'm not sure that it is simpler because it will also require substitutions save/restore for name mangling (mangleNameWithAbiTags) to produce the same substitutions twice (without implicate abi_tags and later with implicit abi_tags). IMHO, it is almost identical approaches but current one is a bit cleaner because it copies explicitly everything required from temp to outer mangler.

rsmith added inline comments.Sep 18 2016, 1:59 PM
lib/AST/ItaniumMangle.cpp
669

I think we'd want to override the output stream to write to a temporary buffer at the point when we would otherwise write out the ABI tags, to avoid needing to save/restore any substitutions. But I agree, that seems more invasive than what you're doing here. I'll leave this up to you.

4440

Please avoid the cost of a full copy here by making this a destructive operation on Other -- use swap or move-assignment here. (We'll still be paying for one copy of the substitution set per function mangling, which is unfortunate / undesirable.)

DmitryPolukhin marked an inline comment as done.
DmitryPolukhin added inline comments.
lib/AST/ItaniumMangle.cpp
669

It is significant redesign and additional complexity to remember which exactly ABI tags we would like to rewrite later (it may not be the first call of writeAbiTags for current mangler). I would keep it as is.

Richard, please take another look.

rsmith accepted this revision.Sep 20 2016, 8:08 AM
rsmith edited edge metadata.
This revision is now accepted and ready to land.Sep 20 2016, 8:08 AM