This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/23539] C & C++ compiler generating misaligned references regardless of compiler flags


------- Additional Comments From mcvick_e at iname dot com  2005-08-24 15:44 -------
Here is a short program that duplicates the problem.

------------------ test.cc ------------------------
struct foo {
   char bar1;
   char bar2;
   char bar3;
};


class bar2 {
private:
   static foo   myFubarStruct;

public:

   static void fbs(foo fubarStruct);
};

foo bar2::myFubarStruct;

class bar1 {
private:
   int rVal1;
   int rVal2;

public:
   void doFoo(void);
};

void bar1::doFoo(void) {

   foo barStruct;

   barStruct.bar1 = 'A';
   barStruct.bar2 = 'B';
   barStruct.bar3 = 'C';

   bar2::fbs(barStruct);
}

void bar2::fbs(foo fubarStruct) {
   myFubarStruct = fubarStruct;
}


int main(int argc, char **argv) {

   bar1   baar;

   baar.doFoo();

   return (0);
}

------------------ end of test.cc ------------------------------

The test app was just compiled to object code as shown below with the -mstrict-
align option.

(2)> ppcg++ -mstrict-align -c test.cc

Then an objdump was done to dump the assembly (shown below)

(3)> ppcobjdump -C -S test.o

test.o:     file format elf32-powerpc

Disassembly of section .text:

00000000 <bar2::fbs(foo)>:
   0:   94 21 ff f0     stwu    r1,-16(r1)
   4:   93 e1 00 0c     stw     r31,12(r1)
   8:   7c 3f 0b 78     mr      r31,r1
   c:   7c 6b 1b 78     mr      r11,r3
  10:   3d 20 00 00     lis     r9,0
  14:   39 29 00 00     addi    r9,r9,0
  18:   88 0b 00 00     lbz     r0,0(r11)
  1c:   89 4b 00 01     lbz     r10,1(r11)
  20:   89 6b 00 02     lbz     r11,2(r11)
  24:   98 09 00 00     stb     r0,0(r9)
  28:   99 49 00 01     stb     r10,1(r9)
  2c:   99 69 00 02     stb     r11,2(r9)
  30:   81 61 00 00     lwz     r11,0(r1)
  34:   83 eb ff fc     lwz     r31,-4(r11)
  38:   7d 61 5b 78     mr      r1,r11
  3c:   4e 80 00 20     blr

00000040 <bar1::doFoo()>:
  40:   94 21 ff c8     stwu    r1,-56(r1)
  44:   7c 08 02 a6     mflr    r0
  48:   93 e1 00 34     stw     r31,52(r1)
  4c:   90 01 00 3c     stw     r0,60(r1)
  50:   7c 3f 0b 78     mr      r31,r1
  54:   90 7f 00 18     stw     r3,24(r31)
  58:   38 00 00 41     li      r0,65
  5c:   98 1f 00 0b     stb     r0,11(r31)
  60:   38 00 00 42     li      r0,66
  64:   98 1f 00 0c     stb     r0,12(r31)
  68:   38 00 00 43     li      r0,67
  6c:   98 1f 00 0d     stb     r0,13(r31)
  70:   88 1f 00 0b     lbz     r0,11(r31)
  74:   89 3f 00 0c     lbz     r9,12(r31)
  78:   89 7f 00 0d     lbz     r11,13(r31)
  7c:   98 1f 00 08     stb     r0,8(r31)
  80:   99 3f 00 09     stb     r9,9(r31)
  84:   99 7f 00 0a     stb     r11,10(r31)
  88:   88 1f 00 08     lbz     r0,8(r31)
  8c:   a1 3f 00 09     lhz     r9,9(r31)       <--- Odd alignment
  90:   98 1f 00 20     stb     r0,32(r31)
  94:   b1 3f 00 21     sth     r9,33(r31)      <--- Odd alignment
  98:   38 1f 00 20     addi    r0,r31,32
  9c:   7c 03 03 78     mr      r3,r0
  a0:   48 00 00 01     bl      a0 <bar1::doFoo()+0x60>
  a4:   81 61 00 00     lwz     r11,0(r1)
  a8:   80 0b 00 04     lwz     r0,4(r11)
  ac:   7c 08 03 a6     mtlr    r0
  b0:   83 eb ff fc     lwz     r31,-4(r11)
  b4:   7d 61 5b 78     mr      r1,r11
  b8:   4e 80 00 20     blr

000000bc <main>:
  bc:   94 21 ff d8     stwu    r1,-40(r1)
  c0:   7c 08 02 a6     mflr    r0
  c4:   93 e1 00 24     stw     r31,36(r1)
  c8:   90 01 00 2c     stw     r0,44(r1)
  cc:   7c 3f 0b 78     mr      r31,r1
  d0:   90 7f 00 18     stw     r3,24(r31)
  d4:   90 9f 00 1c     stw     r4,28(r31)
  d8:   48 00 00 01     bl      d8 <main+0x1c>
  dc:   38 7f 00 08     addi    r3,r31,8
  e0:   48 00 00 01     bl      e0 <main+0x24>
  e4:   38 00 00 00     li      r0,0
  e8:   7c 03 03 78     mr      r3,r0
  ec:   81 61 00 00     lwz     r11,0(r1)
  f0:   80 0b 00 04     lwz     r0,4(r11)
  f4:   7c 08 03 a6     mtlr    r0
  f8:   83 eb ff fc     lwz     r31,-4(r11)
  fc:   7d 61 5b 78     mr      r1,r11
 100:   4e 80 00 20     blr
(4)>


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23539


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]