Skip to content
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

[Driver] Turn off optimization when -g option is passed. #15820

Draft
wants to merge 1 commit into
base: sycl
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5600,8 +5600,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-Wno-sycl-strict");
}

// Set O2 optimization level by default
if (!Args.getLastArg(options::OPT_O_Group))
// '-g' option turns off optimization -O2 and makes -O0 the default.
if (Arg *A = Args.getLastArg(options::OPT_g_Group)) {
if (A->getOption().matches(options::OPT_g_Flag))
CmdArgs.push_back("-O0");
}
// Set O2 optimization level by default if no -g option is passed.
if (!Args.getLastArg(options::OPT_O_Group) && !Args.getLastArg(options::OPT_g_Group))
CmdArgs.push_back("-O2");

// Add the integration header option to generate the header.
Expand Down Expand Up @@ -10806,6 +10811,13 @@ void SPIRVTranslator::ConstructJob(Compilation &C, const JobAction &JA,

// Partially copied from clang/lib/Frontend/CompilerInvocation.cpp
static std::string getSYCLPostLinkOptimizationLevel(const ArgList &Args) {

// '-g' option turns off optimization -O2 and makes -O0 the default.
if(Arg *A = Args.getLastArg(options::OPT_g_Group)) {
if (A->getOption().matches(options::OPT_g_Flag))
return "-O0";
}

if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
// Pass -O2 when the user passes -O0 due to IGC
// debugging limitation. Note this only effects
Expand Down
Loading