[clang] 534e23e - [ThinLTO][Matrix] Forward -enable-matrix flag to the LTO plugin

Wael Yehia via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 31 20:18:56 PDT 2023


Author: Wael Yehia
Date: 2023-09-01T03:17:54Z
New Revision: 534e23e47b03292f80a3c8265a88a790f610d3f5

URL: https://github.com/llvm/llvm-project/commit/534e23e47b03292f80a3c8265a88a790f610d3f5
DIFF: https://github.com/llvm/llvm-project/commit/534e23e47b03292f80a3c8265a88a790f610d3f5.diff

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

because matrix intrinsics lowering happens at link time in ThinLTO.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D153583

Added: 
    clang/test/Driver/matrix.c

Modified: 
    clang/lib/Driver/ToolChains/CommonArgs.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index a16469f931884e..1a74a3a1e4cc1d 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -680,6 +680,12 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
   else if (IsThinLTO && IsOSAIX)
     CmdArgs.push_back(Args.MakeArgString(Twine("-bdbg:thinlto")));
 
+  // Matrix intrinsic lowering happens at link time with ThinLTO. Enable
+  // LowerMatrixIntrinsicsPass, which is transitively called by
+  // buildThinLTODefaultPipeline under EnableMatrix.
+  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())

diff  --git a/clang/test/Driver/matrix.c b/clang/test/Driver/matrix.c
new file mode 100644
index 00000000000000..15b44ce5a4ec15
--- /dev/null
+++ b/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"


        


More information about the cfe-commits mailing list