mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +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
Notes:
sideshowbarker
2024-07-16 20:48:05 +09:00
Author: https://github.com/DanShaders Commit: https://github.com/SerenityOS/serenity/commit/3c900765bc Pull-request: https://github.com/SerenityOS/serenity/pull/17398 Reviewed-by: https://github.com/davidot ✅ Reviewed-by: https://github.com/kleinesfilmroellchen ✅
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 =====
|
||||
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)
|
||||
{
|
||||
return sign ? max_word : 0;
|
||||
|
|
|
@ -166,6 +166,28 @@ constexpr bool is_constant_evaluated()
|
|||
#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.
|
||||
|
||||
#define __DEFINE_GENERIC_ABS(type, zero, intrinsic) \
|
||||
|
|
Loading…
Reference in a new issue