| Issue |
83388
|
| Summary |
[X86] Incorrect union parameter value during function calls
|
| Labels |
backend:X86,
miscompilation,
ABI
|
| Assignees |
|
| Reporter |
linsinan1995
|
## 1. Problem
clang does not seem to be correctly passing union parameters in X86 backend.
## 2. How to reproduce
test.c
```c++
#include <stdbool.h>
#include <stdio.h>
typedef union{struct{float v0;double v1;}v0;struct{double v0;double v1;}v1;}t0;
typedef float t1;
typedef union{signed short v0[4];}t2;
typedef struct{unsigned int v0;union{bool v0;}v1;}t3;
typedef union{double v0[5];bool v1[16];}t4;
void __attribute__((noinline)) func(t0 v0, t1 v1, t2 v2, t3 v3, t4 v4)
{
printf("%.2f\n", v0.v1.v0);
printf("%llx\n", (unsigned long long)v0.v1.v0);
return;
}
int main()
{
t0 v0;
t1 v1;
t2 v2;
t3 v3;
t4 v4;
v0.v1.v0 = 1326003572768462080.0;
v0.v1.v1 = -9216063831952089088.0;
v1 = -9222032222277231616.0f;
v2.v0[0] = 32753;
v2.v0[1] = -32714;
v2.v0[2] = 23982;
v2.v0[3] = -31049;
v3.v0 = 4294967295U;
v3.v1.v0 = 0;
v4.v1[0] = 0;
v4.v1[1] = 1;
v4.v1[2] = 1;
v4.v1[3] = 1;
v4.v1[4] = 0;
v4.v1[5] = 1;
v4.v1[6] = 1;
v4.v1[7] = 1;
v4.v1[8] = 0;
v4.v1[9] = 1;
v4.v1[10] = 1;
v4.v1[11] = 0;
v4.v1[12] = 0;
v4.v1[13] = 0;
v4.v1[14] = 1;
v4.v1[15] = 0;
printf("%.2f\n", v0.v1.v0);
printf("%llx\n", (unsigned long long)v0.v1.v0);
func(v0, v1, v2, v3, v4);
}
```
clang test -o test
./test
```
1326003572768462080.00
1266e93955c35500
0.00
0
```
expect result:
```
1326003572768462080.00
1266e93955c35500
1326003572768462080.00
1266e93955c35500
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs