-
Notifications
You must be signed in to change notification settings - Fork 788
Remove "unreachable" instruction from LLVM IR for SYCL devices #1789
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
Conversation
@Savonic: Mind taking 1 more look? I'm going to approve, but I want your final thought as well. |
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.
Actually, I just realized there isn't a test here. Please add a CodeGen LIT test for this.
Isn't this expected behavior? Maybe I don't understand the behavior of this attribute it looks like if I call "noreturn" function, it might run forever. Right? |
Well, simply that the function doesn't 'return', and the optimizer is allowed to assume that it is a 'terminate' type of thing. Typically, a noreturn function must terminate the program (as never-ending loops are considered UB). I forget the context of the bug report, but my understanding is that the driver folks didn't have a mechanism for handling this in the case of abort. Presumably, they would need to teach said drivers to abort, but I thought there wasn't a good way to do so. |
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.
BTW, please add a test.
Is code comments below captures it right? void foo() { while(1); } // UB
[[noreturn]] void foo() { while(1); } // must terminate - not UB |
Infinite loops themselves are UB, see http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1528.htm By my reading of the standard, BOTH while loops there are UB. I don't believe that the noreturn attribute changes that at all. It simply means that the compiler can optimize assuming that code after the call to a no-return function never executes. |
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 fine with FE changes, but I'd like @asavonic to approve first since I'm not an expert in stuff which is happening in assert test.
Please align the PR title with the latest revision of the patch. It is no longer limited to Intel NEO driver. |
@rbegam @intel/llvm-reviewers-runtime Can you please review this PR? |
fc6db38
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.
LGTM
This is a follow-up to: 74aa9a0 [SYCL] Remove "unreachable" instruction from LLVM IR for SYCL devices (intel#1789) Noreturn function attribute gives LLVM optimization passes an opportunity to re-structure code and insert an unreachable instruction. This happens when optimizations are turned on by -fsycl-enable-optimizations, so noreturn function attribute must be removed. Signed-off-by: Andrew Savonichev <[email protected]>
This is a follow-up to: 74aa9a0 [SYCL] Remove "unreachable" instruction from LLVM IR for SYCL devices (#1789) Noreturn function attribute gives LLVM optimization passes an opportunity to re-structure code and insert an unreachable instruction. This happens when optimizations are turned on by -fsycl-enable-optimizations, so noreturn function attribute must be removed. Signed-off-by: Andrew Savonichev <[email protected]>
Signed-off-by: Arvind Sudarsanam <[email protected]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@a8b0c8e
C/C++ standard functions with
__attribute__ ((__noreturn__))
in SYCL device code emit "unreachable" instruction in LLVM IR. This PR removes the "ur" instruction in LLVM IR for SYCL devices.