[PATCH] D121969: Pass split-machine-functions to code generator when flto is used

2022-03-17 Thread Junfeng Dong via Phabricator via cfe-commits
junfd created this revision.
Herald added a subscriber: inglorion.
Herald added a project: All.
junfd requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121969

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/split-machine-functions.c


Index: clang/test/Driver/split-machine-functions.c
===
--- /dev/null
+++ clang/test/Driver/split-machine-functions.c
@@ -0,0 +1,8 @@
+// Test options pass-through with lto
+// RUN: %clang -### -flto -fsplit-machine-functions %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-PASS
+
+// Test no pass-through to ld without lto
+// RUN: %clang -### -fsplit-machine-functions %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-NOPASS
+
+// CHECK-PASS:  "-plugin-opt=-split-machine-functions"
+// CHECK-NOPASS-NOT:"-plugin-opt=-split-machine-functions"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -574,6 +574,10 @@
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
+  if (Args.hasArg(options::OPT_fsplit_machine_functions)) {
+  CmdArgs.push_back("-plugin-opt=-split-machine-functions");
+  }
+
   if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))


Index: clang/test/Driver/split-machine-functions.c
===
--- /dev/null
+++ clang/test/Driver/split-machine-functions.c
@@ -0,0 +1,8 @@
+// Test options pass-through with lto
+// RUN: %clang -### -flto -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+
+// Test no pass-through to ld without lto
+// RUN: %clang -### -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
+
+// CHECK-PASS:  "-plugin-opt=-split-machine-functions"
+// CHECK-NOPASS-NOT:"-plugin-opt=-split-machine-functions"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -574,6 +574,10 @@
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
+  if (Args.hasArg(options::OPT_fsplit_machine_functions)) {
+  CmdArgs.push_back("-plugin-opt=-split-machine-functions");
+  }
+
   if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121969: Pass split-machine-functions to code generator when flto is used

2022-03-17 Thread Junfeng Dong via Phabricator via cfe-commits
junfd updated this revision to Diff 416363.
junfd added a comment.

Follow clang format.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121969/new/

https://reviews.llvm.org/D121969

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/split-machine-functions.c


Index: clang/test/Driver/split-machine-functions.c
===
--- /dev/null
+++ clang/test/Driver/split-machine-functions.c
@@ -0,0 +1,8 @@
+// Test options pass-through with lto
+// RUN: %clang -### -flto -fsplit-machine-functions %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-PASS
+
+// Test no pass-through to ld without lto
+// RUN: %clang -### -fsplit-machine-functions %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-NOPASS
+
+// CHECK-PASS:  "-plugin-opt=-split-machine-functions"
+// CHECK-NOPASS-NOT:"-plugin-opt=-split-machine-functions"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -574,6 +574,10 @@
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
+  if (Args.hasArg(options::OPT_fsplit_machine_functions)) {
+CmdArgs.push_back("-plugin-opt=-split-machine-functions");
+  }
+
   if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))


Index: clang/test/Driver/split-machine-functions.c
===
--- /dev/null
+++ clang/test/Driver/split-machine-functions.c
@@ -0,0 +1,8 @@
+// Test options pass-through with lto
+// RUN: %clang -### -flto -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+
+// Test no pass-through to ld without lto
+// RUN: %clang -### -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
+
+// CHECK-PASS:  "-plugin-opt=-split-machine-functions"
+// CHECK-NOPASS-NOT:"-plugin-opt=-split-machine-functions"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -574,6 +574,10 @@
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
+  if (Args.hasArg(options::OPT_fsplit_machine_functions)) {
+CmdArgs.push_back("-plugin-opt=-split-machine-functions");
+  }
+
   if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121969: Pass split-machine-functions to code generator when flto is used

2022-03-18 Thread Junfeng Dong via Phabricator via cfe-commits
junfd updated this revision to Diff 416555.
junfd added a comment.

Disable test on Windows, because -fsplit-machine-functions only works for ELF.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121969/new/

https://reviews.llvm.org/D121969

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/split-machine-functions.c


Index: clang/test/Driver/split-machine-functions.c
===
--- /dev/null
+++ clang/test/Driver/split-machine-functions.c
@@ -0,0 +1,11 @@
+// Split machine functions only work for ELF, so disable the test on Windows
+// UNSUPPORTED: system-windows
+
+// Test options pass-through with lto
+// RUN: %clang -### -flto -fsplit-machine-functions %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-PASS
+
+// Test no pass-through to ld without lto
+// RUN: %clang -### -fsplit-machine-functions %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-NOPASS
+
+// CHECK-PASS:  "-plugin-opt=-split-machine-functions"
+// CHECK-NOPASS-NOT:"-plugin-opt=-split-machine-functions"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -574,6 +574,10 @@
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
+  if (Args.hasArg(options::OPT_fsplit_machine_functions)) {
+CmdArgs.push_back("-plugin-opt=-split-machine-functions");
+  }
+
   if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))


