From 5c88587c014d30a60edcc68220b694c134bb2c3f Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 17 May 2020 23:35:26 +0000 Subject: [PATCH] Encourage std::fill to become memset gcc has a special case to devolve to memset if both the pointed-at data and the value to fill are considered a byte. All uses of DXX_POISON_MEMORY pass a value that fits in a byte, so change the signature to be a byte, to encourage gcc to activate the special case. --- common/include/compiler-poison.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/include/compiler-poison.h b/common/include/compiler-poison.h index c6f7c2c02..92c0c5974 100644 --- a/common/include/compiler-poison.h +++ b/common/include/compiler-poison.h @@ -103,8 +103,8 @@ static inline void DXX_POISON_DEFINED_MEMORY(T b, unsigned long l, const V &v) /* Poison a memory range, then mark it unreadable. */ -template -static inline void DXX_POISON_MEMORY(T b, unsigned long l, const V &v) +template +static inline void DXX_POISON_MEMORY(T b, unsigned long l, const uint8_t v) { DXX_POISON_DEFINED_MEMORY(b, l, v); DXX_MAKE_MEM_UNDEFINED(b, l); @@ -113,8 +113,8 @@ static inline void DXX_POISON_MEMORY(T b, unsigned long l, const V &v) /* Convenience function to invoke * `DXX_POISON_MEMORY(T &, unsigned long, V)` */ -template -static inline void DXX_POISON_MEMORY(T b, T e, const V &v) +template +static inline void DXX_POISON_MEMORY(T b, T e, const uint8_t &&v) { DXX_POISON_MEMORY_RANGE(b, e, v); DXX_MAKE_MEM_UNDEFINED(b, e); @@ -125,7 +125,7 @@ static inline void DXX_POISON_MEMORY(T b, T e, const V &v) * of `T`. */ template -static inline void DXX_POISON_VAR(T &b, const unsigned char v) +static inline void DXX_POISON_VAR(T &b, const uint8_t v) { DXX_POISON_MEMORY(reinterpret_cast(std::addressof(b)), sizeof(T), v); }