@@ -174,7 +174,7 @@ char MPIR_attach_fifo[MPIR_MAX_PATH_LENGTH] = {0};
174174int MPIR_force_to_main = 0 ;
175175static void orte_debugger_init_before_spawn (orte_job_t * jdata );
176176
177- ORTE_DECLSPEC void * __opal_attribute_optnone__ MPIR_Breakpoint (void );
177+ ORTE_DECLSPEC void __opal_attribute_optnone__ MPIR_Breakpoint (void );
178178
179179/*
180180 * Attempt to prevent the compiler from optimizing out
@@ -192,14 +192,26 @@ ORTE_DECLSPEC void* __opal_attribute_optnone__ MPIR_Breakpoint(void);
192192 * See the following git issue for more discussion:
193193 * https://github.com/open-mpi/ompi/issues/5501
194194 */
195- static volatile void * volatile noop_mpir_breakpoint_ptr = NULL ;
195+ volatile void * volatile noop_mpir_breakpoint_ptr = NULL ;
196196
197197/*
198198 * Breakpoint function for parallel debuggers
199199 */
200- void * MPIR_Breakpoint (void )
200+ void MPIR_Breakpoint (void )
201201{
202- return noop_mpir_breakpoint_ptr ;
202+ /*
203+ * Actually do something with this pointer to make
204+ * sure the compiler does not optimize out this function.
205+ * The compiler should be forced to keep this
206+ * function around due to the volatile void* type.
207+ *
208+ * This pointer doesn't actually do anything other than
209+ * prevent unwanted optimization, and
210+ * *should not* be used anywhere else in the code.
211+ * So pointing this to the weeds should be OK.
212+ */
213+ noop_mpir_breakpoint_ptr = (volatile void * ) 0x42 ;
214+ return ;
203215}
204216
205217/* local objects */
0 commit comments