Home | History | Annotate | Download | only in jni
      1 #include <stdio.h>
      2 #include "header.h"
      3 
      4 void foo(union u *ptr, int flag)
      5 {
      6     union u local;
      7     local.i = ptr->i;
      8 
      9     printf("Calling printf to trash r0..r3\n");
     10     /*
     11      * Clang 3.1 generates the following instructions to store flag into
     12      * local.s.x. Because str is paired with ldrh, the high half-word in r0 is
     13      * uninitialized and the corresponding positions in local.s.i will be
     14      * clobbered.
     15      *
     16      * 1a:   f8bd 0004       ldrh.w  r0, [sp, #4]
     17      * 1e:   f005 0101       and.w   r1, r5, #1
     18      * 22:   f020 0001       bic.w   r0, r0, #1
     19      * 26:   4308            orrs    r0, r1
     20      * 28:   9001            str     r0, [sp, #4]
     21      */
     22     local.s.x = flag;
     23     ptr->i = local.i;
     24 }
     25