Skip to content

Commit 92121c9

Browse files
[SYCL][Driver] Revert -O0 as the default SYCL device optimization if -g is passed. (#17987)
Reverts #16408
1 parent 06290b2 commit 92121c9

File tree

4 files changed

+6
-62
lines changed

4 files changed

+6
-62
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

+4-40
Original file line numberDiff line numberDiff line change
@@ -5757,27 +5757,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
57575757
CmdArgs.push_back("-Wno-sycl-strict");
57585758
}
57595759

5760-
// If no optimization controlling flags (-O) are provided, check if
5761-
// any debug information flags(-g) are passed.
5762-
// "-fintelfpga" implies "-g" and we preserve the default optimization for
5763-
// this flow(-O2).
5764-
// if "-g" is explicitly passed from the command-line, set default
5765-
// optimization to -O0.
5766-
5767-
if (!Args.hasArgNoClaim(options::OPT_O_Group, options::OPT__SLASH_O)) {
5768-
StringRef OptLevel = "-O2";
5769-
const Arg *DebugInfoGroup = Args.getLastArg(options::OPT_g_Group);
5770-
// -fintelfpga -g case
5771-
if ((Args.hasArg(options::OPT_fintelfpga) &&
5772-
Args.hasMultipleArgs(options::OPT_g_Group)) ||
5773-
/* -fsycl -g case */ (!Args.hasArg(options::OPT_fintelfpga) &&
5774-
DebugInfoGroup)) {
5775-
if (!DebugInfoGroup->getOption().matches(options::OPT_g0)) {
5776-
OptLevel = "-O0";
5777-
}
5778-
}
5779-
CmdArgs.push_back(OptLevel.data());
5780-
}
5760+
// Set O2 optimization level by default
5761+
if (!Args.getLastArg(options::OPT_O_Group))
5762+
CmdArgs.push_back("-O2");
57815763

57825764
// Add the integration header option to generate the header.
57835765
StringRef Header(D.getIntegrationHeader(Input.getBaseInput()));
@@ -11083,25 +11065,7 @@ static std::string getSYCLPostLinkOptimizationLevel(const ArgList &Args) {
1108311065
[=](char c) { return c == S[0]; }))
1108411066
return std::string("-O") + S[0];
1108511067
}
11086-
// If no optimization controlling flags (-O) are provided, check if
11087-
// any debug information flags(-g) are passed.
11088-
// "-fintelfpga" implies "-g" and we preserve the default optimization for
11089-
// this flow(-O2).
11090-
// if "-g" is explicitly passed from the command-line, set default
11091-
// optimization to -O0.
11092-
11093-
if (!Args.hasArg(options::OPT_O_Group)) {
11094-
const Arg *DebugInfoGroup = Args.getLastArg(options::OPT_g_Group);
11095-
// -fintelfpga -g case
11096-
if ((Args.hasArg(options::OPT_fintelfpga) &&
11097-
Args.hasMultipleArgs(options::OPT_g_Group)) ||
11098-
/* -fsycl -g case */
11099-
(!Args.hasArg(options::OPT_fintelfpga) && DebugInfoGroup)) {
11100-
if (!DebugInfoGroup->getOption().matches(options::OPT_g0)) {
11101-
return "-O0";
11102-
}
11103-
}
11104-
}
11068+
1110511069
// The default for SYCL device code optimization
1110611070
return "-O2";
1110711071
}

clang/test/Driver/sycl-device-optimizations.cpp

-20
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,4 @@
4646
// RUN: | FileCheck -check-prefix=CHECK-NO-THRESH %s
4747
// CHECK-NO-THRESH-NOT: "-mllvm" "-inline-threshold
4848

49-
/// Check that optimizations for sycl device are disabled with -g passed:
50-
// RUN: %clang -### -fsycl -g %s 2>&1 \
51-
// RUN: | FileCheck -check-prefix=CHECK-DEBUG %s
52-
// RUN: %clang_cl -### -fsycl -g %s 2>&1 \
53-
// RUN: | FileCheck -check-prefix=CHECK-DEBUG %s
54-
// CHECK-DEBUG: clang{{.*}} "-fsycl-is-device{{.*}}" "-O0"
55-
// CHECK-DEBUG: sycl-post-link{{.*}} "-O0"
56-
// CHECK-DEBUG-NOT: "-O2"
5749

58-
/// Check that optimizations for sycl device are enabled with -g and O2 passed:
59-
// RUN: %clang -### -fsycl -O2 -g %s 2>&1 \
60-
// RUN: | FileCheck -check-prefix=CHECK-G-O2 %s
61-
// For clang_cl, -O2 maps to -O3
62-
// RUN: %clang_cl -### -fsycl -O2 -g %s 2>&1 \
63-
// RUN: | FileCheck -check-prefix=CHECK-G-O3 %s
64-
// CHECK-G-O2: clang{{.*}} "-fsycl-is-device{{.*}}" "-O2"
65-
// CHECK-G-O2: sycl-post-link{{.*}} "-O2"
66-
// CHECK-G-O2-NOT: "-O0"
67-
// CHECK-G-O3: clang{{.*}} "-fsycl-is-device{{.*}}" "-O3"
68-
// CHECK-G-O3: sycl-post-link{{.*}} "-O3"
69-
// CHECK-G-O3-NOT: "-O0"

sycl/test-e2e/InvokeSimd/Regression/ImplicitSubgroup/debug_symbols.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Check that full compilation works:
2-
// RUN: %clangxx -DIMPL_SUBGROUP -fsycl -fno-sycl-device-code-split-esimd -Xclang -fsycl-allow-func-ptr -g -O2 %S/../debug_symbols.cpp -o %t.out
2+
// RUN: %clangxx -DIMPL_SUBGROUP -fsycl -fno-sycl-device-code-split-esimd -Xclang -fsycl-allow-func-ptr -g %S/../debug_symbols.cpp -o %t.out
33
// RUN: env IGC_VCSaveStackCallLinkage=1 IGC_VCDirectCallsOnly=1 %{run} %t.out
44
//
55
// VISALTO enable run

sycl/test-e2e/InvokeSimd/Regression/debug_symbols.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Check that full compilation works:
2-
// RUN: %{build} -fno-sycl-device-code-split-esimd -Xclang -fsycl-allow-func-ptr -g -O2 -o %t.out
2+
// RUN: %{build} -fno-sycl-device-code-split-esimd -Xclang -fsycl-allow-func-ptr -g -o %t.out
33
// RUN: env IGC_VCSaveStackCallLinkage=1 IGC_VCDirectCallsOnly=1 %{run} %t.out
44
//
55
// VISALTO enable run

0 commit comments

Comments
 (0)