This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Set fast-math flags on functions given the options
ClosedPublic

Authored by rampitec on Sep 27 2017, 11:37 AM.

Details

Summary

We have a single library build without relaxation options.
When inlined library functions remove fast math attributes
from the functions they are integrated into.

This patch sets relaxation attributes on the functions after
linking provided corresponding relaxation options are given.
Math instructions inside the inlined functions remain to have
no fast flags, but inlining does not prevent fast math
transformations of a surrounding caller code anymore.

Diff Detail

Repository
rL LLVM

Event Timeline

rampitec created this revision.Sep 27 2017, 11:37 AM
dfukalov edited edge metadata.Sep 29 2017, 3:24 PM

otherwise LGTM

lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
375 ↗(On Diff #116851)

It possible would be better to create temporary ref for Options member and capture it instead of whole this pointer

rampitec added inline comments.Sep 29 2017, 3:28 PM
lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
375 ↗(On Diff #116851)

It is just a pointer, not the whole content under it.

rampitec added inline comments.Sep 29 2017, 3:31 PM
lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
375 ↗(On Diff #116851)

I.e. it will be one line of code more:

const auto &Opt = Options;
Builder.addExtension(
  PassManagerBuilder::EP_EarlyAsPossible,
  [AMDGPUAA, LibCallSimplify, &Opt](const PassManagerBuilder &,
                                    legacy::PassManagerBase &PM) {
    if (AMDGPUAA) {
      PM.add(createAMDGPUAAWrapperPass());
      PM.add(createAMDGPUExternalAAWrapperPass());
    }
    PM.add(llvm::createAMDGPUUseNativeCallsPass());
    if (LibCallSimplify)
      PM.add(llvm::createAMDGPUSimplifyLibCallsPass(Opt));
});

but the capture size is still the same sizeof(void*).

rampitec updated this revision to Diff 117239.Sep 29 2017, 3:47 PM
rampitec marked 3 inline comments as done.

Created reference to Options to capture as requested.

dfukalov accepted this revision.Sep 29 2017, 3:51 PM
This revision is now accepted and ready to land.Sep 29 2017, 3:51 PM
This revision was automatically updated to reflect the committed changes.