[libspirv][NFC] Fix build warnings when -Wall -Wextra is enabled#21586
[libspirv][NFC] Fix build warnings when -Wall -Wextra is enabled#21586wenju-he wants to merge 1 commit intointel:syclfrom
Conversation
| int scope, global __CLC_GENTYPE *dst, const local __CLC_GENTYPE *src, | ||
| size_t num_gentypes, size_t stride, event_t event) { | ||
| (void)scope; |
There was a problem hiding this comment.
| int scope, global __CLC_GENTYPE *dst, const local __CLC_GENTYPE *src, | |
| size_t num_gentypes, size_t stride, event_t event) { | |
| (void)scope; | |
| int /*scope*/, global __CLC_GENTYPE *dst, const local __CLC_GENTYPE *src, | |
| size_t num_gentypes, size_t stride, event_t event) { |
NIT: I'm not sure if libclc has an established existing practice for unused parameters, if it does it might be better to follow that, but I personally prefer this style. See also C++ Core Guidelines - Unused parameters should unnamed
Applies to all the places where there are unused parameters of course, I don't want to comment on all of them :)
| } else { \ | ||
| __builtin_trap(); \ | ||
| __builtin_unreachable(); \ |
There was a problem hiding this comment.
If op is ever not one of the above values that is an error made by the developer of libclc, and never the user, right?
In that case I think this check should be some kind of build-time controlled assertion that compiles to only __builtin_unreachable in release builds (basically LLVM_UNREACHABLE).
I would also find a structure like this better, in which case we don't need unreachable:
if (op == Reduce) { \
result = __clc__SubgroupShuffle(x, __spirv_BuiltInSubgroupSize() - 1); \
*carry = result; \
} /* For InclusiveScan, use results as computed */ \
else if (op == InclusiveScan) { \
result = x; \
*carry = result; \
} else { \
LIBCLC_ASSERT(op == ExclusiveScan && "Unexpected operation"); \
/* For ExclusiveScan, shift and prepend identity */ \
*carry = x; \
result = __clc__SubgroupShuffleUp(x, 1); \
if (sg_lid == 0) { \
result = IDENTITY; \
} \
}Also we're basically expecting the optimizer to fold these conditionals out, correct?
In this case I think just as OP is a macro, we could have a EPILOG_OP. Though honestly using some C++ templates and lambdas in libclc is sounding more and more attractive.
There was a problem hiding this comment.
If you'd like to get this in quickly and return to LIBCLC_ASSERT or similar in a follow up then I would make the code like the above and only have the "assert" as a TODO comment.
| } else { \ | ||
| result = OP(sg_x, sg_prefix); \ | ||
| } \ | ||
| } else { \ |
| float4 a = __nvvm_tex_1d_v4f32_f32(imageHandle, x); | ||
| float4 a = __nvvm_tex_3d_v4f32_f32(imageHandle, x, y, z); |
There was a problem hiding this comment.
How did this ever work before? Good catch, ...I think :).
No description provided.