TMS570: more testing including combination with HalCoGen files for direct RTEMS startup and VFP

Pavel Pisa pisa at cmp.felk.cvut.cz
Sat Nov 28 15:47:17 UTC 2015


Hello Gedare,

On Saturday 28 of November 2015 16:13:23 Gedare Bloom wrote:
> On Sat, Nov 28, 2015 at 5:24 AM, Pavel Pisa <pisa at cmp.felk.cvut.cz> wrote:
> > I have come with next workaround to ensure that GCC
> > cannot predict that compared value is equivalent
> > to address of static/global object.
> >
> > -  if ( (uintptr_t)bsp_start_vector_table_begin != 0 ) {
> > +  asm volatile ("\n": "=r" (need_remap_int): "r" (need_remap_ptr));
> > +  if ( need_remap_int != 0 ) {
> >
> > Code generated with this change is correct and really
> > switches POM off for application located at start
> > of memory map. I prepare patch for this and run more tests.
> >
> > Observed problem can affect much more BSPs and places
> > in RTEMS. Usage of all linker symbols in RTEMS should
> > be checked.
>
> Can we (do we want to) suppress the particular optimization?
>
> If the suggested approach is deemed "best", then we should create some
> macros to facilitate using it.
>
> I seem to recall similar problems related to vector addresses in some
> other BSP but I can't find any email about it.

.... I am not sure if the solution is the best one.
I have made mistake in above example. It should be

   asm volatile ("\n": "=r" (need_remap_int): "0" (need_remap_ptr));

to map input and output to same register else (dummy) move instruction
is required. Even without it code worked OK when I have tested it
because GCC mapped r3 to both sides.

The sent patch contains corrected code already.

Other options which should not be optimized out

 if ( (uintptr_t)linker_address & ~1 )

or 

 if ( (uintptr_t)linker_address < 2 )

So if that is more preferred we can take this path.
Both later solutions have problem to distinguish value
between 0 and 1.

If you want I can propose nest define to suppress optimization

#define RTEMS_SUPPRESS_NULL_OPTIMIZATION(inp_val) \
 ({
   typeof(inp_val) out_val;
   asm volatile ("\n": "=r" (out_val): "0" (inp_val));
   out_val;
 })

or function for pointers

static inline void *rtems_suppress_null_optimization(void *val)
{
  asm volatile ("\n": "=r" (val): "0" (val));
  return val;
}

or function

static inline int rtems_object_address_is_zero(void *val)
{
  asm volatile ("\n": "=r" (val): "0" (val));
  return val == 0;
}

for non GCC builds it can be declared as

static inline int rtems_object_address_is_zero(void *val)
{
  return ((uintptr_t)val & ~1) == 0;
}

So the preferred form depends on taste.

Best wishes,

              Pavel




More information about the devel mailing list