r302547 - [mips] Impose a threshold for coercion of aggregates
Author: petarj Date: Tue May 9 11:24:03 2017 New Revision: 302547 URL: http://llvm.org/viewvc/llvm-project?rev=302547&view=rev Log: [mips] Impose a threshold for coercion of aggregates Modified MipsABIInfo::classifyArgumentType so that it now coerces aggregate structures only if the size of said aggregate is less than 16/64 bytes, depending on the ABI. Patch by Stefan Maksimovic. Differential Revision: https://reviews.llvm.org/D32900 Added: cfe/trunk/test/CodeGen/mips-aggregate-arg.c Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=302547&r1=302546&r2=302547&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue May 9 11:24:03 2017 @@ -6695,6 +6695,14 @@ MipsABIInfo::classifyArgumentType(QualTy return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory); } +// Use indirect if the aggregate cannot fit into registers for +// passing arguments according to the ABI +unsigned Threshold = IsO32 ? 16 : 64; + +if(getContext().getTypeSizeInChars(Ty) > CharUnits::fromQuantity(Threshold)) + return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true, + getContext().getTypeAlign(Ty) / 8 > Align); + // If we have reached here, aggregates are passed directly by coercing to // another structure type. Padding is inserted if the offset of the // aggregate is unaligned. Added: cfe/trunk/test/CodeGen/mips-aggregate-arg.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-aggregate-arg.c?rev=302547&view=auto == --- cfe/trunk/test/CodeGen/mips-aggregate-arg.c (added) +++ cfe/trunk/test/CodeGen/mips-aggregate-arg.c Tue May 9 11:24:03 2017 @@ -0,0 +1,38 @@ +// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=O32 %s +// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s -target-abi n32 | FileCheck -check-prefix=N32-N64 %s +// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s -target-abi n64 | FileCheck -check-prefix=N32-N64 %s + +struct t1 { + char t1[10]; +}; + +struct t2 { + char t2[20]; +}; + +struct t3 { + char t3[65]; +}; + +extern struct t1 g1; +extern struct t2 g2; +extern struct t3 g3; +extern void f1(struct t1); +extern void f2(struct t2); +extern void f3(struct t3); + +void f() { + +// O32: call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7) +// O32: call void @f2(%struct.t2* byval align 4 %tmp) +// O32: call void @f3(%struct.t3* byval align 4 %tmp1) + +// N32-N64: call void @f1(i64 inreg %3, i16 inreg %5) +// N32-N64: call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13) +// N32-N64: call void @f3(%struct.t3* byval align 8 %tmp) + + f1(g1); + f2(g2); + f3(g3); +} + ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r302547 - [mips] Impose a threshold for coercion of aggregates
On Tue, May 9, 2017 at 9:24 AM, Petar Jovanovic via cfe-commits wrote: > Author: petarj > Date: Tue May 9 11:24:03 2017 > New Revision: 302547 > > URL: http://llvm.org/viewvc/llvm-project?rev=302547&view=rev > Log: > [mips] Impose a threshold for coercion of aggregates > > Modified MipsABIInfo::classifyArgumentType so that it now coerces aggregate > structures only if the size of said aggregate is less than 16/64 bytes, > depending on the ABI. > > Patch by Stefan Maksimovic. > > Differential Revision: https://reviews.llvm.org/D32900 > > Added: > cfe/trunk/test/CodeGen/mips-aggregate-arg.c > Modified: > cfe/trunk/lib/CodeGen/TargetInfo.cpp Looks like a test is failing due to this: http://bb.pgr.jp/builders/test-clang-x86_64-linux-R/builds/1932/steps/test_clang/logs/Clang%20%3A%3A%20CodeGen__mips-aggregate-arg.c ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
RE: r302547 - [mips] Impose a threshold for coercion of aggregates
Reverted in r302555. From: hwennb...@google.com [hwennb...@google.com] on behalf of Hans Wennborg [h...@chromium.org] Sent: Tuesday, May 09, 2017 7:18 PM To: Petar Jovanovic Cc: cfe-commits Subject: Re: r302547 - [mips] Impose a threshold for coercion of aggregates On Tue, May 9, 2017 at 9:24 AM, Petar Jovanovic via cfe-commits wrote: > Author: petarj > Date: Tue May 9 11:24:03 2017 > New Revision: 302547 > > URL: http://llvm.org/viewvc/llvm-project?rev=302547&view=rev > Log: > [mips] Impose a threshold for coercion of aggregates > > Modified MipsABIInfo::classifyArgumentType so that it now coerces aggregate > structures only if the size of said aggregate is less than 16/64 bytes, > depending on the ABI. > > Patch by Stefan Maksimovic. > > Differential Revision: https://reviews.llvm.org/D32900 > > Added: > cfe/trunk/test/CodeGen/mips-aggregate-arg.c > Modified: > cfe/trunk/lib/CodeGen/TargetInfo.cpp Looks like a test is failing due to this: http://bb.pgr.jp/builders/test-clang-x86_64-linux-R/builds/1932/steps/test_clang/logs/Clang%20%3A%3A%20CodeGen__mips-aggregate-arg.c ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r302555 - Revert r302547 ([mips] Impose a threshold for coercion of aggregates)
Author: petarj Date: Tue May 9 12:20:06 2017 New Revision: 302555 URL: http://llvm.org/viewvc/llvm-project?rev=302555&view=rev Log: Revert r302547 ([mips] Impose a threshold for coercion of aggregates) Reverting Modified MipsABIInfo::classifyArgumentType so that it now coerces aggregate structures only if the size of said aggregate is less than 16/64 bytes, depending on the ABI. as it broke clang-with-lto-ubuntu builder. Removed: cfe/trunk/test/CodeGen/mips-aggregate-arg.c Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=302555&r1=302554&r2=302555&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue May 9 12:20:06 2017 @@ -6695,14 +6695,6 @@ MipsABIInfo::classifyArgumentType(QualTy return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory); } -// Use indirect if the aggregate cannot fit into registers for -// passing arguments according to the ABI -unsigned Threshold = IsO32 ? 16 : 64; - -if(getContext().getTypeSizeInChars(Ty) > CharUnits::fromQuantity(Threshold)) - return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true, - getContext().getTypeAlign(Ty) / 8 > Align); - // If we have reached here, aggregates are passed directly by coercing to // another structure type. Padding is inserted if the offset of the // aggregate is unaligned. Removed: cfe/trunk/test/CodeGen/mips-aggregate-arg.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-aggregate-arg.c?rev=302554&view=auto == --- cfe/trunk/test/CodeGen/mips-aggregate-arg.c (original) +++ cfe/trunk/test/CodeGen/mips-aggregate-arg.c (removed) @@ -1,38 +0,0 @@ -// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=O32 %s -// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s -target-abi n32 | FileCheck -check-prefix=N32-N64 %s -// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s -target-abi n64 | FileCheck -check-prefix=N32-N64 %s - -struct t1 { - char t1[10]; -}; - -struct t2 { - char t2[20]; -}; - -struct t3 { - char t3[65]; -}; - -extern struct t1 g1; -extern struct t2 g2; -extern struct t3 g3; -extern void f1(struct t1); -extern void f2(struct t2); -extern void f3(struct t3); - -void f() { - -// O32: call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7) -// O32: call void @f2(%struct.t2* byval align 4 %tmp) -// O32: call void @f3(%struct.t3* byval align 4 %tmp1) - -// N32-N64: call void @f1(i64 inreg %3, i16 inreg %5) -// N32-N64: call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13) -// N32-N64: call void @f3(%struct.t3* byval align 8 %tmp) - - f1(g1); - f2(g2); - f3(g3); -} - ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits