<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 8/14/12 9:31 AM, Baozeng wrote:<br>
    </div>
    <blockquote
cite="mid:CAP=GMUHeCuWdQTUiL2LTGQJy+2jGHu0KOT=dyNsJ92O=mbDpnw@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <br clear="all">
      Hello all,<br>
      I found that the alignment for stack value has no limitation, but
      for global value, it has a limitation.<br>
    </blockquote>
    <br>
    So here's what I found:<br>
    <br>
    1) We already know from Baozeng's experiments that LLVM 3.0 and
    Clang 3.0 do not align globals properly when the alignment is large.<br>
    <br>
    2) LLVM 3.1 will properly align globals with alignment up to 0x10000
    (which is larger than the 8192 byte alignment given in Baozeng's
    original example).  However, Clang 3.1 will assert out because it
    uses an unsigned short for representing alignments of lvalues. 
    Changing the alignment class member to unsigned long magically fixes
    everything, and the code will align variables up to 0x10000
    properly.<br>
    <br>
    3) LLVM/Clang mainline have the same behavior as LLVM 3.1.<br>
    <br>
    Baozeng, for your Baggy Bounds Checking work, the upgrade to LLVM
    mainline that SAFECode is currently undergoing will just fix the
    problem that you're seeing.  You and I can discuss separately
    whether to make the LLVM mainline switch for BBC during GSoC.<br>
    <br>
    As for the bug in Clang, I'll file a bug report.<br>
    <br>
    -- John T.<br>
    <br>
    <br>
    <blockquote
cite="mid:CAP=GMUHeCuWdQTUiL2LTGQJy+2jGHu0KOT=dyNsJ92O=mbDpnw@mail.gmail.com"
      type="cite"><br>
      Here is an example:<br>
      <br>
      #include <stdio.h><br>
      #include <stdlib.h><br>
      <br>
      char x[4000] __attribute__((aligned(4096)));<br>
      <br>
      int<br>
      main (int argc, char ** argv) {<br>
        char y[4000] __attribute__((aligned(4096)));<br>
        printf("x is %p\n", x);<br>
        printf("y is %p\n", y);<br>
        <br>
        return 0;<br>
      }<br>
      <br>
      After compiled with clang, the result is:<br>
      x is 0x804b000<br>
      y is 0xbf9d8000<br>
      <br>
      They are both aligned to be 4096 as we expected.<br>
      <br>
      Then we change the example as the following:<br>
      <br>
      char x[4000] __attribute__((aligned(8192)));<br>
      <br>
      int<br>
      main (int argc, char ** argv) {<br>
        char y[4000] __attribute__((aligned(8192)));<br>
        printf("x is %p\n", x);<br>
        printf("y is %p\n", y);<br>
        <br>
        return 0;<br>
      }<br>
      <br>
      The result is :<br>
      x is 0x804d000<br>
      y is 0xbffd2000<br>
      <br>
      We can see that the stack value y is aligned to be 8192, but the
      global value x is not!<br>
      <br>
      My target OS is 32-bit Linux. Anyone can explain this? or is this
      a bug of clang? <br>
      <br>
      <br>
      <br>
      <br>
      -- <br>
           Best Regards,<br>
                                                                      
      Baozeng Ding<br>
                                                                      
      OSTG,NFS,ISCAS<br>
      <br>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>