This is an archive of the discontinued LLVM Phabricator instance.

[libomptarget][nfc][amdgpu] Factor out setting upper bounds
ClosedPublic

Authored by JonChesterfield on May 25 2021, 8:38 AM.

Details

Summary

Refactor suggested in D103037 to help avoid similar copy-paste errors.
Change is mechanical. Some parts of this would be more robust with unsigned.

Diff Detail

Event Timeline

JonChesterfield requested review of this revision.May 25 2021, 8:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2021, 8:38 AM
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
804–805

minor change here, previously a single error message was used for either case.

JonChesterfield edited the summary of this revision. (Show Details)May 25 2021, 3:17 PM
dhruvachak added inline comments.May 26 2021, 10:44 AM
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
739

How about making the change that clang-tidy is suggesting here?

Another question: Any specific reason why you are not using std::min? Is it because emitting the DP becomes a bit cumbersome?

openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
739

Pretty much. min doesn't say whether it made a change or not, and we've tied debug printing to whether a change was made.

I can't think of a reason why else after a return would be considered bad. Will try google on that term.

  • twist code around clang-tidy
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
739

...advises to reduce indentation where possible and where it makes understanding code easier. Early exit is one of the suggested enforcements of that. Please do not use else or else if after something that interrupts control flow

That seems uncompelling in this case, but it's trivial to shuffle the code to avoid the diagnostic. E.g. latest version.

dhruvachak accepted this revision.May 26 2021, 11:28 AM

LGTM. Thanks.

This revision is now accepted and ready to land.May 26 2021, 11:28 AM
This revision was landed with ongoing or failed builds.May 26 2021, 11:58 AM
This revision was automatically updated to reflect the committed changes.