Skip to content

Commit 4fd35f6

Browse files
committed
Disable msan in clmul code
1 parent 566b2d4 commit 4fd35f6

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/fields/clmul_common_impl.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@
1515

1616
namespace {
1717

18-
template<typename I, int BITS, I MOD> I MulWithClMulReduce(I a, I b)
18+
// The memory sanitizer in clang 9 cannot reason through _mm_clmulepi64_si128 calls.
19+
// Disable memory sanitization entirely in them for now.
20+
#if defined(__has_feature)
21+
# if __has_feature(memory_sanitizer)
22+
# define NO_SANITIZE_MEMORY __attribute__((no_sanitize("memory")))
23+
# endif
24+
#endif
25+
#ifndef NO_SANITIZE_MEMORY
26+
# define NO_SANITIZE_MEMORY
27+
#endif
28+
29+
template<typename I, int BITS, I MOD> NO_SANITIZE_MEMORY I MulWithClMulReduce(I a, I b)
1930
{
2031
static constexpr I MASK = Mask<BITS, I>();
2132

@@ -52,7 +63,7 @@ template<typename I, int BITS, I MOD> I MulWithClMulReduce(I a, I b)
5263
}
5364
}
5465

55-
template<typename I, int BITS, int POS> I MulTrinomial(I a, I b)
66+
template<typename I, int BITS, int POS> NO_SANITIZE_MEMORY I MulTrinomial(I a, I b)
5667
{
5768
static constexpr I MASK = Mask<BITS, I>();
5869

0 commit comments

Comments
 (0)