[cfe-dev] [libc++abi] demangle fails to handle SSE2 types

Howard Hinnant hhinnant at apple.com
Wed May 23 07:01:02 PDT 2012


On May 23, 2012, at 5:53 AM, Luc Bourhis wrote:

> Hi,
> 
> I am not sure whether it is fine to discuss libc++abi here but since libc++ is welcome a subject, I boldly extrapolated…

To boldly discuss where no discussion has gone before... :-)

> 
> So,  abi::__cxa_demangle from libc++abi trunk fails to demangle SSE2 types such as __m128. This is demonstrated by the following snippet:
> 
> //*********************************************************************************
> #include <iostream>
> #include <cxxabi.h>
> #include <immintrin.h>
> 
> template <class T>
> void pretty_print(T const &o) {
>  char const *mangled = typeid(o).name();
>  int status;
>  char *demangled = abi::__cxa_demangle(mangled, 0, 0, &status);
>  std::cout << "Mangled: " << mangled << "\n";
>  if (status) {
>    std::cout << "Demangling failed with status " << status << "\n";
>  }
>  else {
>    std::cout << "Demangled: " << demangled << "\n";
>  }
>  std::cout << std::endl;
> }
> 
> int main() {
>  double x0;
>  __m128 x1;
>  __m128d x2;
>  pretty_print(x0);
>  pretty_print(x1);
>  pretty_print(x2);
> }
> //************************************************************************************
> 
> which prints
> 
> Mangled: d
> Demangled: double
> 
> Mangled: Dv4_f
> Demangling failed with status -2
> 
> Mangled: Dv2_d
> Demangling failed with status -2

Currently libc++abi mangling is following the specification here:

http://sourcery.mentor.com/public/cxx-abi/abi.html#mangling

The section you should be interested in is: <builtin-type>.  And this section currently lacks Dv4_f and Dv2_d.  It does include a mangling for vendor extended types, and it is a shame that the ABI hasn't been followed for these types (prefix with 'u'), but oh well.

It shouldn't be hard to modify the demangler to include these types.  If you'll tell me what string you would like to see these symbols demangle to, I'll put it on my to-do list.  You should assume I know absolutely nothing about SSE2 types in your table of mappings.  For example I do not know the significance of the 4 and 2 in these mangled names, nor what other values they may take (I could guess, but I don't want to).

Howard





More information about the cfe-dev mailing list