This is an archive of the discontinued LLVM Phabricator instance.

[amdgpu][lds] Fix missing markUsedByKernel calls and undef lookup table elements
ClosedPublic

Authored by JonChesterfield on Jul 11 2023, 7:43 AM.

Details

Summary

More robust association between the kernels and lds struct.

Use poison instead of value() for lookup table elements introduced by dynamic lds lowering.

Extracted from D154946, new test from there verbatim. Segv fixed.

Fixes issues/63338

Fixes SWDEV-404491

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2023, 7:43 AM
JonChesterfield requested review of this revision.Jul 11 2023, 7:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2023, 7:43 AM
JonChesterfield edited the summary of this revision. (Show Details)Jul 11 2023, 7:45 AM
JonChesterfield retitled this revision from partial fix to [amdgpu][lds] Fix missing markUsedByKernel calls.Jul 11 2023, 12:16 PM
JonChesterfield edited the summary of this revision. (Show Details)
JonChesterfield planned changes to this revision.Jul 11 2023, 12:23 PM

Not pleased with the churn in ds_write2.ll here, trying to address that in a separate patch. There are a few more tests that need updating still to go.

  • [amdgpu][lds] Fix missing markUsedByKernel calls
  • ds_write
  • update most tests

Don't see which one is the new asserting test?

llvm/test/CodeGen/AMDGPU/noclobber-barrier.ll
590 ↗(On Diff #539308)

Most of the test churn is from update_test_checks learning to check metadata

  • test updates, more conservative annotation
JonChesterfield edited the summary of this revision. (Show Details)Jul 11 2023, 3:56 PM
JonChesterfield added a reviewer: arsenm.
arsenm added inline comments.Jul 11 2023, 3:58 PM
llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
974

The insert-on-not-found behavior of operator[] is evil, avoid using it?

Reasonably interesting. Introducing a llvm.donothing with an explicit use of a global changes codegen. The checks in noclobber-barrier fail for one of the atomic optimizer strategy options, looks like a regression to me.

@arsenm the segv test case in D154946 is half-fixed by this. That test crashes on use of an accidentally default initialised value, and if that is fixed, crashes at this point. Splitting the two failures out because the change is mostly noise in test cases.

llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
1178

This ^ crashes if the ith kernel doesn't have an associated struct, which happens if the ith kernel was only given an index for a dynamic LDS variable. This patch fixes that and the above todo by annotating the struct close to where it was created.

Does llvm.donothing not have enough memory attributes?

  • avoid operator[]
JonChesterfield marked an inline comment as done.Jul 11 2023, 4:11 PM
JonChesterfield added inline comments.
llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
974

It's a map<function*, set<globalvariable*>> so putting a default initialised value doesn't matter much. There are a lot of calls to operator[] in this file, I think I'm convinced they should all be purged as part of adding const to places. I'll avoid introducing this one.

JonChesterfield marked an inline comment as done.
  • Fix the crash as well
arsenm accepted this revision.Jul 11 2023, 4:23 PM

Add the fixes # thing to the commit message so it gets auto closed

llvm/test/CodeGen/AMDGPU/lower-module-lds-all-indirect-accesses.ll
4

Add comment explaining the test and link to the issue?

This revision is now accepted and ready to land.Jul 11 2023, 4:23 PM
JonChesterfield retitled this revision from [amdgpu][lds] Fix missing markUsedByKernel calls to [amdgpu][lds] Fix missing markUsedByKernel calls and undef lookup table elements.Jul 11 2023, 4:25 PM
JonChesterfield edited the summary of this revision. (Show Details)
JonChesterfield edited the summary of this revision. (Show Details)
JonChesterfield edited the summary of this revision. (Show Details)Jul 11 2023, 4:30 PM
  • comment in regression test

Add the fixes # thing to the commit message so it gets auto closed

Good call, thanks!

llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
515–516

One segv was here. This is assigning an array element for each kernel in OrderedKernels, where some might not have a corresponding kernel struct

This revision was landed with ongoing or failed builds.Jul 11 2023, 4:37 PM
This revision was automatically updated to reflect the committed changes.