-
Notifications
You must be signed in to change notification settings - Fork 772
[SYCL][NFC] Use -fsyntax-only more extensively in LIT tests #8144
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
[SYCL][NFC] Use -fsyntax-only more extensively in LIT tests #8144
Conversation
Adjusted LIT tests to use syntax-only mode for some tests which perform full compilation and linking or only compilation (`-c`) to speed up those tests. Also removed `-o` option from some existing `-fsyntax-only` mode to shorten `RUN` lines, because it is anyway ignored by the compiler.
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.
FYI: sometimes, the intention can be to test compiler's IR generation as well.
I don't know if any of the tests you updated requires this.
Yes, I'm aware of such tests and haven't touched any of them in this PR. |
Okay, did you look at extensions/macro_cuda.cpp failure? |
I think I made a mistake by moving macro check above UPD: should be fixed by 58e43ed |
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.
One issue I see with this approach is inability to verify all explicit instantiations are in place. Missing ones manifest themselves at link time only with undefined symbols.
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note -DSYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL %s -o %t.out | ||
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note -D__SYCL_INTERNAL_API -DSYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL %s -o %t.out | ||
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note -DSYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL %s | ||
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note -D__SYCL_INTERNAL_API -DSYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL %s |
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.
Not related to this particular file, it's just when I realized it... What if a mistake is done inside the pi.def
-related mapping and some symbol/offset is missing, would -fsyntax-only
catch that?
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.
If I understand correctly, it is likely that SYCL RT (or unit-tests) won't be built at all.
For example, if you add something new into pi.def
, but not anywhere else, then the following piece of code will try to reference non-existing function:
llvm/sycl/include/sycl/detail/pi.h
Lines 1982 to 1985 in e833806
struct FunctionPointers { | |
#define _PI_API(api) decltype(::api) *api; | |
#include <sycl/detail/pi.def> | |
} PiFunctionTable; |
} |
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.
I'm surprised to see dynamic asserts
in this test (lines 56/57). Unrelated to this PR though.
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.
The test was added like this in #4458. We should probably be more careful when reviewing tests and perhaps we should do another round of tests review to refactor them, i.e.:
- move to llvm-test-suite anything which requires actual devices
- and/or rewrite that to unit-tests
- remove runtime checks from
-fsyntax-only
tests to simplify and cleanup them
@@ -1,4 +1,4 @@ | |||
// RUN: %clangxx -fsycl -c %s -o %t.out -Wno-deprecated -fno-operator-names | |||
// RUN: %clangxx -fsycl -fsyntax-only %s -Wno-deprecated -fno-operator-names |
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.
Line 7?
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.
it does not appear to respect the -fno-operator-names option
What does it mean? Modified test passes.
I suggest we a use of operator name in the test itself and add --verify option with checks that operator names are used in the test, but no detected in the headers.
BTW, I suppose DPC++ extensions, which are not implicitly included by <sycl/sycl.hpp>
should be tested as well. Right?
@Pennycook, FYI.
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.
It seems like the comment on line 7 is not correct. From my local experiments:
$ ./bin/clang++ -fsyntax-only t.cpp -fno-operator-names
t.cpp:2:13: error: expected ')'
if (a > b and b >c ) {
^
t.cpp:2:6: note: to match this '('
if (a > b and b >c ) {
^
1 error generated.
$ ./bin/clang++ -fsyntax-only t.cpp -foperator-names
$ echo $?
0
UPD: -fsycl
doesn't alter the behavior, -fno-operator-names
still works as expected with it.
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.
Removed the comment in b29ae74
Adjusted LIT tests to use syntax-only mode for some tests which perform full compilation and linking or only compilation (
-c
) to speed up those tests.Also removed
-o
option from some existing-fsyntax-only
mode to shortenRUN
lines, because it is anyway ignored by the compiler.Refactored some tests for predefined macro to make checks at compile-time and not at runtime.