llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[AMDGPU] HIP miscompilation bug (aggregate assignment of nested unions)

Open ElliotBLabs opened this issue 6 months ago • 4 comments

The following HIP program triggers a miscompilation bug. The output should be a deterministic value as it's UB free. The bug manifests by enabling optimisations which cause a divergence in the printed value.

Test File: HIPProg.hip

How to reproduce:

  1. clang++ -O0 -x hip HIPProg.hip -Wno-c++11-narrowing --offload-arch=native -o O0.out
  2. clang++ -O1 -x hip HIPProg.hip -Wno-c++11-narrowing --offload-arch=native -o O1.out
  3. ./O0.out
  4. ./O1.out

Compare output values: Bug (-O1): 589824 Ref (-O0): 0

ElliotBLabs avatar May 19 '26 18:05 ElliotBLabs

tagging @mgcarrasco who is working on it confirmed in commit a4cd17e

ElliotBLabs avatar May 19 '26 19:05 ElliotBLabs

@llvm/issue-subscribers-backend-amdgpu

Author: ElliotBLabs

The following HIP program triggers a miscompilation bug. The output should be a deterministic value as it's UB free. The bug manifests by enabling optimisations which cause a divergence in the printed value.

Test File: HIPProg.hip

How to reproduce:

  1. clang++ -O0 -x hip HIPProg.hip -Wno-c++11-narrowing --offload-arch=native -o O0.out
  2. clang++ -O1 -x hip HIPProg.hip -Wno-c++11-narrowing --offload-arch=native -o O1.out
  3. ./O0.out
  4. ./O1.out

Compare output values: Bug (-O1): 589824 Ref (-O0): 0

Can you use more specific / unique titles? There are now at least 4 issues open with identical titles

arsenm avatar May 20 '26 06:05 arsenm

Can you use more specific / unique titles? There are now at least 4 issues open with identical titles

We can also refine them when more is known about the pass/reason for the miscompilation.

ElliotBLabs avatar May 20 '26 09:05 ElliotBLabs