clc: static assert that clc_optional_features has no padding
authorKarol Herbst <git@karolherbst.de>
Thu, 15 Jun 2023 22:29:24 +0000 (00:29 +0200)
committerMarge Bot <emma+marge@anholt.net>
Thu, 15 Jun 2023 23:31:27 +0000 (23:31 +0000)
Signed-off-by: Karol Herbst <git@karolherbst.de>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23685>

src/compiler/clc/clc.h
src/compiler/clc/clc_helpers.cpp

index de867cf..690c3db 100644 (file)
@@ -49,7 +49,6 @@ enum clc_spirv_version {
    CLC_SPIRV_VERSION_1_4,
 };
 
-// IMPORTANT: this struct is used for hashing and must not contain any padding.
 struct clc_optional_features {
    bool fp16;
    bool fp64;
index 17400b0..1f72b99 100644 (file)
@@ -756,6 +756,9 @@ clc_compile_to_llvm_module(LLVMContext &llvm_ctx,
                            const struct clc_compile_args *args,
                            const struct clc_logger *logger)
 {
+   static_assert(std::has_unique_object_representations<clc_optional_features>(),
+                 "no padding allowed inside clc_optional_features");
+
    std::string diag_log_str;
    raw_string_ostream diag_log_stream { diag_log_str };