Index: clang/test/Driver/split-machine-functions.c
===
--- /dev/null
+++ clang/test/Driver/split-machine-functions.c
@@ -0,0 +1,11 @@
+// Split machine functions only work for ELF, so disable the test on Windows
+// UNSUPPORTED: system-windows
+
+// Test options pass-through with lto
+// RUN: %clang -### -flto -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+
+// Test no pass-through to ld without lto
+// RUN: %clang -### -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
+
+// CHECK-PASS:  "-plugin-opt=-split-machine-functions"
+// CHECK-NOPASS-NOT:"-plugin-opt=-split-machine-functions"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -574,6 +574,10 @@
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
+  if (Args.hasArg(options::OPT_fsplit_machine_functions)) {
+CmdArgs.push_back("-plugin-opt=-split-machine-functions");
+  }
+
   if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121969: Pass split-machine-functions to code generator when flto is used

2022-03-21 Thread Junfeng Dong via Phabricator via cfe-commits
junfd updated this revision to Diff 417146.
junfd added a comment.

Refine the test case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121969/new/

https://reviews.llvm.org/D121969

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/fsplit-machine-functions2.c


Index: clang/test/Driver/fsplit-machine-functions2.c
===
--- /dev/null
+++ clang/test/Driver/fsplit-machine-functions2.c
@@ -0,0 +1,8 @@
+// Test -fsplit-machine-functions option pass-through with lto
+// RUN: %clang -### -target x86_64-unknown-linux -flto 
-fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+
+// Test no pass-through to ld without lto
+// RUN: %clang -### -target x86_64-unknown-linux -fsplit-machine-functions %s 
2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
+
+// CHECK-PASS:  "-plugin-opt=-split-machine-functions"
+// CHECK-NOPASS-NOT:"-plugin-opt=-split-machine-functions"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -574,6 +574,10 @@
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
+  if (Args.hasArg(options::OPT_fsplit_machine_functions)) {
+CmdArgs.push_back("-plugin-opt=-split-machine-functions");
+  }
+
   if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))


Index: clang/test/Driver/fsplit-machine-functions2.c
===
--- /dev/null
+++ clang/test/Driver/fsplit-machine-functions2.c
@@ -0,0 +1,8 @@
+// Test -fsplit-machine-functions option pass-through with lto
+// RUN: %clang -### -target x86_64-unknown-linux -flto -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+
+// Test no pass-through to ld without lto
+// RUN: %clang -### -target x86_64-unknown-linux -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
+
+// CHECK-PASS:  "-plugin-opt=-split-machine-functions"
+// CHECK-NOPASS-NOT:"-plugin-opt=-split-machine-functions"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -574,6 +574,10 @@
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
+  if (Args.hasArg(options::OPT_fsplit_machine_functions)) {
+CmdArgs.push_back("-plugin-opt=-split-machine-functions");
+  }
+
   if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121969: Pass split-machine-functions to code generator when flto is used

2022-03-22 Thread Junfeng Dong via Phabricator via cfe-commits
junfd updated this revision to Diff 417387.
junfd added a comment.

Check the mixing -fsplit-machine-functions and -fno-split-machine-functions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121969/new/

https://reviews.llvm.org/D121969

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/fsplit-machine-functions2.c


Index: clang/test/Driver/fsplit-machine-functions2.c
===
--- /dev/null
+++ clang/test/Driver/fsplit-machine-functions2.c
@@ -0,0 +1,12 @@
+// Test -fsplit-machine-functions option pass-through with lto
+// RUN: %clang -### -target x86_64-unknown-linux -flto 
-fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+
+// Test no pass-through to ld without lto
+// RUN: %clang -### -target x86_64-unknown-linux -fsplit-machine-functions %s 
2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
+
+// Test the mix of -fsplit-machine-functions and -fno-split-machine-functions
+// RUN: %clang -### -target x86_64-unknown-linux -flto 
-fsplit-machine-functions -fno-split-machine-functions %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-NOPASS
+// RUN: %clang -### -target x86_64-unknown-linux -flto 
-fno-split-machine-functions -fsplit-machine-functions %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-PASS
+
+// CHECK-PASS:  "-plugin-opt=-split-machine-functions"
+// CHECK-NOPASS-NOT:"-plugin-opt=-split-machine-functions"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -574,6 +574,13 @@
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
+  // Pass an option to enable split machine functions.
+  if (auto *A = Args.getLastArg (options::OPT_fsplit_machine_functions,
+options::OPT_fno_split_machine_functions)) {
+if (A->getOption().matches(options::OPT_fsplit_machine_functions))
+  CmdArgs.push_back("-plugin-opt=-split-machine-functions");
+  }
+
   if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))


