This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Fix using LTO with the new driver in RDC-mode
ClosedPublic

Authored by jhuber6 on Oct 5 2022, 12:38 PM.

Details

Summary

The new driver supports LTO for RDC-mode compilations. However, this was
not correctly handled for non-LTO compilations. HIP can handle this as
it is fed to lld which will perform the LTO itself. CUDA however would
require every work which is wholly useless in non-RDC mode so it should
report an error.

Diff Detail

Event Timeline

jhuber6 created this revision.Oct 5 2022, 12:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 5 2022, 12:38 PM
Herald added a subscriber: inglorion. · View Herald Transcript
jhuber6 requested review of this revision.Oct 5 2022, 12:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 5 2022, 12:38 PM
yaxunl added a comment.Oct 5 2022, 3:00 PM

should we test with -ccc-print-phases instead? It is not clear what actions are produced by driver.

should we test with -ccc-print-phases instead? It is not clear what actions are produced by driver.

Of the four run lines added, three use -ccc-print-phases. The last uses just -### because otherwise the error message would not be triggered as it would quit before trying to generate the Clang job.

should we test with -ccc-print-phases instead? It is not clear what actions are produced by driver.

Ah, realized you meant with phases. This is good enough for NVPTX as there is no explicit assembler phase. LTO makes no difference for AMDGPU as it already outputs bitcode.

yaxunl added a comment.Oct 5 2022, 3:17 PM

should we test with -ccc-print-phases instead? It is not clear what actions are produced by driver.

Ah, realized you meant with phases. This is good enough for NVPTX as there is no explicit assembler phase. LTO makes no difference for AMDGPU as it already outputs bitcode.

It is not clear whether the driver respects -foffload-lto when -fno-gpu-rdc is specified. -ccc-print-phases shows whether the driver generates bc or object. -ccc-print-bindings does not because it does not show the file types.

should we test with -ccc-print-phases instead? It is not clear what actions are produced by driver.

Ah, realized you meant with phases. This is good enough for NVPTX as there is no explicit assembler phase. LTO makes no difference for AMDGPU as it already outputs bitcode.

It is not clear whether the driver respects -foffload-lto when -fno-gpu-rdc is specified. -ccc-print-phases shows whether the driver generates bc or object. -ccc-print-bindings does not because it does not show the file types.

There's an existing test in the OpenMP toolchain that uses phases I believe, using bindings was just easier for making the tests. If you think it's worth changing then I'll do it, but it was just easier this way.

jhuber6 updated this revision to Diff 465584.Oct 5 2022, 3:48 PM

Changing two tests to use phases instead to illustrate the lto-bc usage.

yaxunl added inline comments.Oct 5 2022, 5:09 PM
clang/test/Driver/hip-phases.hip
553

do we need a test for -foffload-lto -fno-gpu-rdc ?

jhuber6 added inline comments.Oct 5 2022, 5:37 PM
clang/test/Driver/hip-phases.hip
553

The test above still uses the bindings, all the matters for that one is that the jobs generated are legal and still the same.

yaxunl accepted this revision.Oct 6 2022, 7:29 AM

LGTM. Thanks.

This revision is now accepted and ready to land.Oct 6 2022, 7:29 AM
This revision was automatically updated to reflect the committed changes.