r239421 - [ItaniumMangle] Mangle long double as __float128 for some Power targets
David Majnemer
david.majnemer at gmail.com
Tue Jun 9 11:05:34 PDT 2015
Author: majnemer
Date: Tue Jun 9 13:05:33 2015
New Revision: 239421
URL: http://llvm.org/viewvc/llvm-project?rev=239421&view=rev
Log:
[ItaniumMangle] Mangle long double as __float128 for some Power targets
GCC mangles long double like __float128 in order to support
compatibility with ABI variants which had a different interpretation of
long double.
This fixes PR23791.
Added:
cfe/trunk/test/CodeGenCXX/mangle-long-double.cpp
Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/Basic/Targets.cpp
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=239421&r1=239420&r2=239421&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Jun 9 13:05:33 2015
@@ -363,6 +363,10 @@ public:
return *LongDoubleFormat;
}
+ /// \brief Return true if the 'long double' type should be mangled like
+ /// __float128.
+ virtual bool useFloat128ManglingForLongDouble() const { return false; }
+
/// \brief Return the value for the C99 FLT_EVAL_METHOD macro.
virtual unsigned getFloatEvalMethod() const { return 0; }
Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=239421&r1=239420&r2=239421&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Jun 9 13:05:33 2015
@@ -2010,7 +2010,11 @@ void CXXNameMangler::mangleType(const Bu
case BuiltinType::Half: Out << "Dh"; break;
case BuiltinType::Float: Out << 'f'; break;
case BuiltinType::Double: Out << 'd'; break;
- case BuiltinType::LongDouble: Out << 'e'; break;
+ case BuiltinType::LongDouble:
+ Out << (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble()
+ ? 'g'
+ : 'e');
+ break;
case BuiltinType::NullPtr: Out << "Dn"; break;
#define BUILTIN_TYPE(Id, SingletonId)
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=239421&r1=239420&r2=239421&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Jun 9 13:05:33 2015
@@ -992,6 +992,12 @@ public:
bool hasSjLjLowering() const override {
return true;
}
+
+ bool useFloat128ManglingForLongDouble() const override {
+ return LongDoubleWidth == 128 &&
+ LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble &&
+ getTriple().isOSBinFormatELF();
+ }
};
const Builtin::Info PPCTargetInfo::BuiltinInfo[] = {
Added: cfe/trunk/test/CodeGenCXX/mangle-long-double.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-long-double.cpp?rev=239421&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-long-double.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/mangle-long-double.cpp Tue Jun 9 13:05:33 2015
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s --check-prefix=POWER64-LINUX
+// RUN: %clang_cc1 -triple powerpc-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s --check-prefix=POWER-LINUX
+// RUN: %clang_cc1 -triple powerpc64-apple-darwin9 %s -emit-llvm -o - | FileCheck %s --check-prefix=POWER64-DARWIN
+// RUN: %clang_cc1 -triple powerpc-apple-darwin9 %s -emit-llvm -o - | FileCheck %s --check-prefix=POWER-DARWIN
+
+void f(long double) {}
+// POWER64-LINUX: _Z1fg
+// POWER-LINUX: _Z1fg
+// POWER64-DARWIN: _Z1fe
+// POWER-DARWIN: _Z1fe
More information about the cfe-commits
mailing list