Skip to content

Conversation

@Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Jun 9, 2025

The inheritance hierarchy for llvm::ms_demangle::Node (doxygen) is a bit more involved. One thing that's missing without RTTI is the ability to determine if a node is a symbol, identifier, or type (or one would need to check for every kind).

This PR adds support for dyn_cast, isa, and friends to llvm::ms_demangle::Node. As the type already has a kind(), this mainly adds classof to the nodes as well as some start and end markers in the NodeKind enum.

@zwuis zwuis requested review from MaxEW707 and zmodem June 16, 2025 01:38
@zmodem
Copy link
Collaborator

zmodem commented Jun 24, 2025

One thing that's missing without RTTI is the ability to determine if a node is a symbol, identifier, or type (or one would need to check for every kind).

Do you have an example in mind, where this added RTTI functionality would make the code simpler?

@Nerixyz
Copy link
Contributor Author

Nerixyz commented Jun 24, 2025

Do you have an example in mind, where this added RTTI functionality would make the code simpler?

Yes, I wanted to add rich function demangling info for MS to LLDB (#143149). For this, I need to keep track where certain parts of the demangled name are. Specifically, the basename and function arguments. Here is my WIP, which still has some unrelated changes. RTTI is used there for checking if a node is an identifier and to be able to access its template parameters.

LLDB already does this for the Itanium demangling in DemangledNameInfo. It would be even better if that visitor/output buffer could be reused somehow, as MS-demangle also uses that class. However, it doesn't call printLeft/printRight, because the node types are different.

Copy link
Collaborator

@zmodem zmodem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, adding this sounds good to me.

enum class NodeKind {
Unknown,

SymbolStart,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should introduce new enumerator values for the Start/End values. The guideline is that there should be one enumerator per concrete class.

How about something like:

enum class NodeKind {
  Unknown,

  SymbolStart,
  EncodedStringLiteral = SymbolStart,
  ...
  VariableSymbol,
  SymbolEnd = VariableSymbol,
  ...

@Nerixyz Nerixyz force-pushed the feat/llvm-ms-demangle-rtti branch from 86c1777 to 4e15273 Compare June 27, 2025 17:23
Copy link
Collaborator

@zmodem zmodem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Nerixyz
Copy link
Contributor Author

Nerixyz commented Jul 4, 2025

@zmodem I can't merge this on my own. Could you please merge this for me?

@zmodem zmodem merged commit 2fcf1f8 into llvm:main Jul 4, 2025
7 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 4, 2025

LLVM Buildbot has detected a new failure on builder flang-arm64-windows-msvc running on linaro-armv8-windows-msvc-01 while building llvm at step 7 "test-build-unified-tree-check-flang".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/207/builds/3367

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-flang) failure: test (failure)
******************** TEST 'Flang :: Lower/OpenMP/wsloop-reduction-logical-kinds.f90' FAILED ********************
Exit Code: 2

Command Output (stdout):
--
# RUN: at line 1
c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe -fc1 -emit-hlfir -fopenmp -o - C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\flang\test\Lower\OpenMP\wsloop-reduction-logical-kinds.f90 | c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\filecheck.exe C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\flang\test\Lower\OpenMP\wsloop-reduction-logical-kinds.f90
# executed command: 'c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe' -fc1 -emit-hlfir -fopenmp -o - 'C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\flang\test\Lower\OpenMP\wsloop-reduction-logical-kinds.f90'
# .---command stderr------------
# | PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
# | Stack dump:
# | 0.	Program arguments: c:\\users\\tcwg\\llvm-worker\\flang-arm64-windows-msvc\\build\\bin\\flang.exe -fc1 -emit-hlfir -fopenmp -o - C:\\Users\\tcwg\\llvm-worker\\flang-arm64-windows-msvc\\llvm-project\\flang\\test\\Lower\\OpenMP\\wsloop-reduction-logical-kinds.f90
# | Exception Code: 0xC0000005
# |  #0 0x00007ff617921c24 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a91c24)
# |  #1 0x00007ff61791f90c (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a8f90c)
# |  #2 0x00007ff61791d7a0 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a8d7a0)
# |  #3 0x00007ff6179234b4 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a934b4)
# |  #4 0x00007ff61791d308 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a8d308)
# |  #5 0x00007ff61673ca48 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x8aca48)
# |  #6 0x00007ff616785ea8 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x8f5ea8)
# |  #7 0x00007ff61682f2ec (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x99f2ec)
# |  #8 0x00007ff6167852e4 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x8f52e4)
# |  #9 0x00007ff615f28ac0 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x98ac0)
# | #10 0x00007ff615f3ea88 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0xaea88)
# | #11 0x00007ff615e934e8 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x34e8)
# | #12 0x00007ff615e920a4 (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x20a4)
# | #13 0x00007ff61ab4e6f8 mlir::detail::FallbackTypeIDResolver::registerImplicitTypeID(class llvm::StringRef) (c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x4cbe6f8)
# | #14 0x29077ff61ab4e794
# `-----------------------------
# error: command failed with exit status: 0xc0000005
# executed command: 'c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\filecheck.exe' 'C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\flang\test\Lower\OpenMP\wsloop-reduction-logical-kinds.f90'
# .---command stderr------------
# | FileCheck error: '<stdin>' is empty.
# | FileCheck command line:  c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\filecheck.exe C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\flang\test\Lower\OpenMP\wsloop-reduction-logical-kinds.f90
# `-----------------------------
# error: command failed with exit status: 2

--

********************


@zmodem
Copy link
Collaborator

zmodem commented Jul 4, 2025

LLVM Buildbot has detected a new failure on builder flang-arm64-windows-msvc

The next build (https://lab.llvm.org/buildbot/#/builders/207/builds/3368) is green, so that was a flake.

@Nerixyz Nerixyz deleted the feat/llvm-ms-demangle-rtti branch July 4, 2025 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants