This is an archive of the discontinued LLVM Phabricator instance.

[Demangle][Rust] Parse dot suffix
ClosedPublic

Authored by tmiasko on Jun 16 2021, 12:07 AM.

Details

Summary

Allow mangled names to include an arbitrary dot suffix, akin to vendor
specific suffix in Itanium mangling.

Primary motivation is a support for symbols renamed during ThinLTO
import / promotion (ThinLTO is the default configuration for optimized
builds in rustc).

Diff Detail

Event Timeline

tmiasko created this revision.Jun 16 2021, 12:07 AM
tmiasko requested review of this revision.Jun 16 2021, 12:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2021, 12:07 AM
dblaikie added inline comments.Jun 17 2021, 9:45 AM
llvm/lib/Demangle/RustDemangle.cpp
123–130

Is this similar to the Itanium implementation? Or would it be possible/reasonable/simpler (maybe not, I don't know) to strip the '.' before doing any parsing at all? (or are there cases where the rust mangling can include '.' and so finding the trailing '.' must be a context-sensitive operation)

tmiasko updated this revision to Diff 352805.Jun 17 2021, 11:30 AM
  • Strip dot suffix before parsing
  • Include the dot in demangled output
tmiasko added inline comments.Jun 17 2021, 11:33 AM
llvm/lib/Demangle/RustDemangle.cpp
123–130

There is some variation in existing implementations. LLVM Itanium demangler prints _Z1fv.llvm.1234 as f() (.llvm.1234). The c++filt prints it as f() [clone .llvm.1234]. The rustc-demangle crate, which is used by rustc, omits .llvm.* suffixes from output, but prints others verbatim. The Rust demangler in c++filt rejects symbols with suffixes altogether.

The Rust mangling does not use . character by itself. So yes, suffix can be stripped ahead of time, which seems simpler than it was before.

dblaikie accepted this revision.Jun 17 2021, 2:01 PM

Looks good, thanks!

This revision is now accepted and ready to land.Jun 17 2021, 2:01 PM
This revision was landed with ongoing or failed builds.Jun 18 2021, 12:31 AM
This revision was automatically updated to reflect the committed changes.