https://github.com/koachan updated https://github.com/llvm/llvm-project/pull/217065
>From 09db49897e5ddb41474be49e93b41fa348acf323 Mon Sep 17 00:00:00 2001 From: Koakuma <[email protected]> Date: Tue, 18 Aug 2026 22:48:28 +0700 Subject: [PATCH 1/6] [clang][SPARC] Match zero-size struct lowering with GCC's Zero-sized struct arguments are lowered in a different way to other types: - If there are still free integer registers avaliable, it's lowered as if it's a normal i64, that is, it will occupy an i64 register, together with a corresponding shadow space in an f64 register and the stack. - After that, the arguments will occupy a f64 register starting from %d12, but *not* allocate a shadow space in the stack. - After the f64 register slots are exhausted, the arguments will not be allocated at all. To do this the clang frontend lowers ZSS arguments as `i64 inreg`s, and the backend allocates `i64 inreg` arguments following the scheme above. Fixes https://github.com/llvm/llvm-project/issues/213561. --- clang/lib/CodeGen/Targets/Sparc.cpp | 12 ++-- clang/test/CodeGen/Sparc/sparcv9-abi.c | 13 ++-- llvm/lib/Target/Sparc/SparcISelLowering.cpp | 71 +++++++++++++++++---- llvm/test/CodeGen/SPARC/inreg-i64-v9.ll | 47 ++++++++++++++ 4 files changed, 124 insertions(+), 19 deletions(-) create mode 100644 llvm/test/CodeGen/SPARC/inreg-i64-v9.ll diff --git a/clang/lib/CodeGen/Targets/Sparc.cpp b/clang/lib/CodeGen/Targets/Sparc.cpp index fcd2086964c488..c8166e63ba7905 100644 --- a/clang/lib/CodeGen/Targets/Sparc.cpp +++ b/clang/lib/CodeGen/Targets/Sparc.cpp @@ -306,6 +306,11 @@ class SparcV9ABIInfo : public ABIInfo { break; } } + + // Zero-sized structs gets the inreg flag; they are treated specially. + unsigned Size = DL.getTypeSizeInBits(StrTy).getKnownMinValue(); + if (!Size) + InReg = true; } // Check if Ty is a usable substitute for the coercion type. @@ -420,12 +425,11 @@ ABIArgInfo SparcV9ABIInfo::classifyType(QualType Ty, unsigned SizeLimit, CoerceBuilder CB(VMContext, getDataLayout(), IsVarArg); CB.addStruct(0, StrTy); + // All structs, even empty ones, should take up a register argument slot, // so pin the minimum struct size to one bit. - CB.pad(llvm::alignTo( - std::max(CB.DL.getTypeSizeInBits(StrTy).getKnownMinValue(), uint64_t(1)), - 64)); - RegOffset += PaddingSlots + CB.Size / 64; + uint64_t ActualSize = CB.DL.getTypeSizeInBits(StrTy).getKnownMinValue(); + CB.pad(llvm::alignTo(std::max(ActualSize, uint64_t(1)), 64)); // Try to use the original type for coercion. llvm::Type *CoerceTy = CB.isUsableType(StrTy) ? StrTy : CB.getType(); diff --git a/clang/test/CodeGen/Sparc/sparcv9-abi.c b/clang/test/CodeGen/Sparc/sparcv9-abi.c index 46556b7abfcab5..c37181d9ee168c 100644 --- a/clang/test/CodeGen/Sparc/sparcv9-abi.c +++ b/clang/test/CodeGen/Sparc/sparcv9-abi.c @@ -21,7 +21,7 @@ char f_int_4(char x) { return x; } // CHECK-LABEL: define{{.*}} fp128 @f_ld(fp128 noundef %x) long double f_ld(long double x) { return x; } -// Zero-sized structs reserves an argument register slot if passed directly. +// Zero-sized structs will be coerced into `i64 inreg`s. struct empty {}; struct emptyarr { struct empty a[10]; }; @@ -31,12 +31,17 @@ struct align16_int { _Alignas(16) int x; }; struct align16_mixed { _Alignas(16) int x; double y; }; struct align16_longdouble { long double x; }; -// CHECK-LABEL: define{{.*}} i64 @f_empty(i64 %x.coerce) +// CHECK-LABEL: define{{.*}} i64 @f_empty(i64 inreg %x.coerce) struct empty f_empty(struct empty x) { return x; } -// CHECK-LABEL: define{{.*}} i64 @f_emptyarr(i64 %x.coerce) +// CHECK-LABEL: define{{.*}} i64 @f_emptyarr(i64 inreg %x.coerce) struct empty f_emptyarr(struct emptyarr x) { return x.a[0]; } +// CHECK-LABEL: define{{.*}} i64 @f_emptystackarg(i64 inreg %a0.coerce, i64 inreg %a1.coerce, i64 inreg %a2.coerce, i64 inreg %a3.coerce, i64 inreg %a4.coerce, i64 inreg %a5.coerce, i64 inreg %a6.coerce, i64 inreg %a7.coerce) +struct empty f_emptystackarg(struct empty a0, struct empty a1, struct empty a2, struct empty a3, struct empty a4, struct empty a5, struct empty a6, struct empty a7) { + return a7; +} + // CHECK-LABEL: define{{.*}} void @f_aligncaller(i64 %a.coerce0, i64 %a.coerce1) // CHECK-LABEL: declare{{.*}} void @f_aligncallee(i32 noundef signext, i64, i64, i64) void f_aligncallee(int pad, struct align16_int a); @@ -98,7 +103,7 @@ long f_emptyvar(unsigned count, ...) { } // If the zero-sized struct is contained in a non-zero-sized struct, -// though, it doesn't reserve any registers. +// though, it disappears completely. struct emptymixed { struct empty a; long b; }; struct emptyflex { unsigned count; struct empty data[10]; }; diff --git a/llvm/lib/Target/Sparc/SparcISelLowering.cpp b/llvm/lib/Target/Sparc/SparcISelLowering.cpp index 4ab47cceb48529..03746475937fcf 100644 --- a/llvm/lib/Target/Sparc/SparcISelLowering.cpp +++ b/llvm/lib/Target/Sparc/SparcISelLowering.cpp @@ -44,6 +44,20 @@ using namespace llvm; // Calling Convention Implementation //===----------------------------------------------------------------------===// +static const MCPhysReg ArgIs[] = {SP::I0, SP::I1, SP::I2, + SP::I3, SP::I4, SP::I5}; + +static const MCPhysReg ArgFs[] = { + SP::F1, SP::F3, SP::F5, SP::F7, SP::F9, SP::F11, SP::F13, SP::F15, + SP::F17, SP::F19, SP::F21, SP::F23, SP::F25, SP::F27, SP::F29, SP::F31}; + +static const MCPhysReg ArgDs[] = { + SP::D0, SP::D1, SP::D2, SP::D3, SP::D4, SP::D5, SP::D6, SP::D7, + SP::D8, SP::D9, SP::D10, SP::D11, SP::D12, SP::D13, SP::D14, SP::D15}; + +static const MCPhysReg ArgQs[] = {SP::Q0, SP::Q1, SP::Q2, SP::Q3, + SP::Q4, SP::Q5, SP::Q6, SP::Q7}; + static bool CC_Sparc_Assign_SRet(unsigned &ValNo, MVT &ValVT, MVT &LocVT, CCValAssign::LocInfo &LocInfo, ISD::ArgFlagsTy &ArgFlags, CCState &State) @@ -114,25 +128,60 @@ static bool Analyze_CC_Sparc64_Full(bool IsReturn, unsigned &ValNo, MVT &ValVT, || LocVT.getSizeInBits() == 64) && "Can't handle non-64 bits locations"); - // Stack space is allocated for all arguments starting from [%fp+BIAS+128]. + // Zero-sized struct arguments are lowered as `i64 inreg`s, and here they get + // a special treatment: + // - If there are still free integer registers avaliable, it's lowered as if + // it's a normal i64. + // - After that, the arguments will occupy a f64 register starting from %d12 + // (SP::D6 in LLVM parlance), but *not* occupy a stack slot. + // - After the f64 register slots are exhausted, the arguments will not be + // allocated at all. + // This is to match GCC's lowering behavior. + // See also: + // https://github.com/llvm/llvm-project/issues/213561#issuecomment-5377850094 + if (!IsReturn && LocVT == MVT::i64 && ArgFlags.isInReg() && + State.isAllocated(SP::I5)) { + Register Reg = State.AllocateReg(ArgDs); + if (Reg) + State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo)); + return true; + } + + // Stack space is allocated for all non-inreg arguments and the first six + // i64 inreg arguments starting from [%fp+BIAS+128]. unsigned size = (LocVT == MVT::f128) ? 16 : 8; Align alignment = (LocVT == MVT::f128 || ArgFlags.isSplit()) ? Align(16) : Align(8); unsigned Offset = State.AllocateStack(size, alignment); - unsigned Reg = 0; + Register Reg = 0; - if (LocVT == MVT::i64 && Offset < 6*8) + if (LocVT == MVT::i64) { // Promote integers to %i0-%i5. - Reg = SP::I0 + Offset/8; - else if (LocVT == MVT::f64 && Offset < 16*8) - // Promote doubles to %d0-%d30. (Which LLVM calls D0-D15). - Reg = SP::D0 + Offset/8; - else if (LocVT == MVT::f32 && Offset < 16*8) + if (ArgFlags.isSplit() && + ((State.getFirstUnallocated(ArgIs) - SP::I0) % 2 != 0)) { + // We are receiving a split i128, pad so we have an even-numbered + // integer register. + State.AllocateReg(ArgIs); + State.AllocateReg(ArgDs); // Shadow allocation. + } + + Reg = State.AllocateReg(ArgIs); + State.AllocateReg(ArgDs); // Shadow allocation. + } else if (LocVT == MVT::f32) { // Promote floats to %f1, %f3, ... - Reg = SP::F1 + Offset/4; - else if (LocVT == MVT::f128 && Offset < 16*8) + Reg = State.AllocateReg(ArgFs); + State.AllocateReg(ArgIs); // Shadow allocation. + } else if (LocVT == MVT::f64) { + // Promote doubles to %d0-%d30. (Which LLVM calls D0-D15). + Reg = State.AllocateReg(ArgDs); + State.AllocateReg(ArgIs); // Shadow allocation. + } else if (LocVT == MVT::f128) { // Promote long doubles to %q0-%q28. (Which LLVM calls Q0-Q7). - Reg = SP::Q0 + Offset/16; + Reg = State.AllocateReg(ArgQs); + // Shadow allocation. + for (int i = 0; i < 2; i++) + State.AllocateReg(ArgIs); + } // Promote to register when possible, otherwise use the stack slot. if (Reg) { diff --git a/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll b/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll new file mode 100644 index 00000000000000..6dcf3ca0b14836 --- /dev/null +++ b/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll @@ -0,0 +1,47 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -mtriple=sparcv9 | FileCheck %s -check-prefix=SPARC64 + +;; `i64 inreg`s get a special treatment when lowered + +declare void @callee1(i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i8 noundef zeroext) + +define void @caller1() nounwind { +; SPARC64-LABEL: caller1: +; SPARC64: ! %bb.0: ! %entry +; SPARC64-NEXT: save %sp, -192, %sp +; SPARC64-NEXT: mov 90, %i0 +; SPARC64-NEXT: call callee1 +; SPARC64-NEXT: stx %i0, [%sp+2223] +; SPARC64-NEXT: ret +; SPARC64-NEXT: restore +entry: + tail call void @callee1(i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i8 noundef zeroext 90) + ret void +} + +declare void @callee2(i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i8 noundef zeroext) + +define void @caller2() nounwind { +; SPARC64-LABEL: caller2: +; SPARC64: ! %bb.0: ! %entry +; SPARC64-NEXT: save %sp, -192, %sp +; SPARC64-NEXT: mov 90, %i0 +; SPARC64-NEXT: call callee2 +; SPARC64-NEXT: stx %i0, [%sp+2223] +; SPARC64-NEXT: ret +; SPARC64-NEXT: restore +entry: + tail call void @callee2(i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i8 noundef zeroext 90) + ret void +} + + +define noundef float @floatret(i64 inreg %.coerce, i64 inreg %.coerce1, i64 inreg %.coerce2, i64 inreg %.coerce3, i64 inreg %.coerce4, i64 inreg %.coerce5, i64 inreg %.coerce6, float noundef returned %v) nounwind { +; SPARC64-LABEL: floatret: +; SPARC64: ! %bb.0: ! %entry +; SPARC64-NEXT: fmovs %f15, %f0 +; SPARC64-NEXT: retl +; SPARC64-NEXT: nop +entry: + ret float %v +} >From 363e4fe075d7f99bdf82f426eb473941616b8fea Mon Sep 17 00:00:00 2001 From: Koakuma <[email protected]> Date: Sun, 15 Nov 2026 09:38:16 +0700 Subject: [PATCH 2/6] Remove undef --- llvm/test/CodeGen/SPARC/inreg-i64-v9.ll | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll b/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll index 6dcf3ca0b14836..1bc0a6ad7bef0e 100644 --- a/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll +++ b/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll @@ -3,7 +3,7 @@ ;; `i64 inreg`s get a special treatment when lowered -declare void @callee1(i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i8 noundef zeroext) +declare void @callee1(i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i8 zeroext) define void @caller1() nounwind { ; SPARC64-LABEL: caller1: @@ -15,11 +15,11 @@ define void @caller1() nounwind { ; SPARC64-NEXT: ret ; SPARC64-NEXT: restore entry: - tail call void @callee1(i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i8 noundef zeroext 90) + tail call void @callee1(i64 inreg poison, i64 inreg poison, i64 inreg poison, i64 inreg poison, i64 inreg poison, i64 inreg poison, i64 inreg poison, i8 zeroext 90) ret void } -declare void @callee2(i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i8 noundef zeroext) +declare void @callee2(i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i8 zeroext) define void @caller2() nounwind { ; SPARC64-LABEL: caller2: @@ -31,12 +31,12 @@ define void @caller2() nounwind { ; SPARC64-NEXT: ret ; SPARC64-NEXT: restore entry: - tail call void @callee2(i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i64 inreg undef, i8 noundef zeroext 90) + tail call void @callee2(i64 inreg poison, i64 inreg poison, i64 inreg poison, i64 inreg poison, i64 inreg poison, i64 inreg poison, i64 inreg poison, i64 inreg poison, i8 zeroext 90) ret void } -define noundef float @floatret(i64 inreg %.coerce, i64 inreg %.coerce1, i64 inreg %.coerce2, i64 inreg %.coerce3, i64 inreg %.coerce4, i64 inreg %.coerce5, i64 inreg %.coerce6, float noundef returned %v) nounwind { +define nopoison float @floatret(i64 inreg %.coerce, i64 inreg %.coerce1, i64 inreg %.coerce2, i64 inreg %.coerce3, i64 inreg %.coerce4, i64 inreg %.coerce5, i64 inreg %.coerce6, float nopoison returned %v) nounwind { ; SPARC64-LABEL: floatret: ; SPARC64: ! %bb.0: ! %entry ; SPARC64-NEXT: fmovs %f15, %f0 >From 67398eb5684ae9a5820bd1f0287c375045d0aa62 Mon Sep 17 00:00:00 2001 From: Koakuma <[email protected]> Date: Sun, 15 Nov 2026 12:06:30 +0700 Subject: [PATCH 3/6] Fix typo --- llvm/test/CodeGen/SPARC/inreg-i64-v9.ll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll b/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll index 1bc0a6ad7bef0e..101acd332114bf 100644 --- a/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll +++ b/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll @@ -36,7 +36,7 @@ entry: } -define nopoison float @floatret(i64 inreg %.coerce, i64 inreg %.coerce1, i64 inreg %.coerce2, i64 inreg %.coerce3, i64 inreg %.coerce4, i64 inreg %.coerce5, i64 inreg %.coerce6, float nopoison returned %v) nounwind { +define float @floatret(i64 inreg %.coerce, i64 inreg %.coerce1, i64 inreg %.coerce2, i64 inreg %.coerce3, i64 inreg %.coerce4, i64 inreg %.coerce5, i64 inreg %.coerce6, float %v) nounwind { ; SPARC64-LABEL: floatret: ; SPARC64: ! %bb.0: ! %entry ; SPARC64-NEXT: fmovs %f15, %f0 >From e196e510e1335a64d0ceab20d0ec65b2e92424ea Mon Sep 17 00:00:00 2001 From: Koakuma <[email protected]> Date: Sun, 15 Nov 2026 14:59:54 +0700 Subject: [PATCH 4/6] Add explanation in clang's Sparc.cpp --- clang/lib/CodeGen/Targets/Sparc.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/clang/lib/CodeGen/Targets/Sparc.cpp b/clang/lib/CodeGen/Targets/Sparc.cpp index c8166e63ba7905..25d05552c339f2 100644 --- a/clang/lib/CodeGen/Targets/Sparc.cpp +++ b/clang/lib/CodeGen/Targets/Sparc.cpp @@ -193,6 +193,16 @@ class SparcV8TargetCodeGenInfo : public TargetCodeGenInfo { // the inreg arguments. All other arguments are allocated a multiple of 8 // bytes. // +// Zero-sized structs have a special treatment: +// - The first six occupies a full i64 argument slot. +// - The next ten occupies a f64 register (but *not* reserve a shadow space in +// the stack). +// - Further arguments won't occupy any space. +// This is represented as i64 with the LLVM IR inreg attribute: +// +// declare void f(i64 inreg %a) +// +// The backend then takes care of allocating the space for it. namespace { class SparcV9ABIInfo : public ABIInfo { public: >From 6c870fd6a87efe06f0a0409f469e75559d2214fa Mon Sep 17 00:00:00 2001 From: Koakuma <[email protected]> Date: Mon, 16 Nov 2026 21:09:14 +0700 Subject: [PATCH 5/6] Reword comments --- clang/lib/CodeGen/Targets/Sparc.cpp | 15 ++++++++------- llvm/lib/Target/Sparc/SparcISelLowering.cpp | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/clang/lib/CodeGen/Targets/Sparc.cpp b/clang/lib/CodeGen/Targets/Sparc.cpp index 25d05552c339f2..4c02ad6103d774 100644 --- a/clang/lib/CodeGen/Targets/Sparc.cpp +++ b/clang/lib/CodeGen/Targets/Sparc.cpp @@ -194,11 +194,11 @@ class SparcV8TargetCodeGenInfo : public TargetCodeGenInfo { // bytes. // // Zero-sized structs have a special treatment: -// - The first six occupies a full i64 argument slot. -// - The next ten occupies a f64 register (but *not* reserve a shadow space in -// the stack). +// - Initially it will be allocated as if it's a normal i64. +// - If we run out of available integer registers, it'll occupy an f64 register +// (but *not* reserve a shadow space in the stack). // - Further arguments won't occupy any space. -// This is represented as i64 with the LLVM IR inreg attribute: +// A zero-sized struct is represented as i64 with the LLVM IR inreg attribute: // // declare void f(i64 inreg %a) // @@ -317,7 +317,7 @@ class SparcV9ABIInfo : public ABIInfo { } } - // Zero-sized structs gets the inreg flag; they are treated specially. + // Zero-sized structs get the inreg flag; they are treated specially. unsigned Size = DL.getTypeSizeInBits(StrTy).getKnownMinValue(); if (!Size) InReg = true; @@ -436,10 +436,11 @@ ABIArgInfo SparcV9ABIInfo::classifyType(QualType Ty, unsigned SizeLimit, CoerceBuilder CB(VMContext, getDataLayout(), IsVarArg); CB.addStruct(0, StrTy); - // All structs, even empty ones, should take up a register argument slot, - // so pin the minimum struct size to one bit. + // All structs, even zero-sized ones, should take up a register argument + // slot, so pin the minimum struct size to one bit. uint64_t ActualSize = CB.DL.getTypeSizeInBits(StrTy).getKnownMinValue(); CB.pad(llvm::alignTo(std::max(ActualSize, uint64_t(1)), 64)); + RegOffset += PaddingSlots + CB.Size / 64; // Try to use the original type for coercion. llvm::Type *CoerceTy = CB.isUsableType(StrTy) ? StrTy : CB.getType(); diff --git a/llvm/lib/Target/Sparc/SparcISelLowering.cpp b/llvm/lib/Target/Sparc/SparcISelLowering.cpp index 03746475937fcf..3d552c4fc531c0 100644 --- a/llvm/lib/Target/Sparc/SparcISelLowering.cpp +++ b/llvm/lib/Target/Sparc/SparcISelLowering.cpp @@ -141,7 +141,7 @@ static bool Analyze_CC_Sparc64_Full(bool IsReturn, unsigned &ValNo, MVT &ValVT, // https://github.com/llvm/llvm-project/issues/213561#issuecomment-5377850094 if (!IsReturn && LocVT == MVT::i64 && ArgFlags.isInReg() && State.isAllocated(SP::I5)) { - Register Reg = State.AllocateReg(ArgDs); + MCRegister Reg = State.AllocateReg(ArgDs); if (Reg) State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo)); return true; @@ -153,7 +153,7 @@ static bool Analyze_CC_Sparc64_Full(bool IsReturn, unsigned &ValNo, MVT &ValVT, Align alignment = (LocVT == MVT::f128 || ArgFlags.isSplit()) ? Align(16) : Align(8); unsigned Offset = State.AllocateStack(size, alignment); - Register Reg = 0; + MCRegister Reg = 0; if (LocVT == MVT::i64) { // Promote integers to %i0-%i5. >From 3dc891d87d653778e1254633791a67c4e868eeba Mon Sep 17 00:00:00 2001 From: Koakuma <[email protected]> Date: Sun, 22 Nov 2026 17:45:41 +0700 Subject: [PATCH 6/6] Add tests based on GH issue --- llvm/test/CodeGen/SPARC/inreg-i64-v9.ll | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll b/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll index 101acd332114bf..7733052522fb73 100644 --- a/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll +++ b/llvm/test/CodeGen/SPARC/inreg-i64-v9.ll @@ -35,6 +35,42 @@ entry: ret void } +declare void @callee3(i64 inreg, float, i64 inreg, i64 inreg, i64 inreg, i32, i64 inreg, i64 inreg, i32, i64 inreg, i64 inreg, float, i64 inreg, i64 inreg, i64 inreg, i64 inreg, i32, float) + +define void @caller3() nounwind { +;; The arguments should be placed as follows: +;; 1.0 in %f3 +;; 2 in %o5 +;; 3 in stack slot starting at %sp+BIAS+176 (%sp+2223) +;; 4.0 in %f23 +;; 5 in stack slot starting at %sp+BIAS+192 (%sp+2239) +;; 6.0 in stack slot starting at %sp+BIAS+200 (%sp+2247) +;; See also: https://github.com/llvm/llvm-project/issues/213561#issuecomment-5377850094 +; SPARC64-LABEL: caller3: +; SPARC64: ! %bb.0: ! %entry +; SPARC64-NEXT: save %sp, -208, %sp +; SPARC64-NEXT: sethi 1060864, %i0 +; SPARC64-NEXT: st %i0, [%sp+2251] +; SPARC64-NEXT: mov 5, %i0 +; SPARC64-NEXT: sethi %h44(.LCPI2_0), %i1 +; SPARC64-NEXT: add %i1, %m44(.LCPI2_0), %i1 +; SPARC64-NEXT: sllx %i1, 12, %i1 +; SPARC64-NEXT: ld [%i1+%l44(.LCPI2_0)], %f3 +; SPARC64-NEXT: sethi %h44(.LCPI2_1), %i1 +; SPARC64-NEXT: add %i1, %m44(.LCPI2_1), %i1 +; SPARC64-NEXT: sllx %i1, 12, %i1 +; SPARC64-NEXT: ld [%i1+%l44(.LCPI2_1)], %f23 +; SPARC64-NEXT: stx %i0, [%sp+2239] +; SPARC64-NEXT: mov 3, %i0 +; SPARC64-NEXT: mov 2, %o5 +; SPARC64-NEXT: call callee3 +; SPARC64-NEXT: stx %i0, [%sp+2223] +; SPARC64-NEXT: ret +; SPARC64-NEXT: restore +entry: +tail call void @callee3(i64 inreg poison, float 1.0, i64 inreg poison, i64 inreg poison, i64 inreg poison, i32 2, i64 inreg poison, i64 inreg poison, i32 3, i64 inreg poison, i64 inreg poison, float 4.0, i64 inreg poison, i64 inreg poison, i64 inreg poison, i64 inreg poison, i32 5, float 6.0) + ret void +} define float @floatret(i64 inreg %.coerce, i64 inreg %.coerce1, i64 inreg %.coerce2, i64 inreg %.coerce3, i64 inreg %.coerce4, i64 inreg %.coerce5, i64 inreg %.coerce6, float %v) nounwind { ; SPARC64-LABEL: floatret: _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
