This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][OMPIRBuilder] Migrate createOffloadEntriesAndInfoMetadata from clang to OpenMPIRBuilder
ClosedPublic

Authored by jsjodin on Oct 27 2022, 9:05 AM.

Details

Summary

This patch moves the createOffloadEntriesAndInfoMetadata to OpenMPIRBuilder,
the createOffloadEntry helper function. The clang specific error handling is
invoked using a callback. This code will also be used by flang in the future.

Diff Detail

Event Timeline

jsjodin created this revision.Oct 27 2022, 9:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2022, 9:05 AM
jsjodin requested review of this revision.Oct 27 2022, 9:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2022, 9:05 AM
jsjodin updated this revision to Diff 471232.Oct 27 2022, 11:09 AM

Change forward declaration to struct

I think the pure code move looks good. My comments below are more concerned with cleanup/clarification we could do while we are here.

llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
27

It's a struct, according to the pre-commit buildbot error.

1101

IsGPU is not great. If anything, let's call it "IsTargetCodegen" or similar. Also elsewhere. As this clashes with the special handling of "host offloading", I would suggest to then rename IsDevice to IsEmbedded or something. This should work for non-GPUs and also the "IsDevice" flag is misnamed as the host offloading is also targeting a device.

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
4734

Why do we call it in SIMD mode in the first place?
The Module should be available to the IRBuilder.

jsjodin added inline comments.Oct 27 2022, 12:31 PM
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
1101

IsGPU is not great. If anything, let's call it "IsTargetCodegen" or similar. Also elsewhere. As this clashes with the special handling of "host offloading", I would suggest to then rename IsDevice to IsEmbedded or something. This should work for non-GPUs and also the "IsDevice" flag is misnamed as the host offloading is also targeting a device.

Yes, I was a bit confused about the naming, so I opted to use the names that the clang options indicate. I will make the changes you suggested and hopefully that will be cleaner.

jsjodin updated this revision to Diff 472322.Nov 1 2022, 9:05 AM

Code cleanup, rename parameters.

This revision is now accepted and ready to land.Nov 1 2022, 9:55 AM
jsjodin updated this revision to Diff 472752.Nov 2 2022, 2:01 PM

Use std::function instead of function_ref.

jsjodin closed this revision.Nov 8 2022, 11:05 AM