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.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
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. |
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.
The comment is not accurate anymore. State what linkages are not internalized. Also say below it returns nullptr if it was not internalized.