[SYCL] Add -Wno-sycl-undefined-func-in-image to silence spurious undefined-function warnings - #23012
[SYCL] Add -Wno-sycl-undefined-func-in-image to silence spurious undefined-function warnings#23012bviyer wants to merge 13 commits into
Conversation
srividya-sundaram
left a comment
There was a problem hiding this comment.
Clang Driver changes LGTM. Thanks!
There was a problem hiding this comment.
I'd prefer to avoid duplicating code or stating the evident in comments.
| // Set indirectly by clang's -Wno-sycl-undefined-func-in-image |
There was a problem hiding this comment.
I think auto-apply just messed things up... :(
There was a problem hiding this comment.
let's avoid implementation details in the option description, even internal. We may change what we pass from driver, that should not invalidate this internal option.
| "in a device image")); |
There was a problem hiding this comment.
same here - code now looks incorrect.
Co-authored-by: Yury Plyakhin <yury.plyakhin@intel.com>
Co-authored-by: Yury Plyakhin <yury.plyakhin@intel.com>
Co-authored-by: Yury Plyakhin <yury.plyakhin@intel.com>
There was a problem hiding this comment.
This is the only cl::opt in all of llvm/lib/SYCLPostLink/. The library is intentionally option-free because it's linked into three consumers with different option front-ends: the sycl-post-link tool, clang-linker-wrapper, and sycl-jit. All configuration is passed via PostLinkSettings / ModuleSplitterSettings.
In current implementation, the new flag a silent no-op on the library path. With --offload-new-driver -no-use-sycl-post-link-tool, clang-linker-wrapper runs sycl_post_link::performPostLinkProcessing in-process (ClangLinkerWrapper.cpp:872) using settings built from an ArgList in getSYCLPostLinkSettings (line 645);
--sycl-post-link-options= values are only forwarded to the tool (line 807).
So, in case of library usage the user passes -Wno-..., and still sees the warning.
Please follow the existing pattern instead:
cl::opt<bool> SuppressUndefinedFuncWarningsinllvm/tools/sycl-post-link/sycl-post-link.cpp, next toAllowDeviceImageDependencies.- New field in
ModuleSplitterSettings(andPostLinkSettingsso it survives the pipeline). - Pass it as a parameter to
checkForCallsToUndefinedFunctions/extractCallGraph, exactly likeAllowDeviceImageDependencies. - Set it in
getSYCLPostLinkSettingsfrom the linker-wrapper's arg list, so the new-offload library path honours it too.
| @@ -0,0 +1,58 @@ | |||
| /// Verify that -W[no-]sycl-undefined-func-in-image is forwarded correctly to | |||
There was a problem hiding this comment.
All RUN lines exercise only the legacy offload path. Please add --offload-new-driver test, where the option is serialized differently:
// RUN: %clang -### -fsycl --offload-new-driver -fsycl-targets=spir64 -Wno-sycl-undefined-func-in-image %s 2>&1 \
// RUN: | FileCheck --check-prefix=WNO-NEW %s
// WNO-NEW: clang-linker-wrapper{{.*}} "--sycl-post-link-options=-suppress-undefined-func-warnings"
and a matching negative case.
| /// sycl-post-link under both the default clang driver and the clang-cl | ||
| /// driver. The clang-cl coverage exists because the underlying Options.td | ||
| /// defs need Visibility<[ClangOption, CLOption]> for the driver's | ||
| /// getLastArg(OPT_Wsycl_..., OPT_Wno_sycl_...) to see the arg under |
There was a problem hiding this comment.
This is stale after the switch to hasFlag. If possible, could you update the comment with focusing on behavior and avoiding implementation details. Otherwise, the comment might stale again in the future.
Same for other comments in this code, where makes sense.
| @@ -11506,6 +11492,16 @@ static void getNonTripleBasedSYCLPostLinkOpts(const ToolChain &TC, | |||
| if (allowDeviceImageDependencies(TCArgs)) | |||
| addArgs(PostLinkArgs, TCArgs, {"-allow-device-image-dependencies"}); | |||
|
|
|||
| // Forward -Wno-sycl-undefined-func-in-image to sycl-post-link. Users pass | |||
| // this to silence sycl-post-link's "Undefined function ... found in ..." | |||
| // warning for device-code symbols resolved by the driver/JIT (e.g. Intel | |||
There was a problem hiding this comment.
Here and in the rest of the code/comments/docs changed in this PR:
An unqualified "driver" may be read as the clang driver, but here it means the GPU driver.
Please disambiguate: ... for device-code symbols resolved by the GPU runtime or JIT.
There was a problem hiding this comment.
Appending [-Wsycl-undefined-func-in-image] signals full clang warning semantics, but only the two literal spellings are honoured. -w, -Wno-everything, and -Werror=sycl-undefined-func-in-image all parse cleanly and have no effect.
Maybe we need to be more explicit here: Use -Wno-sycl-undefined-func-in-image to suppress the warning.
There was a problem hiding this comment.
This takes the test from 2 to 5 full -fsycl -fsycl-link compiles of <sycl/sycl.hpp>.
I suggest keeping the one that adds real end-to-end value (-Wno-... actually suppresses the warning)
Can we drop CHECK-WARNING-REENABLED / CHECK-WARNING-LAST-WNO?
last --W-wins is driver argument handling, already covered by LAST-W/LAST-WNO in clang/test/Driver/sycl-suppress-undefined-func-warnings.cpp.
| /// getLastArg(OPT_Wsycl_..., OPT_Wno_sycl_...) to see the arg under | ||
| /// --driver-mode=cl. | ||
|
|
||
| // RUN: %clang -### -fsycl -fsycl-targets=spir64 %s 2>&1 \ |
There was a problem hiding this comment.
%clang and %clangxx are redundant for -### forwarding checks since -fsycl implies C++, right?
%clangxx + %clang_cl should be sufficient.
KseniyaTikhomirova
left a comment
There was a problem hiding this comment.
SYCL RT part LGTM
Silences sycl-post-link's "Undefined function found in
" warning. Intended for symbols resolved by the GPU driver / JIT. Adds the SyclUndefinedFuncInImage DiagGroup; the driver forwards suppress-undefined-func-warnings to sycl-post-link.