This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Internalize functions in OpenMPOpt to improve IPO passes
ClosedPublic

Authored by jhuber6 on May 19 2021, 8:05 PM.

Details

Summary

Currently the attributor needs to give up if a function has external linkage.
This means that the optimization introduced in D97818 will only apply to static
functions. This change uses the Attributor to internalize OpenMP device
routines by making a copy of each function with private linkage and replacing
the uses in the module with it. This allows for the optimization to be applied
to any regular function.

Diff Detail

Event Timeline

jhuber6 created this revision.May 19 2021, 8:05 PM
jhuber6 requested review of this revision.May 19 2021, 8:05 PM
Herald added a reviewer: baziotis. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
jdoerfert accepted this revision.May 19 2021, 8:10 PM

LGTM, two minor nits.

llvm/include/llvm/Transforms/IPO/Attributor.h
1676

The comment is not accurate anymore. State what linkages are not internalized. Also say below it returns nullptr if it was not internalized.

llvm/lib/Transforms/IPO/OpenMPOpt.cpp
2628

I guess we can put the internalized version in the SCC if there was one and otherwise the original function. That way we already ignore what we probably delete later anyway.

This revision is now accepted and ready to land.May 19 2021, 8:10 PM
jhuber6 updated this revision to Diff 347099.May 21 2021, 12:15 PM

Fixing a bug where an internalized function could have multiple metadata nodes attached. Adding a flag to Attributor to prevent function signature rewrites preventing the __kmpc_alloc_shared calls from being found in OpenMPOpt. Adding methods to only run OpenMPOpt Module pass on the internalized versions of functions if one exists.

This revision was landed with ongoing or failed builds.Jun 22 2021, 9:38 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2021, 9:38 AM