Page MenuHomePhabricator

[OpenMP] Add support for extracting device code in linker wrapper

Authored by jhuber6 on Jan 3 2022, 10:02 AM.



This patchs add support for extracting device offloading code from the
linker's input files. If the file contains a section starting with the name
.llvm.offloading.<triple>.<arch> it will be extracted to a new
temporary file to be linked. Addtionally, the host file containing it
will have the section stripped so it does not remain in the executable
once linked.

Depends on D116544

Diff Detail

Event Timeline

jhuber6 created this revision.Jan 3 2022, 10:02 AM
jhuber6 requested review of this revision.Jan 3 2022, 10:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 3 2022, 10:02 AM
jhuber6 updated this revision to Diff 404035.Jan 28 2022, 8:16 AM

Changing section embedding after adding filenames previously.

JonChesterfield edited the summary of this revision. (Show Details)Jan 31 2022, 7:16 AM

Can we test this, or is it tested with a follow up commit at least? If so, which one (add to commit message as well, e.g., tests contained in D...).
Some notes, exclusively on the unused do not strip flag. Everything else looks good reading it.

if (!StripSections)
  return static_cast<std::string>(TempFile);

if (!StripSections)

return None;

Does this work with the "do not strip option"? I somehow doubt it and would expect an error.


I know this is not new but I don't understand the warning here.

jhuber6 added inline comments.Jan 31 2022, 9:04 AM

Fixed this later, I could rebase it so it applies here if it makes the review easier.


If we don't strip then we just return None to indicate we didn't create a new host file and this code won't execute.


it was just a stand-in to indicate that the tool was indeed running with the -fopenmp-new-driver flag, but wasn't doing the offload linking step and thus wouldn't execute on the device. It's removed once offloading actually works.

what commit contains the tests?


I see, there is an optional inside an expected.

what commit contains the tests?

The previous four have clang tests, showing that we call this tool with the expected arguments. Testing the tool itself requires running it, so I was thinking I could make a new class of OpenMP tests that run with the new driver similar to how we handled the new runtime transition. Haven't gotten that done yet.

jdoerfert accepted this revision.Jan 31 2022, 6:34 PM

LG, as part of the patch set, and given the runtime test for coverage.

This revision is now accepted and ready to land.Jan 31 2022, 6:34 PM
This revision was landed with ongoing or failed builds.Jan 31 2022, 8:12 PM
This revision was automatically updated to reflect the committed changes.