1 parent
3851aeb703
commit
053ee5b296
23 files changed
+845
-93
No files matched your search
@@ -103,7 +103,10 @@ template <typename T>
|
||||
inline void do_not_optimize(T& val) noexcept
|
||||
{
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
asm volatile("" : "+r,m"(val) : : "memory");
|
||||
// A memory operand works for every object type and remains accepted by
|
||||
// GCC 16, which rejects the old mixed "+r,m" alternative constraint for
|
||||
// some scalar instantiations.
|
||||
asm volatile("" : "+m"(val) : : "memory");
|
||||
#else
|
||||
volatile T* p = &val;
|
||||
(void)*p;
|
||||
@@ -114,7 +117,7 @@ template <typename T>
|
||||
inline void do_not_optimize(const T& val) noexcept
|
||||
{
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
asm volatile("" : : "r,m"(val) : "memory");
|
||||
asm volatile("" : : "m"(val) : "memory");
|
||||
#else
|
||||
volatile const T* p = &val;
|
||||
(void)*p;
|
||||
|
||||
Reference in new issue
Block a user