-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CGData] Clang Options #90304
[CGData] Clang Options #90304
Changes from 2 commits
966922b
3a3da69
0710ef4
e7be9e2
dbab3cc
d0a95a6
5df8e44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2753,6 +2753,33 @@ void tools::addMachineOutlinerArgs(const Driver &D, | |
addArg(Twine("-enable-machine-outliner=never")); | ||
} | ||
} | ||
|
||
auto *CodeGenDataGenArg = | ||
Args.getLastArg(options::OPT_fcodegen_data_generate, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion! I now use |
||
options::OPT_fcodegen_data_generate_EQ); | ||
auto *CodeGenDataUseArg = Args.getLastArg(options::OPT_fcodegen_data_use, | ||
options::OPT_fcodegen_data_use_EQ); | ||
|
||
// We only allow one of them to be specified. | ||
if (CodeGenDataGenArg && CodeGenDataUseArg) | ||
D.Diag(diag::err_drv_argument_not_allowed_with) | ||
<< CodeGenDataGenArg->getAsString(Args) | ||
<< CodeGenDataUseArg->getAsString(Args); | ||
|
||
// For codegen data gen, the output file is passed to the linker | ||
// while a boolean flag is passed to the LLVM backend. | ||
if (CodeGenDataGenArg) | ||
addArg(Twine("-codegen-data-generate")); | ||
|
||
// For codegen data use, the input file is passed to the LLVM backend. | ||
if (CodeGenDataUseArg) { | ||
SmallString<128> Path(CodeGenDataUseArg->getNumValues() == 0 | ||
? "" | ||
: CodeGenDataUseArg->getValue()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would replacing this logic with |
||
if (Path.empty() || llvm::sys::fs::is_directory(Path)) | ||
llvm::sys::path::append(Path, "default.cgdata"); | ||
addArg(Twine("-codegen-data-use-path=" + Path.str())); | ||
} | ||
} | ||
|
||
void tools::addOpenMPDeviceRTL(const Driver &D, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Verify only one of codegen-data flag is passed. | ||
// RUN: not %clang -### -S --target=aarch64-linux-gnu -fcodegen-data-generate -fcodegen-data-use %s 2>&1 | FileCheck %s --check-prefix=CONFLICT | ||
// RUN: not %clang -### -S --target=arm64-apple-darwin -fcodegen-data-generate -fcodegen-data-use %s 2>&1 | FileCheck %s --check-prefix=CONFLICT | ||
// CONFLICT: error: invalid argument '-fcodegen-data-generate' not allowed with '-fcodegen-data-use' | ||
|
||
// Verify the codegen-data-generate (boolean) flag is passed to LLVM | ||
// RUN: %clang -### -S --target=aarch64-linux-gnu -fcodegen-data-generate %s 2>&1| FileCheck %s --check-prefix=GENERATE | ||
// RUN: %clang -### -S --target=arm64-apple-darwin -fcodegen-data-generate %s 2>&1| FileCheck %s --check-prefix=GENERATE | ||
// GENERATE: "-mllvm" "-codegen-data-generate" | ||
|
||
// 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. | ||
// RUN: %clang -### -flto --target=aarch64-linux-gnu -fcodegen-data-generate %s 2>&1 | FileCheck %s --check-prefix=GENERATE-LTO | ||
// GENERATE-LTO: {{ld(.exe)?"}} | ||
// GENERATE-LTO-SAME: "-plugin-opt=-codegen-data-generate" | ||
// RUN: %clang -### -flto --target=arm64-apple-darwin -fcodegen-data-generate %s 2>&1 | FileCheck %s --check-prefix=GENERATE-LTO-DARWIN | ||
// GENERATE-LTO-DARWIN: {{ld(.exe)?"}} | ||
// GENERATE-LTO-DARWIN-SAME: "-mllvm" "-codegen-data-generate" | ||
|
||
// Verify the codegen-data-use-path flag with a LTO is passed to LLVM. | ||
// RUN: %clang -### -flto=thin --target=aarch64-linux-gnu -fcodegen-data-use %s 2>&1 | FileCheck %s --check-prefix=USE-LTO | ||
// USE-LTO: {{ld(.exe)?"}} | ||
// USE-LTO-SAME: "-plugin-opt=-codegen-data-use-path=default.cgdata" | ||
// RUN: %clang -### -flto=thin --target=arm64-apple-darwin -fcodegen-data-use %s 2>&1 | FileCheck %s --check-prefix=USE-LTO-DARWIN | ||
// USE-LTO-DARWIN: {{ld(.exe)?"}} | ||
// USE-LTO-DARWIN-SAME: "-mllvm" "-codegen-data-use-path=default.cgdata" | ||
|
||
// For now, LLD MachO supports for generating the codegen data at link time. | ||
// RUN: %clang -### -fuse-ld=lld -B%S/Inputs/lld --target=arm64-apple-darwin -fcodegen-data-generate %s 2>&1 | FileCheck %s --check-prefix=GENERATE-LLD-DARWIN | ||
// GENERATE-LLD-DARWIN: {{ld(.exe)?"}} | ||
// GENERATE-LLD-DARWIN-SAME: "--codegen-data-generate-path=default.cgdata" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the
CC1Option
? I don't see this being used in the frontend.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. It's not needed. Instead, add CLOption similar to the IRPGO flags.