r256556 - [MS ABI] Cleanup our mangling of vector types
David Majnemer via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 29 03:45:58 PST 2015
Author: majnemer
Date: Tue Dec 29 05:45:58 2015
New Revision: 256556
URL: http://llvm.org/viewvc/llvm-project?rev=256556&view=rev
Log:
[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>
Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-vector-types.cpp
Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=256556&r1=256555&r2=256556&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Dec 29 05:45:58 2015
@@ -2227,7 +2227,7 @@ void MicrosoftCXXNameMangler::mangleType
uint64_t Width = getASTContext().getTypeSize(T);
// Pattern match exactly the typedefs in our intrinsic headers. Anything that
// doesn't match the Intel types uses a custom mangling below.
- bool IsBuiltin = true;
+ size_t OutSizeBefore = Out.tell();
llvm::Triple::ArchType AT =
getASTContext().getTargetInfo().getTriple().getArch();
if (AT == llvm::Triple::x86 || AT == llvm::Triple::x86_64) {
@@ -2240,22 +2240,25 @@ void MicrosoftCXXNameMangler::mangleType
mangleArtificalTagType(TTK_Union, "__m" + llvm::utostr(Width) + 'i');
else if (ET->getKind() == BuiltinType::Double)
mangleArtificalTagType(TTK_Struct, "__m" + llvm::utostr(Width) + 'd');
- else
- IsBuiltin = false;
- } else {
- IsBuiltin = false;
}
- } else {
- IsBuiltin = false;
}
+ bool IsBuiltin = Out.tell() != OutSizeBefore;
if (!IsBuiltin) {
// 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
// types, and for extensions like __v4sf.
- Out << "T__clang_vec" << T->getNumElements() << '_';
- mangleType(ET, Quals, Range);
- Out << "@@";
+
+ llvm::SmallString<64> TemplateMangling;
+ 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"});
}
}
Modified: cfe/trunk/test/CodeGenCXX/mangle-ms-vector-types.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-vector-types.cpp?rev=256556&r1=256555&r2=256556&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-ms-vector-types.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-vector-types.cpp Tue Dec 29 05:45:58 2015
@@ -27,11 +27,11 @@ void foo256i(__m256i) {}
// We have a custom mangling for vector types not standardized by Intel.
void foov8hi(__v8hi) {}
-// CHECK: define void @"\01?foov8hi@@YAXT__clang_vec8_F@@@Z"
+// CHECK: define void @"\01?foov8hi@@YAXT?$__vector at F$07 at __clang@@@Z"
typedef __attribute__((ext_vector_type(4))) int vi4b;
void foovi4b(vi4b) {}
-// CHECK: define void @"\01?foovi4b@@YAXT__clang_vec4_H@@@Z"
+// CHECK: define void @"\01?foovi4b@@YAXT?$__vector at H$03 at __clang@@@Z"
// Clang does not support vectors of complex types, so we can't test the
// mangling of them.
More information about the cfe-commits
mailing list