Skip to content
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

[MISC] Add workaround for gcc13's bogus memmov warnings #227

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion include/chopper/workarounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,29 @@

#pragma once

#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER)
# define CHOPPER_COMPILER_IS_GCC 1
#else
# define CHOPPER_COMPILER_IS_GCC 0
#endif

/*!\brief Workaround bogus memcpy errors in GCC 12. (Wrestrict and Wstringop-overflow)
* \see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105545
*/
#ifndef CHOPPER_WORKAROUND_GCC_BOGUS_MEMCPY
# if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER) && (__GNUC__ == 12)
# if CHOPPER_COMPILER_IS_GCC && (__GNUC__ == 12)
# define CHOPPER_WORKAROUND_GCC_BOGUS_MEMCPY 1
# else
# define CHOPPER_WORKAROUND_GCC_BOGUS_MEMCPY 0
# endif
#endif

/*!\brief Workaround bogus memmov errors in GCC 13. (Warray-bounds and Wstringop-overflow)
*/
#ifndef CHOPPER_WORKAROUND_GCC_BOGUS_MEMMOV
# if CHOPPER_COMPILER_IS_GCC && (__GNUC__ == 13)
# define CHOPPER_WORKAROUND_GCC_BOGUS_MEMMOV 1
# else
# define CHOPPER_WORKAROUND_GCC_BOGUS_MEMMOV 0
# endif
#endif
16 changes: 16 additions & 0 deletions src/layout/hibf_statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,15 @@ void hibf_statistics::collect_bins()

if (!found_merged_bin)
{
#if CHOPPER_WORKAROUND_GCC_BOGUS_MEMMOV
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Warray-bounds="
# pragma GCC diagnostic ignored "-Wstringop-overflow="
#endif // CHOPPER_WORKAROUND_GCC_BOGUS_MEMMOV
ibf.bins.emplace_back(hibf_statistics::bin_kind::merged, 1, std::vector<size_t>{user_bin_info.idx});
#if CHOPPER_WORKAROUND_GCC_BOGUS_MEMMOV
# pragma GCC diagnostic pop
#endif // CHOPPER_WORKAROUND_GCC_BOGUS_MEMMOV
ibf.bins.back().tb_index = target_tb_index;
auto next = prev;
next.push_back(target_tb_index);
Expand All @@ -398,9 +406,17 @@ void hibf_statistics::collect_bins()

// emplace a split bin at last since every user bin is on its lowest level single or split
auto & ibf = ibfs[id_to_pos.at(prev)];
#if CHOPPER_WORKAROUND_GCC_BOGUS_MEMMOV
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Warray-bounds="
# pragma GCC diagnostic ignored "-Wstringop-overflow="
#endif // CHOPPER_WORKAROUND_GCC_BOGUS_MEMMOV
ibf.bins.emplace_back(hibf_statistics::bin_kind::split,
user_bin_info.number_of_technical_bins,
std::vector<size_t>{user_bin_info.idx});
#if CHOPPER_WORKAROUND_GCC_BOGUS_MEMMOV
# pragma GCC diagnostic pop
#endif // CHOPPER_WORKAROUND_GCC_BOGUS_MEMMOV
ibf.bins.back().tb_index = user_bin_info.storage_TB_id;
}

Expand Down