Commit 4432df12 by Nicolas Capens Committed by Nicolas Capens

Fix GCC inline assembly syntax

The output registers and memory clobber were not being properly specified, which can cause incorrect compiler transformations when these functions are inlined cross-module via ThinLTO. Bug: b/135066502 Change-Id: I7031d5df2d9fe0f2712e65b98cfdf5b0990db598 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/32748 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent f9411ce3
...@@ -137,7 +137,7 @@ void clear(uint16_t *memory, uint16_t element, size_t count) ...@@ -137,7 +137,7 @@ void clear(uint16_t *memory, uint16_t element, size_t count)
#if defined(_MSC_VER) && defined(__x86__) && !defined(MEMORY_SANITIZER) #if defined(_MSC_VER) && defined(__x86__) && !defined(MEMORY_SANITIZER)
__stosw(memory, element, count); __stosw(memory, element, count);
#elif defined(__GNUC__) && defined(__x86__) && !defined(MEMORY_SANITIZER) #elif defined(__GNUC__) && defined(__x86__) && !defined(MEMORY_SANITIZER)
__asm__("rep stosw" : : "D"(memory), "a"(element), "c"(count)); __asm__ __volatile__("rep stosw" : "+D"(memory), "+c"(count) : "a"(element) : "memory");
#else #else
for(size_t i = 0; i < count; i++) for(size_t i = 0; i < count; i++)
{ {
...@@ -151,7 +151,7 @@ void clear(uint32_t *memory, uint32_t element, size_t count) ...@@ -151,7 +151,7 @@ void clear(uint32_t *memory, uint32_t element, size_t count)
#if defined(_MSC_VER) && defined(__x86__) && !defined(MEMORY_SANITIZER) #if defined(_MSC_VER) && defined(__x86__) && !defined(MEMORY_SANITIZER)
__stosd((unsigned long*)memory, element, count); __stosd((unsigned long*)memory, element, count);
#elif defined(__GNUC__) && defined(__x86__) && !defined(MEMORY_SANITIZER) #elif defined(__GNUC__) && defined(__x86__) && !defined(MEMORY_SANITIZER)
__asm__("rep stosl" : : "D"(memory), "a"(element), "c"(count)); __asm__ __volatile__("rep stosl" : "+D"(memory), "+c"(count) : "a"(element) : "memory");
#else #else
for(size_t i = 0; i < count; i++) for(size_t i = 0; i < count; i++)
{ {
...@@ -159,4 +159,5 @@ void clear(uint32_t *memory, uint32_t element, size_t count) ...@@ -159,4 +159,5 @@ void clear(uint32_t *memory, uint32_t element, size_t count)
} }
#endif #endif
} }
} }
...@@ -137,7 +137,7 @@ void clear(uint16_t *memory, uint16_t element, size_t count) ...@@ -137,7 +137,7 @@ void clear(uint16_t *memory, uint16_t element, size_t count)
#if defined(_MSC_VER) && defined(__x86__) && !defined(MEMORY_SANITIZER) #if defined(_MSC_VER) && defined(__x86__) && !defined(MEMORY_SANITIZER)
__stosw(memory, element, count); __stosw(memory, element, count);
#elif defined(__GNUC__) && defined(__x86__) && !defined(MEMORY_SANITIZER) #elif defined(__GNUC__) && defined(__x86__) && !defined(MEMORY_SANITIZER)
__asm__("rep stosw" : : "D"(memory), "a"(element), "c"(count)); __asm__ __volatile__("rep stosw" : "+D"(memory), "+c"(count) : "a"(element) : "memory");
#else #else
for(size_t i = 0; i < count; i++) for(size_t i = 0; i < count; i++)
{ {
...@@ -151,7 +151,7 @@ void clear(uint32_t *memory, uint32_t element, size_t count) ...@@ -151,7 +151,7 @@ void clear(uint32_t *memory, uint32_t element, size_t count)
#if defined(_MSC_VER) && defined(__x86__) && !defined(MEMORY_SANITIZER) #if defined(_MSC_VER) && defined(__x86__) && !defined(MEMORY_SANITIZER)
__stosd((unsigned long*)memory, element, count); __stosd((unsigned long*)memory, element, count);
#elif defined(__GNUC__) && defined(__x86__) && !defined(MEMORY_SANITIZER) #elif defined(__GNUC__) && defined(__x86__) && !defined(MEMORY_SANITIZER)
__asm__("rep stosl" : : "D"(memory), "a"(element), "c"(count)); __asm__ __volatile__("rep stosl" : "+D"(memory), "+c"(count) : "a"(element) : "memory");
#else #else
for(size_t i = 0; i < count; i++) for(size_t i = 0; i < count; i++)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment