This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Adjust phases for AMDGPU offloading for OpenMP in save-temps mode
ClosedPublic

Authored by jhuber6 on Jan 10 2023, 2:53 PM.

Details

Summary

Currently, the behaviour of -save-temps changes the generated output
when offloading to AMDGPU. This is because we only have a single phase
and it contains the -disable-llvm-passes flags which results in
unoptimized bitcode. We need to make sure we generate another phase that
produces both the optimized and unoptimized bitcode. There used to be a
check that turned these phases into a no-op. But I believe it is more
correct to not generate them this way in the first place. Doing this
requires a bit of a hack, replacing an already generated phase action,
but it should be fine.

Diff Detail

Event Timeline

jhuber6 created this revision.Jan 10 2023, 2:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 10 2023, 2:53 PM
jhuber6 requested review of this revision.Jan 10 2023, 2:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 10 2023, 2:53 PM
JonChesterfield accepted this revision.Jan 10 2023, 11:35 PM

If i'm reading this right, the change means we emit the same save-temps files as hip with the same naming convention. That sounds great, makes life easier for backend devs looking at either. I don't know why rdc is a factor - it's not obvious to me that it means anything on amdgpu - but if that's preserving hip's current handling it's fine by me.

Thanks!

clang/lib/Driver/Driver.cpp
4460

Why is rdc involved here?

This revision is now accepted and ready to land.Jan 10 2023, 11:35 PM
jhuber6 added inline comments.Jan 11 2023, 5:17 AM
clang/lib/Driver/Driver.cpp
4460

HIP goes straight through a separate linker phase in non-RDC mode. Setting the type here would prevent that.

jhuber6 updated this revision to Diff 488187.Jan 11 2023, 6:30 AM

I realized that if I fix up how we propagate the ToolChains I can use it in ConstructPhaseAction. Should be cleaner this way.

This revision was landed with ongoing or failed builds.Jan 11 2023, 8:32 AM
This revision was automatically updated to reflect the committed changes.

Getting a build failure on AIX, could you take a look please?

/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/clang/lib/Driver/Driver.cpp:5715:37: error: lambda capture 'C' is not used [-Werror,-Wunused-lambda-capture]
    auto IsHIPRDCInCompilePhase = [&C](const JobAction &JA,

https://lab.llvm.org/buildbot/#/builders/214/builds/5290/steps/5/logs/stdio

Getting a build failure on AIX, could you take a look please?

/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/clang/lib/Driver/Driver.cpp:5715:37: error: lambda capture 'C' is not used [-Werror,-Wunused-lambda-capture]
    auto IsHIPRDCInCompilePhase = [&C](const JobAction &JA,

https://lab.llvm.org/buildbot/#/builders/214/builds/5290/steps/5/logs/stdio

Should be fixed upstream.