diff options
author | Snappy Team <no-reply@google.com> | 2022-11-09 05:32:52 +0000 |
---|---|---|
committer | Victor Costan <pwnall@chromium.org> | 2023-01-12 13:33:01 +0000 |
commit | 15e2a0e13ddd9c6444c8a95e611e6bda19e9c38f (patch) | |
tree | 71875dfead67118aa523edc78dc348f5f6e10df9 | |
parent | 8881ba172a32913435ef570564bc90123d596693 (diff) | |
download | snappy-git-15e2a0e13ddd9c6444c8a95e611e6bda19e9c38f.tar.gz |
Add "cc" clobbers to inline asm that modifies flags.
As far as we know, the lack of "cc" in the clobbers hasn't caused
problems yet, but it could. This change is to improve correctness,
and is also almost certainly performance neutral.
PiperOrigin-RevId: 487133620
-rw-r--r-- | snappy-internal.h | 6 | ||||
-rw-r--r-- | snappy.cc | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/snappy-internal.h b/snappy-internal.h index e552ea0..0923f39 100644 --- a/snappy-internal.h +++ b/snappy-internal.h @@ -246,7 +246,8 @@ static inline std::pair<size_t, bool> FindMatchLength(const char* s1, asm("testl %k2, %k2\n\t" "cmovzq %1, %0\n\t" : "+r"(a2) - : "r"(a3), "r"(xorval)); + : "r"(a3), "r"(xorval) + : "cc"); #endif *data = a2 >> (shift & (3 * 8)); return std::pair<size_t, bool>(matched_bytes, true); @@ -277,7 +278,8 @@ static inline std::pair<size_t, bool> FindMatchLength(const char* s1, asm("testl %k2, %k2\n\t" "cmovzq %1, %0\n\t" : "+r"(a2) - : "r"(a3), "r"(xorval)); + : "r"(a3), "r"(xorval) + : "cc"); #endif *data = a2 >> (shift & (3 * 8)); matched += matched_bytes; @@ -1107,7 +1107,8 @@ inline size_t AdvanceToNextTagX86Optimized(const uint8_t** ip_p, size_t* tag) { // TODO clang misses the fact that the (c & 3) already correctly // sets the zero flag. asm("and $3, %k[tag_type]\n\t" - : [tag_type] "+r"(tag_type), "=@ccz"(is_literal)); + : [tag_type] "+r"(tag_type), "=@ccz"(is_literal) + :: "cc"); #else tag_type &= 3; is_literal = (tag_type == 0); |