-
Notifications
You must be signed in to change notification settings - Fork 798
[SYCL][NFC] Fix build errors revealed by self build. #3132
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
clang/lib/CodeGen/CGSYCLRuntime.cpp
Outdated
@@ -78,9 +78,9 @@ bool CGSYCLRuntime::actOnFunctionStart(const FunctionDecl &FD, | |||
// be handled specially in the SYCL lowering pass | |||
F.setMetadata(PFWI_MD_ID, llvm::MDNode::get(F.getContext(), {})); | |||
break; |
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.
break; | |
break; | |
default: | |
// fall through |
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.
Adding the default here will lead to the same build error.
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.
Please see what I am proposing as a change.
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.
What is the build error? Would be good to add this info to the PR description 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.
This is a known issue about the default case of switch statement in clang.
Please see:
https://godbolt.org/z/5jvKjz
and
https://godbolt.org/z/sY6bdE
I can propose this solution.
https://godbolt.org/z/oqY8aG
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 more thing to confirm this change:
https://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations
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 combination of these 2 flags that will have the effect of a static. So there is really no need to add the assert as I was proposing in https://godbolt.org/z/oqY8aG.
See https://godbolt.org/z/PqE7Mf
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 see, thanks
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.
So there is really no need to add the assert
I agree with this.
d7e0322
to
9adb32f
Compare
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.
Could you please explain why default
is causing self-build issues?
Avoiding this error: "default label in switch which covers all enumeration values " |
@@ -8353,8 +8353,6 @@ void FileTableTform::ConstructJob(Compilation &C, const JobAction &JA, | |||
addArgs(CmdArgs, TCArgs, {Arg}); | |||
break; | |||
} | |||
default: | |||
llvm_unreachable("unknown file table transformation kind"); |
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.
Could you please explain this one? Are we losing the "unreachable" message for the cases not handled in the switch?
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.
Clang knows that the values of the switch can only be the ones listed in the cases before the default, and it gives the error that I am mentioning above.
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.
Ah, got it! Sorry, I didn't realize @elizabethandrews was asking about the same label.
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 we want to add, the unreachable to make sure we catch a potential wrong value of the switch then, we need to rewrite the switch statement all together. May be asserting that Tf.TheKind can only be the values listed and put that assertion before the switch statement. Let me know if you think that this is better approach.
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 think the case I was concerned about is when another enumerator is added to the enum type, but this switch isn't modified. But I guess in that case, the switch statement would get a diagnostic about a missing case statement.
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.
exactly - I was also curious and verified that
9adb32f
to
376a4db
Compare
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.
CGSYCLRuntime.cpp and ClangOffloadWrapper.cpp
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.
OK For Driver - Thanks!
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.
FE changes looks good to me.
Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com> Original commit: KhronosGroup/SPIRV-LLVM-Translator@8011eaf0c686ecc
Clang warns about using default in a switch statement where all enumerated cases are covered. This is a patch to avoid the warning.