This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Fix off by one in assert
ClosedPublic

Authored by Flakebi on Oct 20 2020, 9:28 AM.

Details

Summary

D89217 did not subtract one when accessing SubRegFromChannelTable in one
place.

Diff Detail

Event Timeline

Flakebi created this revision.Oct 20 2020, 9:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 20 2020, 9:28 AM
Flakebi requested review of this revision.Oct 20 2020, 9:28 AM
critson accepted this revision.Oct 20 2020, 7:36 PM

LGTM.

Thanks, I was going to make the same change, but you beat me to it.
Slight nit. since we use Width - 1 three times, for readability I think we should just declare a new variable for it (TableIdx?).

We cannot easily have a test case for this as it is based on TableGen data.
I would have expected this assertion to be failing already due to the error, but looking at the code generation .size() for this type is a compile time constant, so in practice this becomes assert(Offset < 32), with the index completely disregarded.

This revision is now accepted and ready to land.Oct 20 2020, 7:36 PM
Flakebi updated this revision to Diff 299591.Oct 21 2020, 1:27 AM

I don’t see a way to add a test case. It fails an assertion on Windows when compiling with msvc.

Changed to use TableIdx.

Changed to use TableIdx.

Looks good, thanks!

This revision was landed with ongoing or failed builds.Oct 21 2020, 3:46 AM
This revision was automatically updated to reflect the committed changes.