0004-Corrected-register-usage-in-x86-DCAS-asm-blocks.patch 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. From a67cc1b055cf09f371e2eca544884634a1ccc886 Mon Sep 17 00:00:00 2001
  2. From: Andrey Semashev <andrey.semashev@gmail.com>
  3. Date: Sun, 8 Jan 2017 18:09:12 +0300
  4. Subject: [PATCH] Corrected register usage in x86 DCAS asm blocks.
  5. In some of the asm blocks eax was modified as a result of cmpxchg8b but that
  6. was not reflected in the register constraints. This could cause incorrect code
  7. being generated.
  8. Fetch from:
  9. https://github.com/boostorg/atomic/commit/a67cc1b055cf09f371e2eca544884634a1ccc886
  10. [Adjust github patch to tarball release]
  11. Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
  12. ---
  13. boost/atomic/detail/ops_gcc_x86_dcas.hpp | 14 ++++++++------
  14. 1 file changed, 8 insertions(+), 6 deletions(-)
  15. diff --git a/boost/atomic/detail/ops_gcc_x86_dcas.hpp b/boost/atomic/detail/ops_gcc_x86_dcas.hpp
  16. index 2f51182..e356e8c 100644
  17. --- a/boost/atomic/detail/ops_gcc_x86_dcas.hpp
  18. +++ b/boost/atomic/detail/ops_gcc_x86_dcas.hpp
  19. @@ -73,6 +73,7 @@ struct gcc_dcas_x86
  20. {
  21. #if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS)
  22. #if defined(__PIC__)
  23. + uint32_t v_lo = (uint32_t)v;
  24. uint32_t scratch;
  25. __asm__ __volatile__
  26. (
  27. @@ -84,8 +85,8 @@ struct gcc_dcas_x86
  28. "1: lock; cmpxchg8b %[dest]\n\t"
  29. "jne 1b\n\t"
  30. "movl %[scratch], %%ebx\n\t"
  31. - : [scratch] "=m" (scratch), [dest] "=o" (storage)
  32. - : [value_lo] "a" ((uint32_t)v), "c" ((uint32_t)(v >> 32))
  33. + : [scratch] "=m" (scratch), [dest] "=o" (storage), [value_lo] "+a" (v_lo)
  34. + : "c" ((uint32_t)(v >> 32))
  35. : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "edx", "memory"
  36. );
  37. #else // defined(__PIC__)
  38. @@ -103,6 +104,7 @@ struct gcc_dcas_x86
  39. #endif // defined(__PIC__)
  40. #else // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS)
  41. #if defined(__PIC__)
  42. + uint32_t v_lo = (uint32_t)v;
  43. uint32_t scratch;
  44. __asm__ __volatile__
  45. (
  46. @@ -115,11 +117,11 @@ struct gcc_dcas_x86
  47. "jne 1b\n\t"
  48. "movl %[scratch], %%ebx\n\t"
  49. #if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES)
  50. - : [scratch] "=m,m" (scratch)
  51. - : [value_lo] "a,a" ((uint32_t)v), "c,c" ((uint32_t)(v >> 32)), [dest] "D,S" (&storage)
  52. + : [scratch] "=m,m" (scratch), [value_lo] "+a,a" (v_lo)
  53. + : "c,c" ((uint32_t)(v >> 32)), [dest] "D,S" (&storage)
  54. #else
  55. - : [scratch] "=m" (scratch)
  56. - : [value_lo] "a" ((uint32_t)v), "c" ((uint32_t)(v >> 32)), [dest] "D" (&storage)
  57. + : [scratch] "=m" (scratch), [value_lo] "+a" (v_lo)
  58. + : "c" ((uint32_t)(v >> 32)), [dest] "D" (&storage)
  59. #endif
  60. : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "edx", "memory"
  61. );