[Openmp-commits] [openmp] 6564a70 - [OpenMP][libomp] Fix register constraint for tpause and umwait

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Mon Mar 7 12:56:07 PST 2022


Author: Jonathan Peyton
Date: 2022-03-07T14:55:49-06:00
New Revision: 6564a70415df1eb1504bb271d0d958b456e22c64

URL: https://github.com/llvm/llvm-project/commit/6564a70415df1eb1504bb271d0d958b456e22c64
DIFF: https://github.com/llvm/llvm-project/commit/6564a70415df1eb1504bb271d0d958b456e22c64.diff

LOG: [OpenMP][libomp] Fix register constraint for tpause and umwait

Register constraint switched to "=q" which means very specifically (from
https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html#Machine-Constraints)

> Any register accessible as rl. In 32-bit mode, a, b, c, and d; in 64-bit
mode, any integer register.

Older gcc versions (8.x and below) were trying to use esi or edi for the
8 bit flag variable, but it wound up displaying this error in the end:

kmp_lock.cpp: In function ‘void __kmp_spin_backoff(kmp_backoff_t*)’:
kmp_lock.cpp:2684:1: error: unsupported size for integer register
Hence the correct restriction is "=q" instead of "=r".

Fixes: https://github.com/llvm/llvm-project/issues/53309
Differential Revision: https://reviews.llvm.org/D120519

Added: 
    

Modified: 
    openmp/runtime/src/kmp.h

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index 43fba81adee7c..826a42407a338 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -1334,7 +1334,10 @@ static inline int __kmp_tpause(uint32_t hint, uint64_t counter) {
   char flag;
   __asm__ volatile("#tpause\n.byte 0x66, 0x0F, 0xAE, 0xF1\n"
                    "setb   %0"
-                   : "=r"(flag)
+                   // The "=q" restraint means any register accessible as rl
+                   //   in 32-bit mode: a, b, c, and d;
+                   //   in 64-bit mode: any integer register
+                   : "=q"(flag)
                    : "a"(timeLo), "d"(timeHi), "c"(hint)
                    :);
   return flag;
@@ -1361,7 +1364,10 @@ static inline int __kmp_umwait(uint32_t hint, uint64_t counter) {
   char flag;
   __asm__ volatile("#umwait\n.byte 0xF2, 0x0F, 0xAE, 0xF1\n"
                    "setb   %0"
-                   : "=r"(flag)
+                   // The "=q" restraint means any register accessible as rl
+                   //   in 32-bit mode: a, b, c, and d;
+                   //   in 64-bit mode: any integer register
+                   : "=q"(flag)
                    : "a"(timeLo), "d"(timeHi), "c"(hint)
                    :);
   return flag;


        


More information about the Openmp-commits mailing list