Skip to content

Commit ed39f58

Browse files
committedSep 4, 2014
[mips] Zero-sized structs cannot be ignored in MipsABIInfo::classifyReturnType() for O32
Summary: They are returned indirectly which causes the other arguments to move to the next argument slot. With this, utils/ABITest does not discover any failing cases in the first 500 attempts on big/little endian for O32. Previously some of these failed. Also tested N32/N64 little endian (big endian has other known issues) with no issues. Reviewers: atanasyan Reviewed By: atanasyan Subscribers: atanasyan, cfe-commits Differential Revision: http://reviews.llvm.org/D4811 llvm-svn: 217147
1 parent d3b10d9 commit ed39f58

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed
 

‎clang/lib/CodeGen/TargetInfo.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -5548,7 +5548,12 @@ MipsABIInfo::returnAggregateInRegs(QualType RetTy, uint64_t Size) const {
55485548
ABIArgInfo MipsABIInfo::classifyReturnType(QualType RetTy) const {
55495549
uint64_t Size = getContext().getTypeSize(RetTy);
55505550

5551-
if (RetTy->isVoidType() || Size == 0)
5551+
if (RetTy->isVoidType())
5552+
return ABIArgInfo::getIgnore();
5553+
5554+
// O32 doesn't treat zero-sized structs differently from other structs.
5555+
// However, N32/N64 ignores zero sized return values.
5556+
if (!IsO32 && Size == 0)
55525557
return ABIArgInfo::getIgnore();
55535558

55545559
if (isAggregateTypeForABI(RetTy) || RetTy->isVectorType()) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %clang -target mips-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=O32 %s
2+
// RUN: %clang -target mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=O32 %s
3+
// RUN: %clang -target mips64-unknown-linux-gnu -S -emit-llvm -o - %s -mabi=n32 | FileCheck -check-prefix=N32 %s
4+
// RUN: %clang -target mips64el-unknown-linux-gnu -S -emit-llvm -o - %s -mabi=n32 | FileCheck -check-prefix=N32 %s
5+
// RUN: %clang -target mips64-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=N64 %s
6+
// RUN: %clang -target mips64el-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=N64 %s
7+
8+
// O32: define void @fn28(%struct.T2* noalias sret %agg.result, i8 signext %arg0)
9+
// N32: define void @fn28(i8 signext %arg0)
10+
// N64: define void @fn28(i8 signext %arg0)
11+
12+
typedef struct T2 { } T2;
13+
T2 T2_retval;
14+
T2 fn28(char arg0) {
15+
return T2_retval;
16+
}

0 commit comments

Comments
 (0)
Please sign in to comment.