diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index ab7ba65662ff6b..0da7808d817b26 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1896,13 +1896,13 @@ def fprofile_selected_function_group : MarshallingInfoInt>; def fcodegen_data_generate_EQ : Joined<["-"], "fcodegen-data-generate=">, Group, Visibility<[ClangOption, CLOption]>, MetaVarName<"">, - HelpText<"Emit codegen data into the object file. LLD for MachO (currently) merges them into a file. If the path is a directory, it writes to /default.cgdata.">; + HelpText<"Emit codegen data into the object file. LLD for MachO (currently) merges them into the specified .">; def fcodegen_data_generate : Flag<["-"], "fcodegen-data-generate">, Group, Visibility<[ClangOption, CLOption]>, Alias, HelpText<"Emit codegen data into the object file. LLD for MachO (currently) merges them into default.cgdata.">; def fcodegen_data_use_EQ : Joined<["-"], "fcodegen-data-use=">, Group, Visibility<[ClangOption, CLOption]>, MetaVarName<"">, - HelpText<"Use codegen data read from a file. If the path is a directory, it reads from /default.cgdata.">; + HelpText<"Use codegen data read from the specified .">; def fcodegen_data_use : Flag<["-"], "fcodegen-data-use">, Group, Visibility<[ClangOption, CLOption]>, Alias, HelpText<"Use codegen data read from default.cgdata to optimize the binary">; diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 5fa502d64c0300..02239cda59efdc 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -2776,7 +2776,7 @@ void tools::addMachineOutlinerArgs(const Driver &D, SmallString<128> Path(CodeGenDataUseArg->getNumValues() == 0 ? "" : CodeGenDataUseArg->getValue()); - if (Path.empty() || llvm::sys::fs::is_directory(Path)) + if (Path.empty()) llvm::sys::path::append(Path, "default.cgdata"); addArg(Twine("-codegen-data-use-path=" + Path.str())); } diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 9e72e280109640..7bd91614ee1467 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -484,7 +484,7 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args, SmallString<128> Path(CodeGenDataGenArg->getNumValues() == 0 ? "" : CodeGenDataGenArg->getValue()); - if (Path.empty() || llvm::sys::fs::is_directory(Path)) + if (Path.empty()) llvm::sys::path::append(Path, "default.cgdata"); CmdArgs.push_back( Args.MakeArgString(Twine("--codegen-data-generate-path=") + Path)); @@ -672,7 +672,7 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA, SmallString<128> Path(CodeGenDataUseArg->getNumValues() == 0 ? "" : CodeGenDataUseArg->getValue()); - if (Path.empty() || llvm::sys::fs::is_directory(Path)) + if (Path.empty()) llvm::sys::path::append(Path, "default.cgdata"); CmdArgs.push_back("-mllvm"); CmdArgs.push_back( diff --git a/clang/test/Driver/codegen-data.c b/clang/test/Driver/codegen-data.c index a72850afc59736..28638f61d641c5 100644 --- a/clang/test/Driver/codegen-data.c +++ b/clang/test/Driver/codegen-data.c @@ -11,13 +11,9 @@ // Verify the codegen-data-use-path flag (with a default value) is passed to LLVM. // RUN: %clang -### -S --target=aarch64-linux-gnu -fcodegen-data-use %s 2>&1| FileCheck %s --check-prefix=USE // RUN: %clang -### -S --target=arm64-apple-darwin -fcodegen-data-use %s 2>&1| FileCheck %s --check-prefix=USE -// RUN: mkdir -p %t.d/some/dir -// RUN: %clang -### -S --target=aarch64-linux-gnu -fcodegen-data-use=%t.d/some/dir %s 2>&1 | FileCheck %s --check-prefix=USE-DIR -// RUN: %clang -### -S --target=arm64-apple-darwin -fcodegen-data-use=%t.d/some/dir %s 2>&1 | FileCheck %s --check-prefix=USE-DIR // RUN: %clang -### -S --target=aarch64-linux-gnu -fcodegen-data-use=file %s 2>&1 | FileCheck %s --check-prefix=USE-FILE // RUN: %clang -### -S --target=arm64-apple-darwin -fcodegen-data-use=file %s 2>&1 | FileCheck %s --check-prefix=USE-FILE // USE: "-mllvm" "-codegen-data-use-path=default.cgdata" -// USE-DIR: "-mllvm" "-codegen-data-use-path={{.*}}.d/some/dir{{/|\\\\}}default.cgdata" // USE-FILE: "-mllvm" "-codegen-data-use-path=file" // Verify the codegen-data-generate (boolean) flag with a LTO.