Index: include/clang/Basic/TargetInfo.h =================================================================== --- include/clang/Basic/TargetInfo.h +++ include/clang/Basic/TargetInfo.h @@ -599,9 +599,11 @@ return *Float128Format; } - /// Return true if the 'long double' type should be mangled like - /// __float128. - virtual bool useFloat128ManglingForLongDouble() const { return false; } + /// Return the mangled type of long double. + virtual const char *getManglingForLongDouble() const { return "e"; } + + /// Return the mangled type of __float128. + virtual const char *getManglingForFloat128() const { return "g"; } /// Return the value for the C99 FLT_EVAL_METHOD macro. virtual unsigned getFloatEvalMethod() const { return 0; } Index: lib/AST/ItaniumMangle.cpp =================================================================== --- lib/AST/ItaniumMangle.cpp +++ lib/AST/ItaniumMangle.cpp @@ -2608,30 +2608,19 @@ Out << 'd'; break; case BuiltinType::LongDouble: { - bool UseFloat128Mangling = - getASTContext().getTargetInfo().useFloat128ManglingForLongDouble(); - if (getASTContext().getLangOpts().OpenMP && - getASTContext().getLangOpts().OpenMPIsDevice) { - UseFloat128Mangling = getASTContext() - .getAuxTargetInfo() - ->useFloat128ManglingForLongDouble(); - } - Out << (UseFloat128Mangling ? 'g' : 'e'); + const TargetInfo *TI = getASTContext().getLangOpts().OpenMP && + getASTContext().getLangOpts().OpenMPIsDevice + ? getASTContext().getAuxTargetInfo() + : &getASTContext().getTargetInfo(); + Out << TI->getManglingForLongDouble(); break; } case BuiltinType::Float128: { - bool UseFloat128Mangling = - getASTContext().getTargetInfo().useFloat128ManglingForLongDouble(); - if (getASTContext().getLangOpts().OpenMP && - getASTContext().getLangOpts().OpenMPIsDevice) { - UseFloat128Mangling = getASTContext() - .getAuxTargetInfo() - ->useFloat128ManglingForLongDouble(); - } - if (UseFloat128Mangling) - Out << "U10__float128"; // Match the GCC mangling - else - Out << 'g'; + const TargetInfo *TI = getASTContext().getLangOpts().OpenMP && + getASTContext().getLangOpts().OpenMPIsDevice + ? getASTContext().getAuxTargetInfo() + : &getASTContext().getTargetInfo(); + Out << TI->getManglingForFloat128(); break; } case BuiltinType::NullPtr: Index: lib/Basic/Targets/PPC.h =================================================================== --- lib/Basic/Targets/PPC.h +++ lib/Basic/Targets/PPC.h @@ -314,10 +314,15 @@ bool hasSjLjLowering() const override { return true; } - bool useFloat128ManglingForLongDouble() const override { - return LongDoubleWidth == 128 && - LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble() && - getTriple().isOSBinFormatELF(); + const char *getManglingForLongDouble() const override { + if (LongDoubleWidth == 64) + return "e"; + return LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble() + ? "g" + : "U10__float128"; + } + const char *getManglingForFloat128() const override { + return "U10__float128"; } }; Index: lib/Basic/Targets/SystemZ.h =================================================================== --- lib/Basic/Targets/SystemZ.h +++ lib/Basic/Targets/SystemZ.h @@ -141,7 +141,7 @@ return ""; } - bool useFloat128ManglingForLongDouble() const override { return true; } + const char *getManglingForLongDouble() const override { return "g"; } }; } // namespace targets } // namespace clang Index: lib/Basic/Targets/X86.h =================================================================== --- lib/Basic/Targets/X86.h +++ lib/Basic/Targets/X86.h @@ -848,7 +848,12 @@ LongDoubleFormat = &llvm::APFloat::IEEEquad(); } - bool useFloat128ManglingForLongDouble() const override { return true; } + const char *getManglingForLongDouble() const override { + return LongDoubleWidth == 128 ? "g" : "e"; + } + const char *getManglingForFloat128() const override { + return "U10__float128"; + } }; } // namespace targets } // namespace clang