This is an archive of the discontinued LLVM Phabricator instance.

[libomptarget] Initialize reference parameter IsNew within Device::getOrAllocTgtPtr
ClosedPublic

Authored by ronlieb on Apr 23 2020, 12:07 PM.

Details

Summary
The two locals IsNew and Pointer_IsNew were uninitialized at declaration, and then passed by
reference to Device.getOrAllocTgtPtr which in turn did not assign on all
paths within the function. This resulted in occasional runtime failures in one application.
 Device::getOrAllocTgtPtr will now initialize IsNew to false on entry to function.

Diff Detail

Event Timeline

ronlieb created this revision.Apr 23 2020, 12:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2020, 12:07 PM

I think it would look better if we initialized those variables inside Device::getOrAllocTgtPtr - the caller should not assume any default value. That's also what happens in target_data_end with the IsLast variable, it is initialized inside Device::getTgtPtrBegin.

ronlieb updated this revision to Diff 259858.Apr 24 2020, 4:30 AM
ronlieb retitled this revision from [libomptarget] Initialize IsNew and Pointer_IsNew in target_data_begin to [libomptarget] Initialize reference parameter IsNew within Device::getOrAllocTgtPtr.
ronlieb edited the summary of this revision. (Show Details)

Modified patch to assign to IsNew on entry to Device::getOrAllocTgtPtr

grokos accepted this revision.Apr 24 2020, 12:50 PM

LGTM.

This revision is now accepted and ready to land.Apr 24 2020, 12:50 PM
This revision was automatically updated to reflect the committed changes.