score: Add _CPU_Context_switch_no_return()

The __builtin_unreachable() cannot be used with current GCC versions to
tell the compiler that a function does not return to the caller, see:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99151

Add a no return variant of _CPU_Context_switch() to avoid generation of
dead code in _Thread_Start_multitasking() if RTEMS was built with SMP
support enabled.
This commit is contained in:
Sebastian Huber
2021-05-18 08:02:50 +02:00
parent 80b3c938ce
commit d45f87cf35
10 changed files with 58 additions and 5 deletions
+2
View File
@@ -258,7 +258,9 @@ PROC (_CPU_Context_restore_fp):
ALIGN (PPC_CACHE_ALIGNMENT, PPC_CACHE_ALIGN_POWER)
PUBLIC_PROC (_CPU_Context_switch)
PUBLIC_PROC (_CPU_Context_switch_no_return)
PROC (_CPU_Context_switch):
PROC (_CPU_Context_switch_no_return):
#ifdef BSP_USE_SYNC_IN_CONTEXT_SWITCH
sync
+3
View File
@@ -54,6 +54,9 @@
*/
DEFINE_FUNCTION_ARM(_CPU_Context_switch)
.globl _CPU_Context_switch_no_return
.set _CPU_Context_switch_no_return, _CPU_Context_switch
/* Start saving context */
GET_SELF_CPU_CONTROL r2
ldr r3, [r2, #PER_CPU_ISR_DISPATCH_DISABLE]
@@ -465,6 +465,11 @@ void _CPU_ISR_install_vector(
*/
void _CPU_Context_switch( Context_Control *run, Context_Control *heir );
RTEMS_NO_RETURN void _CPU_Context_switch_no_return(
Context_Control *executing,
Context_Control *heir
);
RTEMS_NO_RETURN void _CPU_Context_restore( Context_Control *new_context );
#if defined(ARM_MULTILIB_ARCH_V7M)
@@ -1054,22 +1054,46 @@ void _CPU_ISR_install_vector(
void *_CPU_Thread_Idle_body( uintptr_t ignored );
/**
* @brief Performs a context switch from the executing thread to the heir
* thread.
*
* @addtogroup RTEMSScoreCPUExampleContext
*
* This routine switches from the run context to the heir context.
* This routine switches from the executing context to the heir context.
*
* @param[in] run points to the context of the currently executing task
* @param[in] heir points to the context of the heir task
* @param[out] executing points to the context of the currently executing task.
*
* @param[in, out] heir points to the context of the heir task.
*
* Port Specific Information:
*
* XXX document implementation including references if appropriate
*/
void _CPU_Context_switch(
Context_Control *run,
Context_Control *executing,
Context_Control *heir
);
/**
* @brief Performs a context switch from the executing thread to the heir
* thread and does not return.
*
* @addtogroup RTEMSScoreCPUExampleContext
*
* This routine shall be a strong alias to _CPU_Context_switch(). It shall be
* provided for all target architectures which support an SMP build
* configuration (RTEMS_SMP). The purpose is help to compiler to avoid
* generation of dead code in _Thread_Start_multitasking().
*
* @param[out] executing points to the context of the currently executing task.
*
* @param[in, out] heir points to the context of the heir task.
*/
RTEMS_NO_RETURN void _CPU_Context_switch_no_return(
Context_Control *executing,
Context_Control *heir
);
/**
* @addtogroup RTEMSScoreCPUExampleContext
*
@@ -914,6 +914,11 @@ void _CPU_Context_switch(
Context_Control *heir
);
RTEMS_NO_RETURN void _CPU_Context_switch_no_return(
Context_Control *executing,
Context_Control *heir
);
/*
* _CPU_Context_restore
*
@@ -383,6 +383,11 @@ void _CPU_Context_switch(
Context_Control *heir
);
RTEMS_NO_RETURN void _CPU_Context_switch_no_return(
Context_Control *executing,
Context_Control *heir
);
/*
* _CPU_Context_restore
*
@@ -37,9 +37,11 @@
.align 2
PUBLIC(_CPU_Context_switch)
PUBLIC(_CPU_Context_switch_no_return)
PUBLIC(_CPU_Context_restore)
SYM(_CPU_Context_switch):
SYM(_CPU_Context_switch_no_return):
GET_SELF_CPU_CONTROL a2
lw a3, PER_CPU_ISR_DISPATCH_DISABLE(a2)
+2
View File
@@ -57,7 +57,9 @@
.align 4
PUBLIC(_CPU_Context_switch)
PUBLIC(_CPU_Context_switch_no_return)
SYM(_CPU_Context_switch):
SYM(_CPU_Context_switch_no_return):
st %g5, [%o0 + G5_OFFSET] ! save the global registers
/*
@@ -971,6 +971,11 @@ void _CPU_Context_switch(
Context_Control *heir
);
RTEMS_NO_RETURN void _CPU_Context_switch_no_return(
Context_Control *executing,
Context_Control *heir
);
/**
* @brief SPARC specific context restore.
*
+1 -1
View File
@@ -59,7 +59,7 @@ void _Thread_Start_multitasking( void )
* executing to the currently selected heir thread.
*/
_CPU_Context_Set_is_executing( &trash, true );
_CPU_Context_switch( &trash, &heir->Registers );
_CPU_Context_switch_no_return( &trash, &heir->Registers );
RTEMS_UNREACHABLE();
}
#else