<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [AVR] uint32_t is incorrectly compiled to i16"
   href="https://bugs.llvm.org/show_bug.cgi?id=39210">39210</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[AVR] uint32_t is incorrectly compiled to i16
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Headers
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>aykevanlaethem@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When compiling this function for avr:

    #include <stdint.h>

    uint32_t size32() {
        return 3;
    }

With the following options:
    clang-7 --target=avr-atmel-none -emit-llvm -S -o intsize.ll -c intsize.c

I get the following IR (cut down to the essential parts):

    target datalayout = "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8"
    target triple = "avr-atmel-none"

    ; Function Attrs: noinline nounwind optnone
    define dso_local i16 @size32() #0 {
      ret i16 3
    }

In other words, uint32_t is compiled to i16 instead of i32 as it should.

I hit this problem while trying to build compiler-rt for AVR and hitting lots
of "shift count >= width of type" warnings which are probably caused by this
problem.

I'm running Debian stable (stretch) with clang-7 from apt.llvm.org.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>