[PATCH] D82481: [XCOFF][AIX] Give symbol an internal name when desired symbol name contains invalid character(s)

Jason Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 29 10:15:32 PDT 2020


jasonliu marked an inline comment as done.
jasonliu added inline comments.


================
Comment at: llvm/lib/MC/MCContext.cpp:313
+  SmallString<128> InvalidName(OriginalName);
+  // Replace the invalid character with '_'.
+  for (size_t I = 0; I < InvalidName.size(); ++I) {
----------------
hubert.reinterpretcast wrote:
> jasonliu wrote:
> > jasonliu wrote:
> > > hubert.reinterpretcast wrote:
> > > > Although this encoding generates runs of underscores, it does make it less intrusive in terms of being able to use `c++filt` on the result. Note that collisions increase with non-Latin scripts (which could be reduced if we append the hex values of all the underscores, including the original ones, to the end of the string).
> > > > ```
> > > > namespace ImplVerTags {
> > > > 
> > > > typedef struct
> > > > 一世
> > > > {} A;
> > > > typedef struct
> > > > 二世
> > > > {} B;
> > > > 
> > > > }
> > > > 
> > > > template <typename> void *implStaticDataUnsafe = nullptr;
> > > > 
> > > > template void *implStaticDataUnsafe<ImplVerTags::A>;
> > > > template void *implStaticDataUnsafe<ImplVerTags::B>;
> > > > ```
> > > Just want to make sure I understand your suggestion:
> > > so if I have a "f`!o" as symbol name, I would get back `_Renamed..6021f__o back`?
> > > Do we want to consider just adding those hex values up? Like getting back `_Renamed..81f__o` for that?
> > If we choose to get the results like `_Renamed..6021f__o`, in what way I could trigger a collision? Do we need to have a collision handling mechanism then?
> Hmm, I suggested appending but adding to the front does seem to make it easier to eyeball the split (in addition to making the more relevant part show up first for C identifiers in non-Latin scripts). I like it. Also, yes, I meant that f_$ would become (with the prefix) `_Renamed..5f24f__`.
> 
> We shouldn't end up with collisions in that case. The transformation is completely reversible by identifying the number of underscores to determine the prefix length and then replacing each underscore with the encoded value.
Thanks for the clarification. Changed the renaming encoding using the idea in our discussion.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82481/new/

https://reviews.llvm.org/D82481





More information about the llvm-commits mailing list