[MS ABI] Cleanup our mangling of vector types

We used to produce a type which demangled to:
union __clang_vec8_F

That 'F' is the mangling for 'short' but it is present in the mangled
name in an inappropriate place, leading to it not getting demangled.

Instead, create a synthetic class type in a synthetic namespace called
__clang. With this, it now demangles to:
union __clang::__vector<short,8>

llvm-svn: 256556
This commit is contained in:
David Majnemer 2015-12-29 11:45:58 +00:00
parent 3add70bf55
commit 0a29fed31f
2 changed files with 15 additions and 12 deletions

View File

@ -2227,7 +2227,7 @@ void MicrosoftCXXNameMangler::mangleType(const VectorType *T, Qualifiers Quals,
uint64_t Width = getASTContext().getTypeSize(T); uint64_t Width = getASTContext().getTypeSize(T);
// Pattern match exactly the typedefs in our intrinsic headers. Anything that // Pattern match exactly the typedefs in our intrinsic headers. Anything that
// doesn't match the Intel types uses a custom mangling below. // doesn't match the Intel types uses a custom mangling below.
bool IsBuiltin = true; size_t OutSizeBefore = Out.tell();
llvm::Triple::ArchType AT = llvm::Triple::ArchType AT =
getASTContext().getTargetInfo().getTriple().getArch(); getASTContext().getTargetInfo().getTriple().getArch();
if (AT == llvm::Triple::x86 || AT == llvm::Triple::x86_64) { if (AT == llvm::Triple::x86 || AT == llvm::Triple::x86_64) {
@ -2240,22 +2240,25 @@ void MicrosoftCXXNameMangler::mangleType(const VectorType *T, Qualifiers Quals,
mangleArtificalTagType(TTK_Union, "__m" + llvm::utostr(Width) + 'i'); mangleArtificalTagType(TTK_Union, "__m" + llvm::utostr(Width) + 'i');
else if (ET->getKind() == BuiltinType::Double) else if (ET->getKind() == BuiltinType::Double)
mangleArtificalTagType(TTK_Struct, "__m" + llvm::utostr(Width) + 'd'); mangleArtificalTagType(TTK_Struct, "__m" + llvm::utostr(Width) + 'd');
else
IsBuiltin = false;
} else {
IsBuiltin = false;
} }
} else {
IsBuiltin = false;
} }
bool IsBuiltin = Out.tell() != OutSizeBefore;
if (!IsBuiltin) { if (!IsBuiltin) {
// The MS ABI doesn't have a special mangling for vector types, so we define // The MS ABI doesn't have a special mangling for vector types, so we define
// our own mangling to handle uses of __vector_size__ on user-specified // our own mangling to handle uses of __vector_size__ on user-specified
// types, and for extensions like __v4sf. // types, and for extensions like __v4sf.
Out << "T__clang_vec" << T->getNumElements() << '_';
mangleType(ET, Quals, Range); llvm::SmallString<64> TemplateMangling;
Out << "@@"; llvm::raw_svector_ostream Stream(TemplateMangling);
MicrosoftCXXNameMangler Extra(Context, Stream);
Stream << "?$";
Extra.mangleSourceName("__vector");
Extra.mangleType(QualType(ET, 0), Range, QMM_Escape);
Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(T->getNumElements()),
/*IsBoolean=*/false);
mangleArtificalTagType(TTK_Union, TemplateMangling, {"__clang"});
} }
} }

View File

@ -27,11 +27,11 @@ void foo256i(__m256i) {}
// We have a custom mangling for vector types not standardized by Intel. // We have a custom mangling for vector types not standardized by Intel.
void foov8hi(__v8hi) {} void foov8hi(__v8hi) {}
// CHECK: define void @"\01?foov8hi@@YAXT__clang_vec8_F@@@Z" // CHECK: define void @"\01?foov8hi@@YAXT?$__vector@F$07@__clang@@@Z"
typedef __attribute__((ext_vector_type(4))) int vi4b; typedef __attribute__((ext_vector_type(4))) int vi4b;
void foovi4b(vi4b) {} void foovi4b(vi4b) {}
// CHECK: define void @"\01?foovi4b@@YAXT__clang_vec4_H@@@Z" // CHECK: define void @"\01?foovi4b@@YAXT?$__vector@H$03@__clang@@@Z"
// Clang does not support vectors of complex types, so we can't test the // Clang does not support vectors of complex types, so we can't test the
// mangling of them. // mangling of them.