This is an archive of the discontinued LLVM Phabricator instance.

[amdgpu] Fix broken error detection in LDS lowering
ClosedPublic

Authored by JonChesterfield on Mar 23 2023, 5:42 PM.

Details

Summary

std::optional<uint32_t> can be compared to uint32_t without warning, but does
not compare to the value within the optional. It needs to be prefixed *.
Wconversion does not warn about this.

bool bug(uint32_t Offset, std::optional<uint32_t> Expect)
{
  return (Offset != Expect);
}
bool deref(uint32_t Offset, std::optional<uint32_t> Expect)
{
  return (Offset != *Expect);
}

Both compile without warnings. Wrote the former, intended the latter.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 5:42 PM
JonChesterfield requested review of this revision.Mar 23 2023, 5:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 5:42 PM
JonChesterfield retitled this revision from Summary: [amdgpu] Fix broken error detection in LDS lowering to Summary:[amdgpu] Fix broken error detection in LDS lowering.Mar 23 2023, 5:42 PM
JonChesterfield edited the summary of this revision. (Show Details)
JonChesterfield retitled this revision from Summary:[amdgpu] Fix broken error detection in LDS lowering to [amdgpu] Fix broken error detection in LDS lowering.Mar 23 2023, 6:25 PM
arsenm accepted this revision.Mar 24 2023, 5:17 PM
This revision is now accepted and ready to land.Mar 24 2023, 5:17 PM