aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/TargetInfo.cpp
diff options
context:
space:
mode:
authorQiu Chaofan <qiucofan@cn.ibm.com>2020-11-19 14:20:24 +0800
committerQiu Chaofan <qiucofan@cn.ibm.com>2020-11-19 14:22:14 +0800
commit6b1341eb5bb71a1ce4547165a247b23bb30ef44e (patch)
tree3fdd72a3cbb947a073f14fe2198b72de4aaab21e /clang/lib/CodeGen/TargetInfo.cpp
parent4d8dede5e53a802bb35dd54cd693390793cb753f (diff)
downloadllvm-6b1341eb5bb71a1ce4547165a247b23bb30ef44e.zip
llvm-6b1341eb5bb71a1ce4547165a247b23bb30ef44e.tar.gz
llvm-6b1341eb5bb71a1ce4547165a247b23bb30ef44e.tar.bz2
[PowerPC] [Clang] Fix alignment of 128-bit float types
According to ELF v2 ABI, both IEEE 128-bit and IBM extended floating point variables should be quad-word (16 bytes) aligned. Previously, only vector types are considered aligned as quad-word on PowerPC. This patch will fix incorrectness of IEEE 128-bit float argument in va_arg cases. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D91596
Diffstat (limited to 'clang/lib/CodeGen/TargetInfo.cpp')
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index a98e409..64240b1 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -5051,6 +5051,11 @@ CharUnits PPC64_SVR4_ABIInfo::getParamTypeAlignment(QualType Ty) const {
return CharUnits::fromQuantity(16);
} else if (Ty->isVectorType()) {
return CharUnits::fromQuantity(getContext().getTypeSize(Ty) == 128 ? 16 : 8);
+ } else if (Ty->isRealFloatingType() && getContext().getTypeSize(Ty) == 128) {
+ // IEEE 128-bit floating numbers are also stored in vector registers.
+ // And both IEEE quad-precision and IBM extended double (ppc_fp128) should
+ // be quad-word aligned.
+ return CharUnits::fromQuantity(16);
}
// For single-element float/vector structs, we consider the whole type