mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:27:45 +00:00
AK: Move taint_for_optimizer to StdLibExtras.h
Additionally, split it into two versions (for IsIntegral<T> -- asking to place value into register and for !IsIntegral<T> -- asking to place value into memory with memory clobber), so that Clang is no more completely confused about `taint_for_optimizer(AK::StringView&)`.
This commit is contained in:
parent
a9d192e882
commit
3c900765bc
2 changed files with 22 additions and 11 deletions
|
@ -154,17 +154,6 @@ constexpr StaticStorage<false, bit_width<T>> get_storage_of(T value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== Utilities =====
|
// ===== Utilities =====
|
||||||
template<typename T>
|
|
||||||
ALWAYS_INLINE constexpr void taint_for_optimizer(T& value)
|
|
||||||
{
|
|
||||||
if (!is_constant_evaluated()) {
|
|
||||||
asm volatile(""
|
|
||||||
: "+rm"(value)
|
|
||||||
:
|
|
||||||
: "memory");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ALWAYS_INLINE constexpr NativeWord extend_sign(bool sign)
|
ALWAYS_INLINE constexpr NativeWord extend_sign(bool sign)
|
||||||
{
|
{
|
||||||
return sign ? max_word : 0;
|
return sign ? max_word : 0;
|
||||||
|
|
|
@ -166,6 +166,28 @@ constexpr bool is_constant_evaluated()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
ALWAYS_INLINE constexpr void taint_for_optimizer(T& value)
|
||||||
|
requires(IsIntegral<T>)
|
||||||
|
{
|
||||||
|
if (!is_constant_evaluated()) {
|
||||||
|
asm volatile(""
|
||||||
|
: "+r"(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
ALWAYS_INLINE constexpr void taint_for_optimizer(T& value)
|
||||||
|
requires(!IsIntegral<T>)
|
||||||
|
{
|
||||||
|
if (!is_constant_evaluated()) {
|
||||||
|
asm volatile(""
|
||||||
|
:
|
||||||
|
: "m"(value)
|
||||||
|
: "memory");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// These can't be exported into the global namespace as they would clash with the C standard library.
|
// These can't be exported into the global namespace as they would clash with the C standard library.
|
||||||
|
|
||||||
#define __DEFINE_GENERIC_ABS(type, zero, intrinsic) \
|
#define __DEFINE_GENERIC_ABS(type, zero, intrinsic) \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue