Skip to content

Commit

Permalink
Remove the directory condition in path per discussion in #90166
Browse files Browse the repository at this point in the history
  • Loading branch information
kyulee-com committed Sep 12, 2024
1 parent 0710ef4 commit af4b454
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1896,13 +1896,13 @@ def fprofile_selected_function_group :
MarshallingInfoInt<CodeGenOpts<"ProfileSelectedFunctionGroup">>;
def fcodegen_data_generate_EQ : Joined<["-"], "fcodegen-data-generate=">,
Group<f_Group>, Visibility<[ClangOption, CLOption]>, MetaVarName<"<path>">,
HelpText<"Emit codegen data into the object file. LLD for MachO (currently) merges them into a <path> file. If the path is a directory, it writes to <path>/default.cgdata.">;
HelpText<"Emit codegen data into the object file. LLD for MachO (currently) merges them into the specified <path>.">;
def fcodegen_data_generate : Flag<["-"], "fcodegen-data-generate">,
Group<f_Group>, Visibility<[ClangOption, CLOption]>, Alias<fcodegen_data_generate_EQ>,
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<f_Group>, Visibility<[ClangOption, CLOption]>, MetaVarName<"<path>">,
HelpText<"Use codegen data read from a <path> file. If the path is a directory, it reads from <path>/default.cgdata.">;
HelpText<"Use codegen data read from the specified <path>.">;
def fcodegen_data_use : Flag<["-"], "fcodegen-data-use">,
Group<f_Group>, Visibility<[ClangOption, CLOption]>, Alias<fcodegen_data_use_EQ>,
HelpText<"Use codegen data read from default.cgdata to optimize the binary">;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 0 additions & 4 deletions clang/test/Driver/codegen-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit af4b454

Please sign in to comment.