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

            Bug ID: 122539
           Summary: CMSE wrongfully clearing non padded union members
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: avieira at gcc dot gnu.org
  Target Milestone: ---

When compiling something like:

#include <arm_cmse.h>                                                           

union u_t_0 {                                                                   
  long long ll;                                                                 
};                                                                              

typedef void(__attribute__((cmse_nonsecure_call)) fn_t_0)(union u_t_0);         

void fn_caller_0(fn_t_0 *f_ptr) {                                               
  union u_t_0 x = {1234};                                                       
  f_ptr(x);                                                                     
}

with -march=armv8-m.mainline -mcmse -O2 -mfloat-abi=soft
the compiler will generate the following assembly:
...
        movw    r0, #1234
        lsrs    r4, r4, #1
        lsls    r4, r4, #1
        mov     r0, r4
        mov     r1, r4
        mov     r2, r4
        mov     r3, r4
        bl      __gnu_cmse_nonsecure_call
...

where the 'mov r0, r4' wrongfully clears teh argument to the nonsecure call.

Reply via email to