From 94f092e32f98e7a716ffdcc5a64c0356e273179a Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Thu, 9 Jan 2025 00:01:43 -0800 Subject: [PATCH] Fix patcher for ppc and aarch64 Prevent the compiler from reordering the instructions in the patcher by marking the assembly code as clobbering memory. Thanks @pinskia for the patch and for bringing the discussion on the gcc bugzilla. Fixes #13014. Signed-off-by: George Bosilca --- opal/mca/patcher/patcher.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opal/mca/patcher/patcher.h b/opal/mca/patcher/patcher.h index 8779a583f77..7b59b6dd769 100644 --- a/opal/mca/patcher/patcher.h +++ b/opal/mca/patcher/patcher.h @@ -30,9 +30,9 @@ * Reference: "64-bit PowerPC ELF Application Binary Interface Supplement 1.9" */ # define OPAL_PATCHER_BEGIN \ unsigned long toc_save; \ - asm volatile("std 2, %0" : "=m"(toc_save)); \ - asm volatile("nop; nop; nop; nop; nop"); -# define OPAL_PATCHER_END asm volatile("ld 2, %0" : : "m"(toc_save)); + asm volatile("std 2, %0" : "=m"(toc_save) :: "memory"); \ + asm volatile("nop; nop; nop; nop; nop"::: "memory"); +# define OPAL_PATCHER_END asm volatile("ld 2, %0" : : "m"(toc_save) : "memory"); #else /* !__PPC64__ */