Skip to content

Commit

Permalink
Adjust behaviors for diagnostic emission
Browse files Browse the repository at this point in the history
Update option behaviors involved with FP model to allow for more
accurate diagnostics.  Update tests to reflect and update docs for
replacement option for -fsycl-use-bitcode.
  • Loading branch information
mdtoguchi committed Mar 6, 2025
1 parent 47596d1 commit 3f73995
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
27 changes: 13 additions & 14 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3144,17 +3144,18 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
CmdArgs.push_back(A->getValue());
}

auto addSPIRVArgs = [&](StringRef SPIRVArg) {
auto addSPIRVArgs = [&](const Arg *PrecArg) {
if (IsFp32PrecDivSqrtAllowed) {
OptSpecifier Opt(PrecArg->getOption().getID());
if (!FPAccuracy.empty())
EmitAccuracyDiag(D, JA, FPAccuracy, SPIRVArg);
if (SPIRVArg == "-fno-offload-fp32-prec-div")
EmitAccuracyDiag(D, JA, FPAccuracy, PrecArg->getSpelling());
if (Opt == options::OPT_fno_offload_fp32_prec_div)
NoOffloadFP32PrecDiv = true;
else if (SPIRVArg == "-fno-offload-fp32-prec-sqrt")
else if (Opt == options::OPT_fno_offload_fp32_prec_sqrt)
NoOffloadFP32PrecSqrt = true;
else if (SPIRVArg == "-foffload-fp32-prec-sqrt")
else if (Opt == options::OPT_foffload_fp32_prec_sqrt)
NoOffloadFP32PrecSqrt = false;
else if (SPIRVArg == "-foffload-fp32-prec-div")
else if (Opt == options::OPT_foffload_fp32_prec_div)
NoOffloadFP32PrecDiv = false;
}
};
Expand All @@ -3181,17 +3182,15 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
default: continue;

case options::OPT_foffload_fp32_prec_div:
addSPIRVArgs("-foffload-fp32-prec-div");
break;
case options::OPT_foffload_fp32_prec_sqrt:
addSPIRVArgs("-foffload-fp32-prec-sqrt");
break;
case options::OPT_fno_offload_fp32_prec_div:
addSPIRVArgs("-fno-offload-fp32-prec-div");
break;
case options::OPT_fno_offload_fp32_prec_sqrt:
addSPIRVArgs("-fno-offload-fp32-prec-sqrt");
break;
if (IsFp32PrecDivSqrtAllowed) {
addSPIRVArgs(A);
break;
}
// Skip claim, as we didn't use the option.
continue;
case options::OPT_fcx_limited_range:
if (GccRangeComplexOption.empty()) {
if (Range != LangOptions::ComplexRangeKind::CX_Basic)
Expand Down
9 changes: 9 additions & 0 deletions clang/test/Driver/sycl-specific-args-diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@
// RUN: %clang_cl -### -fsycl-force-inline-kernel-lambda %s 2>&1 \
// RUN: | FileCheck -check-prefix=WARNING-UNUSED-ARG -DOPT=-fsycl-force-inline-kernel-lambda %s

// RUN: %clang -### -foffload-fp32-prec-sqrt %s 2>&1 \
// RUN: | FileCheck -check-prefix=WARNING-UNUSED-ARG -DOPT=-foffload-fp32-prec-sqrt %s
// RUN: %clang_cl -### -foffload-fp32-prec-sqrt %s 2>&1 \
// RUN: | FileCheck -check-prefix=WARNING-UNUSED-ARG -DOPT=-foffload-fp32-prec-sqrt %s
// RUN: %clang -### -foffload-fp32-prec-div %s 2>&1 \
// RUN: | FileCheck -check-prefix=WARNING-UNUSED-ARG -DOPT=-foffload-fp32-prec-div %s
// RUN: %clang_cl -### -foffload-fp32-prec-div %s 2>&1 \
// RUN: | FileCheck -check-prefix=WARNING-UNUSED-ARG -DOPT=-foffload-fp32-prec-div %s

// Warning should be emitted when using -fsycl-id-queries-fit-in-int without -fsycl
// RUN: %clang -### -fsycl-id-queries-fit-in-int %s 2>&1 \
// RUN: | FileCheck -check-prefix=WARNING-UNUSED-ARG -DOPT=-fsycl-id-queries-fit-in-int %s
Expand Down
1 change: 1 addition & 0 deletions sycl/doc/UsersManual.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ and not recommended to use in production environment.
Emit SYCL device code in LLVM-IR bitcode format. When disabled, SPIR-V is
emitted.
Enabled by default.
This option is replaced with -fsycl-device-obj=<arg>.

**`-fsycl-device-obj=<arg>`** [EXPERIMENTAL]

Expand Down

0 comments on commit 3f73995

Please sign in to comment.