This is an archive of the discontinued LLVM Phabricator instance.

[libomptarget][amdgpu] Remove majority of fatal errors
ClosedPublic

Authored by JonChesterfield on May 12 2021, 11:39 AM.

Details

Summary

[libomptarget][amdgpu] Remove majority of fatal errors

Replaces most calls to exit() with returning an error to the library entry
point. Minor changes to error handling for clear bugs, remove some dead code.

Each exit() call site replaced is either in a library entry point or a
function that already returns error codes on some paths. The existing handling
is not well tested but replacing exit() with a fallback path should be a strict
improvement.

Remaining two early exit points are an abort() from a callback and exit() from
within msgpack. Fixes for those are less obvious and left for a later patch.

Diff Detail

Event Timeline

JonChesterfield requested review of this revision.May 12 2021, 11:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2021, 11:39 AM

This replaces some debug printing with DP() macro where it is near exit calls, leaving other (f)printf calls for a later patch.

openmp/libomptarget/plugins/amdgpu/impl/data.cpp
23

in internal.h

62

register_allocation doesn't look like it handles invalid pointers gracefully, keeping it guarded by allocate succeeding

openmp/libomptarget/plugins/amdgpu/impl/internal.h
51

was unused

openmp/libomptarget/plugins/amdgpu/impl/system.cpp
368

redundant checks

1046

branch was always true

openmp/libomptarget/plugins/amdgpu/impl/utils.cpp
102

this exit was reasonable in atmi, not so in libomptarget

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

previously, this is a nullptr dereference on partial construction of the global

pdhaliwal accepted this revision.May 17 2021, 1:07 AM

Looks good with one minor NIT.

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

should check for return status here.

This revision is now accepted and ready to land.May 17 2021, 1:07 AM
pdhaliwal added inline comments.May 20 2021, 4:26 AM
openmp/libomptarget/plugins/amdgpu/impl/system.cpp
1036

char *name is leaking on these exits.

  • Check error code from allow_access, fold destroy into destructor
  • fix copy error
pdhaliwal accepted this revision.May 20 2021, 7:58 AM
This revision was landed with ongoing or failed builds.May 20 2021, 8:27 AM
This revision was automatically updated to reflect the committed changes.