llvm / llvm/llvm-project

[Sparc] Union containing float is passed in FPR, GCC passes via GPR

Open
#214,840 0 comments 0 reactions 0 assignees View on GitHub
ABI backend:Sparc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

https://godbolt.org/z/4YzPfYq61

```c
union u {
float f;
int i;
};

float foo(union u x) {
return x.f;
}

int bar(union u x) {
return x.i;
}
```

With clang the float function is a no-op

```asm
foo:
retl
nop

bar:
add %sp, -144, %sp
st %f0, [%sp+2187]
ldsw [%sp+2187], %o0
retl
add %sp, 144, %sp
```

While with GCC the integer version is a no-op

```asm
foo:
save %sp, -192, %sp
srlx %i0, 32, %i0
st %i0, [%fp+2043]
ld [%fp+2043], %f0
return %i7+8
nop
bar:
save %sp, -176, %sp
return %i7+8
srax %o0, 32, %o0
```

Contributor guide

Open the contributing guide

Research direction

Start with the Godbolt reproducer and the SPARC calling-convention handling for unions containing float and int members. Compare the generated Clang and GCC assembly for foo and bar, then add or update a regression test showing that both functions pass the union consistently with the intended ABI.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.