r201569 - MS ABI: Add support for mangling __restrict
Reid Kleckner
rnk at google.com
Tue Feb 18 10:14:04 PST 2014
I'm definitely in favor of moving more of the 'E' manglings for 64-bit
pointers into the qualifier mangling.
On Tue, Feb 18, 2014 at 4:58 AM, David Majnemer <david.majnemer at gmail.com>wrote:
> Author: majnemer
> Date: Tue Feb 18 06:58:35 2014
> New Revision: 201569
>
> URL: http://llvm.org/viewvc/llvm-project?rev=201569&view=rev
> Log:
> MS ABI: Add support for mangling __restrict
>
> Pointer types in the MSVC ABI are a bit awkward, the width of the
> pointer is considered a kind of CVR qualifier.
>
> Restrict is handled similarly to const and volatile but is mangled after
> the pointer width qualifier.
>
> This fixes PR18880.
>
> Modified:
> cfe/trunk/lib/AST/MicrosoftMangle.cpp
> cfe/trunk/lib/AST/Type.cpp
> cfe/trunk/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp
> cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
>
> Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=201569&r1=201568&r2=201569&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
> +++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Feb 18 06:58:35 2014
> @@ -145,7 +145,7 @@ private:
> void mangleOperatorName(OverloadedOperatorKind OO, SourceLocation Loc);
> void mangleCXXDtorType(CXXDtorType T);
> void mangleQualifiers(Qualifiers Quals, bool IsMember);
> - void manglePointerQualifiers(Qualifiers Quals);
> + void manglePointerQualifiers(Qualifiers Quals, const Type *PointeeType);
>
> void mangleUnscopedTemplateName(const TemplateDecl *ND);
> void mangleTemplateInstantiationName(const TemplateDecl *TD,
> @@ -1213,13 +1213,16 @@ void MicrosoftCXXNameMangler::mangleQual
> // FIXME: For now, just drop all extension qualifiers on the floor.
> }
>
> -void MicrosoftCXXNameMangler::manglePointerQualifiers(Qualifiers Quals) {
> +void MicrosoftCXXNameMangler::manglePointerQualifiers(Qualifiers Quals,
> + const Type
> *PointeeType) {
> // <pointer-cvr-qualifiers> ::= P # no qualifiers
> // ::= Q # const
> // ::= R # volatile
> // ::= S # const volatile
> bool HasConst = Quals.hasConst(),
> - HasVolatile = Quals.hasVolatile();
> + HasVolatile = Quals.hasVolatile(),
> + HasRestrict = Quals.hasRestrict();
> +
> if (HasConst && HasVolatile) {
> Out << 'S';
> } else if (HasVolatile) {
> @@ -1229,6 +1232,12 @@ void MicrosoftCXXNameMangler::manglePoin
> } else {
> Out << 'P';
> }
> +
> + if (PointersAre64Bit && PointeeType && !PointeeType->isFunctionType())
> + Out << 'E';
> +
> + if (HasRestrict)
> + Out << 'I';
> }
>
> void MicrosoftCXXNameMangler::mangleArgumentType(QualType T,
> @@ -1320,7 +1329,7 @@ void MicrosoftCXXNameMangler::mangleType
>
> // We have to mangle these now, while we still have enough information.
> if (IsPointer)
> - manglePointerQualifiers(Quals);
> + manglePointerQualifiers(Quals, T->getPointeeType().getTypePtr());
> const Type *ty = T.getTypePtr();
>
> switch (ty->getTypeClass()) {
> @@ -1656,7 +1665,7 @@ void MicrosoftCXXNameMangler::mangleType
> void MicrosoftCXXNameMangler::mangleDecayedArrayType(const ArrayType *T) {
> // This isn't a recursive mangling, so now we have to do it all in this
> // one call.
> - manglePointerQualifiers(T->getElementType().getQualifiers());
> + manglePointerQualifiers(T->getElementType().getQualifiers(), 0);
> mangleType(T->getElementType(), SourceRange());
> }
> void MicrosoftCXXNameMangler::mangleType(const ConstantArrayType *T,
> @@ -1728,8 +1737,6 @@ void MicrosoftCXXNameMangler::mangleType
> mangleName(T->getClass()->castAs<RecordType>()->getDecl());
> mangleFunctionType(FPT, 0, true);
> } else {
> - if (PointersAre64Bit && !T->getPointeeType()->isFunctionType())
> - Out << 'E';
> mangleQualifiers(PointeeType.getQualifiers(), true);
> mangleName(T->getClass()->castAs<RecordType>()->getDecl());
> mangleType(PointeeType, Range, QMM_Drop);
> @@ -1761,8 +1768,6 @@ void MicrosoftCXXNameMangler::mangleType
> void MicrosoftCXXNameMangler::mangleType(const PointerType *T,
> SourceRange Range) {
> QualType PointeeTy = T->getPointeeType();
> - if (PointersAre64Bit && !T->getPointeeType()->isFunctionType())
> - Out << 'E';
> mangleType(PointeeTy, Range);
> }
> void MicrosoftCXXNameMangler::mangleType(const ObjCObjectPointerType *T,
>
> Modified: cfe/trunk/lib/AST/Type.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=201569&r1=201568&r2=201569&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/AST/Type.cpp (original)
> +++ cfe/trunk/lib/AST/Type.cpp Tue Feb 18 06:58:35 2014
> @@ -422,6 +422,10 @@ QualType Type::getPointeeType() const {
> return BPT->getPointeeType();
> if (const ReferenceType *RT = getAs<ReferenceType>())
> return RT->getPointeeType();
> + if (const MemberPointerType *MPT = getAs<MemberPointerType>())
> + return MPT->getPointeeType();
> + if (const DecayedType *DT = getAs<DecayedType>())
> + return DT->getPointeeType();
> return QualType();
> }
>
>
> Modified: cfe/trunk/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp?rev=201569&r1=201568&r2=201569&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/mangle-ms-arg-qualifiers.cpp Tue Feb 18
> 06:58:35 2014
> @@ -37,6 +37,22 @@ void foo_sad(char * const volatile x) {}
> // CHECK: "\01?foo_sad@@YAXSAD at Z"
> // X64: "\01?foo_sad@@YAXSEAD at Z"
>
> +void foo_piad(char * __restrict x) {}
> +// CHECK: "\01?foo_piad@@YAXPIAD at Z"
> +// X64: "\01?foo_piad@@YAXPEIAD at Z"
> +
> +void foo_qiad(char * const __restrict x) {}
> +// CHECK: "\01?foo_qiad@@YAXQIAD at Z"
> +// X64: "\01?foo_qiad@@YAXQEIAD at Z"
> +
> +void foo_riad(char * volatile __restrict x) {}
> +// CHECK: "\01?foo_riad@@YAXRIAD at Z"
> +// X64: "\01?foo_riad@@YAXREIAD at Z"
> +
> +void foo_siad(char * const volatile __restrict x) {}
> +// CHECK: "\01?foo_siad@@YAXSIAD at Z"
> +// X64: "\01?foo_siad@@YAXSEIAD at Z"
> +
> void foo_papad(char ** x) {}
> // CHECK: "\01?foo_papad@@YAXPAPAD at Z"
> // X64: "\01?foo_papad@@YAXPEAPEAD at Z"
> @@ -238,3 +254,7 @@ void mangle_yes_backref2(fun_type *const
> void mangle_yes_backref3(ptr_to_fun_type *const, void (**const)(void)) {}
> // CHECK: "\01?mangle_yes_backref3@@YAXQAP6AXXZ0 at Z"
> // X64: "\01?mangle_yes_backref3@@YAXQEAP6AXXZ0 at Z"
> +
> +void mangle_yes_backref4(int *const __restrict, int *const __restrict) {}
> +// CHECK: "\01?mangle_yes_backref4@@YAXQIAH0 at Z"
> +// X64: "\01?mangle_yes_backref4@@YAXQEIAH0 at Z"
>
> Modified: cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms.cpp?rev=201569&r1=201568&r2=201569&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/mangle-ms.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/mangle-ms.cpp Tue Feb 18 06:58:35 2014
> @@ -99,6 +99,11 @@ extern const int * const h2 = &a;
> int i[10][20];
> // CHECK-DAG: @"\01?i@@3PAY0BE at HA"
>
> +typedef int (*FunT)(int, int);
> +FunT FunArr[10][20];
> +// CHECK-DAG: @"\01?FunArr@@3PAY0BE at P6AHHH@ZA"
> +// X64-DAG: @"\01?FunArr@@3PAY0BE at P6AHHH@ZA"
> +
> int (__stdcall *j)(signed char, unsigned char);
> // CHECK-DAG: @"\01?j@@3P6GHCE at ZA"
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140218/341890d3/attachment.html>
More information about the cfe-commits
mailing list