diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/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)) diff --git a/clang/test/Driver/split-machine-functions.c b/clang/test/Driver/split-machine-functions.c new file mode 100644 --- /dev/null +++ b/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"