Index: clang/lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -676,6 +676,9 @@ else if (IsThinLTO && IsOSAIX) CmdArgs.push_back(Args.MakeArgString(Twine("-bdbg:thinlto"))); + // Matrix intrinsic lowering happens at link time with ThinLTO. + if (IsThinLTO && Args.hasArg(options::OPT_fenable_matrix)) + CmdArgs.push_back(Args.MakeArgString(Twine(PluginOptPrefix) + "-enable-matrix")); StringRef Parallelism = getLTOParallelism(Args, D); if (!Parallelism.empty()) Index: clang/test/Driver/matrix.c =================================================================== --- /dev/null +++ clang/test/Driver/matrix.c @@ -0,0 +1,8 @@ +// RUN: touch %t.o +// RUN: %clang -flto=thin -fenable-matrix %t.o -### --target=powerpc64-ibm-aix-xcoff 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-THINLTO-MATRIX-AIX +// CHECK-THINLTO-MATRIX-AIX: "-bplugin_opt:-enable-matrix" +// +// RUN: %clang -flto=thin -fenable-matrix %t.o -### --target=x86_64-unknown-linux 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-THINLTO-MATRIX +// CHECK-THINLTO-MATRIX: "-plugin-opt=-enable-matrix"