llvm / llvm/llvm-project

[PowerPC] Wrong code at -O1

Open
#171,571 1 comment 0 reactions 0 assignees View on GitHub
backend:PowerPC miscompilation
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Reduced tescase: [reduced.c](https://github.com/user-attachments/files/24070790/reduced.c)
The testcase passed the UBSan and ASan: https://godbolt.org/z/dd8Kz49Y5

Reproduce command:
```bash
clang -O1 --target=powerpc64le-unknown-linux-musl -static reduced.c
qemu-ppc64le a.out
clang -O2 --target=powerpc64le-unknown-linux-musl -static reduced.c
qemu-ppc64le a.out
```

Output:
```
BackSmith Checksum = 0x0000000000000005
BackSmith Checksum = 0x0000000000000000
```

clang version 22.0.0git (git@github.com:llvm/llvm-project.git 0e92beb0c0f050e1180c88aa31713f3d6ba9d34e)

Contributor guide

Open the contributing guide

Research direction

Start with the attached reduced.c and run the two clang commands with qemu-ppc64le to reproduce the differing checksums at -O1 and -O2. Then trace the PowerPC compiler path involved in the generated code; the issue is complete when the reduced testcase no longer produces the reported wrong -O1 behavior and the result is verified.

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
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.