diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2015-02-16 17:26:51 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2015-02-16 17:26:51 +0000 |
| commit | eb2af4e8b128795211923d79327ea7ed58ca66d2 (patch) | |
| tree | ead04dbbbbc3a64a490e94eb5e3b9a417dc38d82 /clang/lib/CodeGen | |
| parent | e7f4f86dff5b86ea1932d2f08388516520fe37a8 (diff) | |
| download | bcm5719-llvm-eb2af4e8b128795211923d79327ea7ed58ca66d2.tar.gz bcm5719-llvm-eb2af4e8b128795211923d79327ea7ed58ca66d2.zip | |
x86-64 ABI: unwrap single element structs / arrays of 256-bit vectors to pass and return in registers
This is a patch for PR22563 ( http://llvm.org/bugs/show_bug.cgi?id=22563 ).
We were not correctly unwrapping a single 256-bit AVX vector that was defined as an array of 1 inside a struct.
We would generate a <4 x float> param/return value instead of <8 x float> and lose half of the vector.
Differential Revision: http://reviews.llvm.org/D7614
llvm-svn: 229408
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 117767d0b36..8070e311746 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -2183,19 +2183,15 @@ ABIArgInfo X86_64ABIInfo::getIndirectResult(QualType Ty, return ABIArgInfo::getIndirect(Align); } -/// GetByteVectorType - The ABI specifies that a value should be passed in an -/// full vector XMM/YMM register. Pick an LLVM IR type that will be passed as a -/// vector register. +/// The ABI specifies that a value should be passed in a full vector XMM/YMM +/// register. Pick an LLVM IR type that will be passed as a vector register. llvm::Type *X86_64ABIInfo::GetByteVectorType(QualType Ty) const { - llvm::Type *IRType = CGT.ConvertType(Ty); + // Wrapper structs/arrays that only contain vectors are passed just like + // vectors; strip them off if present. + if (const Type *InnerTy = isSingleElementStruct(Ty, getContext())) + Ty = QualType(InnerTy, 0); - // Wrapper structs that just contain vectors are passed just like vectors, - // strip them off if present. - llvm::StructType *STy = dyn_cast<llvm::StructType>(IRType); - while (STy && STy->getNumElements() == 1) { - IRType = STy->getElementType(0); - STy = dyn_cast<llvm::StructType>(IRType); - } + llvm::Type *IRType = CGT.ConvertType(Ty); // If the preferred type is a 16-byte vector, prefer to pass it. if (llvm::VectorType *VT = dyn_cast<llvm::VectorType>(IRType)){ |