Index: clang/test/Driver/fsplit-machine-functions2.c
===
--- /dev/null
+++ clang/test/Driver/fsplit-machine-functions2.c
@@ -0,0 +1,12 @@
+// Test -fsplit-machine-functions option pass-through with lto
+// RUN: %clang -### -target x86_64-unknown-linux -flto -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+
+// Test no pass-through to ld without lto
+// RUN: %clang -### -target x86_64-unknown-linux -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
+
+// Test the mix of -fsplit-machine-functions and -fno-split-machine-functions
+// RUN: %clang -### -target x86_64-unknown-linux -flto -fsplit-machine-functions -fno-split-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
+// RUN: %clang -### -target x86_64-unknown-linux -flto -fno-split-machine-functions -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+
+// CHECK-PASS:  "-plugin-opt=-split-machine-functions"
+// CHECK-NOPASS-NOT:"-plugin-opt=-split-machine-functions"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -574,6 +574,13 @@
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
+  // Pass an option to enable split machine functions.
+  if (auto *A = Args.getLastArg (options::OPT_fsplit_machine_functions,
+options::OPT_fno_split_machine_functions)) {
+if (A->getOption().matches(options::OPT_fsplit_machine_functions))
+  CmdArgs.push_back("-plugin-opt=-split-machine-functions");
+  }
+
   if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121969: Pass split-machine-functions to code generator when flto is used

2022-03-22 Thread Junfeng Dong via Phabricator via cfe-commits
junfd updated this revision to Diff 417458.
junfd added a comment.

Apply clang format.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121969/new/

https://reviews.llvm.org/D121969

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/fsplit-machine-functions2.c


Index: clang/test/Driver/fsplit-machine-functions2.c
===
--- /dev/null
+++ clang/test/Driver/fsplit-machine-functions2.c
@@ -0,0 +1,12 @@
+// Test -fsplit-machine-functions option pass-through with lto
+// RUN: %clang -### -target x86_64-unknown-linux -flto 
-fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+
+// Test no pass-through to ld without lto
+// RUN: %clang -### -target x86_64-unknown-linux -fsplit-machine-functions %s 
2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
+
+// Test the mix of -fsplit-machine-functions and -fno-split-machine-functions
+// RUN: %clang -### -target x86_64-unknown-linux -flto 
-fsplit-machine-functions -fno-split-machine-functions %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-NOPASS
+// RUN: %clang -### -target x86_64-unknown-linux -flto 
-fno-split-machine-functions -fsplit-machine-functions %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-PASS
+
+// CHECK-PASS:  "-plugin-opt=-split-machine-functions"
+// CHECK-NOPASS-NOT:"-plugin-opt=-split-machine-functions"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -574,6 +574,13 @@
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
+  // Pass an option to enable split machine functions.
+  if (auto *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
+options::OPT_fno_split_machine_functions)) {
+if (A->getOption().matches(options::OPT_fsplit_machine_functions))
+  CmdArgs.push_back("-plugin-opt=-split-machine-functions");
+  }
+
   if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))


Index: clang/test/Driver/fsplit-machine-functions2.c
===
--- /dev/null
+++ clang/test/Driver/fsplit-machine-functions2.c
@@ -0,0 +1,12 @@
+// Test -fsplit-machine-functions option pass-through with lto
+// RUN: %clang -### -target x86_64-unknown-linux -flto -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+
+// Test no pass-through to ld without lto
+// RUN: %clang -### -target x86_64-unknown-linux -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
+
+// Test the mix of -fsplit-machine-functions and -fno-split-machine-functions
+// RUN: %clang -### -target x86_64-unknown-linux -flto -fsplit-machine-functions -fno-split-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
+// RUN: %clang -### -target x86_64-unknown-linux -flto -fno-split-machine-functions -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+
+// CHECK-PASS:  "-plugin-opt=-split-machine-functions"
+// CHECK-NOPASS-NOT:"-plugin-opt=-split-machine-functions"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -574,6 +574,13 @@
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
+  // Pass an option to enable split machine functions.
+  if (auto *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
+options::OPT_fno_split_machine_functions)) {
+if (A->getOption().matches(options::OPT_fsplit_machine_functions))
+  CmdArgs.push_back("-plugin-opt=-split-machine-functions");
+  }
+
   if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits