This is an archive of the discontinued LLVM Phabricator instance.

[Demangle] remove unused status param of itaniumDemangle
ClosedPublic

Authored by nickdesaulniers on May 2 2023, 4:40 PM.

Details

Summary

No call sites interpreted this value meaningfully. Simplify this
interface.

Diff Detail

Event Timeline

nickdesaulniers created this revision.May 2 2023, 4:40 PM
Herald added a reviewer: MaskRay. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: hiraditya. · View Herald Transcript
nickdesaulniers requested review of this revision.May 2 2023, 4:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2023, 4:40 PM
MaskRay accepted this revision.May 3 2023, 10:37 AM

I think the signature llvm::itaniumDemangle was to match __cxxabiv1::__cxa_demangle: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#demangler

I agree that the status parameter is unneeded by most users. The error categories distinguished by status become unuseful after the buf and n parameters were removed.

This change looks good. I am unfamiliar with how LLVMDemangle code is copied to libcxxabi. Does this change affect libcxxabi/src/cxa_demangle.cpp? If no, I think the patch is good to go.

This revision is now accepted and ready to land.May 3 2023, 10:37 AM
MaskRay added inline comments.May 3 2023, 10:39 AM
llvm/include/llvm/Demangle/Demangle.h
31–34

Place non-null and a pointer to a NUL-terminated C style string together? I.e. move if successful before or after them.

Also explain when the return value may be a null.

  • update comment, change code to return early to reduce indentation
nickdesaulniers marked an inline comment as done.May 3 2023, 11:01 AM

I think the signature llvm::itaniumDemangle was to match __cxxabiv1::__cxa_demangle: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#demangler

Ah, that makes sense for "historically, why did this interface look like this?"

I agree that the status parameter is unneeded by most users. The error categories distinguished by status become unuseful after the buf and n parameters were removed.

This change looks good. I am unfamiliar with how LLVMDemangle code is copied to libcxxabi. Does this change affect libcxxabi/src/cxa_demangle.cpp? If no, I think the patch is good to go.

Good question; I believe it does not. In my change to llvm/lib/Demangle/ItaniumDemangle.cpp, you can see in the context on phab on line 363 the comment:

// Code beyond this point should not be synchronized with libc++abi.

(My changes are beyond that point).

libcxxabi's demangler only concerns itself with itanium style demangling, not microsoft, rust or D demangling. llvm::itaniumDemangle uses a ManglingParser which is the first point of interface into code that's synchronized between llvm/ and libcxxabi/. This change is not something that is downstream of libcxxabi (and thus has no need to be copied back upstream).

MaskRay accepted this revision.May 3 2023, 11:05 AM

Nice!

This revision was landed with ongoing or failed builds.May 3 2023, 11:58 AM
This revision was automatically updated to reflect the committed changes.

@nickdesaulniers This function is used in a couple more places:

/mnt/d/llvm-project/llvm/lib/Target/SPIRV/SPIRVUtils.cpp:298:25: error: no matching function for call to 'itaniumDemangle'

char *DemangledName = itaniumDemangle(Name.data(), nullptr, &n, &Status);
                      ^~~~~~~~~~~~~~~

/mnt/d/llvm-project/llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp:176:19: error: no matching function for call to 'itaniumDemangle'

char *NameStr = itaniumDemangle(F->getName().data(), nullptr, &n, &status);
                ^~~~~~~~~~~~~~~

@nickdesaulniers This function is used in a couple more places:

/mnt/d/llvm-project/llvm/lib/Target/SPIRV/SPIRVUtils.cpp:298:25: error: no matching function for call to 'itaniumDemangle'

char *DemangledName = itaniumDemangle(Name.data(), nullptr, &n, &Status);
                      ^~~~~~~~~~~~~~~

/mnt/d/llvm-project/llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp:176:19: error: no matching function for call to 'itaniumDemangle'

char *NameStr = itaniumDemangle(F->getName().data(), nullptr, &n, &status);
                ^~~~~~~~~~~~~~~

Thanks for the report. Looks like my code indexer is only indexing backends I build; none of the experimental ones were enabled. I'm working on a fix immediately, and will triple check for other callers using grep.

@nickdesaulniers This function is used in a couple more places:

/mnt/d/llvm-project/llvm/lib/Target/SPIRV/SPIRVUtils.cpp:298:25: error: no matching function for call to 'itaniumDemangle'

char *DemangledName = itaniumDemangle(Name.data(), nullptr, &n, &Status);
                      ^~~~~~~~~~~~~~~

/mnt/d/llvm-project/llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp:176:19: error: no matching function for call to 'itaniumDemangle'

char *NameStr = itaniumDemangle(F->getName().data(), nullptr, &n, &status);
                ^~~~~~~~~~~~~~~

Thanks for the report. Looks like my code indexer is only indexing backends I build; none of the experimental ones were enabled. I'm working on a fix immediately, and will triple check for other callers using grep.

Nevermind, @MaskRay fixed this up in 8e6b3cc4aeedb864a983d849498c03b074570406. Thanks @MaskRay !

I missed SPIRV in my testing of this patch as well. I now use -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD='ARC;AVR;DirectX;LoongArch;M68k;SPIRV;Xtensa' :)