This is an archive of the discontinued LLVM Phabricator instance.

[ThinLTO][Matrix] Forward -enable-matrix flag to the LTO plugin
ClosedPublic

Authored by w2yehia on Jun 22 2023, 12:55 PM.

Details

Summary

Forward -enable-matrix flag to the LTO plugin because matrix intrinsics lowering happens at link time in thinLTO.

Diff Detail

Event Timeline

w2yehia created this revision.Jun 22 2023, 12:55 PM
w2yehia requested review of this revision.Jun 22 2023, 12:55 PM

this was caught when I tried running test-suite with -flto=thin

w2yehia updated this revision to Diff 534557.Jun 26 2023, 7:47 AM

forgot to touch dummy input file.

MaskRay added inline comments.Jun 26 2023, 9:45 AM
clang/test/Driver/clang_f_opts.c
615 ↗(On Diff #534557)

Don't use clang_f_opts.c. Pick a more a specific aix-* test file.

w2yehia added inline comments.Jun 26 2023, 7:51 PM
clang/test/Driver/clang_f_opts.c
615 ↗(On Diff #534557)

Thanks @MaskRay
this is a general change, not specific to AIX. I'm just testing the two plugin-opt/bplugin_opt spellings. Or do you mean to move the AIX specific test to aix-* and keep the generic (I picked x86_64-unknown-linux) one here?

@fhahn ping. Thanks

clang/test/Driver/clang_f_opts.c
615 ↗(On Diff #534557)

@MaskRay ping. Thanks

MaskRay added inline comments.Jul 11 2023, 9:37 AM
clang/test/Driver/clang_f_opts.c
615 ↗(On Diff #534557)

My thought stays the same. We probably should find another test file for enable-matrix.

w2yehia updated this revision to Diff 542203.Jul 19 2023, 2:44 PM
w2yehia retitled this revision from [ThinLTO][Matrix] Forward -enable-matrix flag to the thinLTO plugin to [ThinLTO][Matrix] Forward -enable-matrix flag to the LTO plugin.
w2yehia edited the summary of this revision. (Show Details)

move tests into its own file

@fhahn can you please review when you have a chance. Thanks

MaskRay added inline comments.Jul 21 2023, 10:39 AM
clang/lib/Driver/ToolChains/CommonArgs.cpp
683

With regular LTO, when does it happen?

The canonical spelling for ThinLTO is "ThinLTO".

clang/test/Driver/matrix.c
8

We normally add double quotes for tested options.

w2yehia added inline comments.Jul 31 2023, 8:54 PM
clang/lib/Driver/ToolChains/CommonArgs.cpp
683

The lowering pass is added in buildModuleOptimizationPipeline function:

if (EnableMatrix) {
  OptimizePM.addPass(LowerMatrixIntrinsicsPass());
  OptimizePM.addPass(EarlyCSEPass());
}

Here's the PassBuilder pipelines for thin and full LTO:

thinLTO compile
  buildThinLTOPreLinkDefaultPipeline
thinLTO link:
  buildThinLTODefaultPipeline
    buildModuleOptimizationPipeline

fullLTO compile:
  buildLTOPreLinkDefaultPipeline
    buildPerModuleDefaultPipeline
      buildModuleOptimizationPipeline
fullLTO link:
  buildLTODefaultPipeline
w2yehia updated this revision to Diff 546503.Aug 2 2023, 9:21 AM

address MaskRay's comments

w2yehia marked 2 inline comments as done.Aug 2 2023, 9:22 AM

@MaskRay @fhahn please review when you have time. Thanks

w2yehia updated this revision to Diff 548648.Aug 9 2023, 9:18 AM

clang-format

w2yehia updated this revision to Diff 549038.Aug 10 2023, 7:39 AM
MaskRay accepted this revision.Aug 16 2023, 3:30 PM
MaskRay added inline comments.
clang/lib/Driver/ToolChains/CommonArgs.cpp
683

I see. The comment seems unclear.

// Enable matrix intrinsic lowering (LowerMatrixIntrinsicsPass), which is transitively called by buildThinLTODefaultPipeline.

clang/test/Driver/matrix.c
6

Replace ^//$ with an empty line

This revision is now accepted and ready to land.Aug 16 2023, 3:30 PM
MaskRay added inline comments.Aug 16 2023, 3:34 PM
clang/lib/Driver/ToolChains/CommonArgs.cpp
683

// Matrix intrinsic lowering happens at link time with ThinLTO. Enable LowerMatrixIntrinsicsPass, which is transitively called by buildThinLTODefaultPipeline under EnableMatrix.

w2yehia marked 3 inline comments as done.Aug 31 2023, 8:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2023, 8:19 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript