<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 - [Arm32] Atomic operations on 64-bit operations have invalid bit-cast"
   href="https://bugs.llvm.org/show_bug.cgi?id=50721">50721</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Arm32] Atomic operations on 64-bit operations have invalid bit-cast
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Backend: ARM
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, smithp352@googlemail.com, Ties.Stuij@arm.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>As demonstrated by <a href="https://reviews.llvm.org/D104264">https://reviews.llvm.org/D104264</a>, the ARM back-end generates
a pointer bit-cast from i64 value to an i8* (to a {i32, i32} struct) to call
the double-word atomic operations on, but if the pointer is in a different
address space, the bit-cast fails.

The back-end barfs with the code (generated by a third-party front-end):
define i64 @atomic_load_i64_other_address_space(i64 addrspace(1)* align 8 %ptr)
{
load_entry:
    %val = load atomic i64, i64 addrspace(1)* %ptr acquire, align 8
    ret i64 %val
}

define void @atomic_store_i64_other_address_space(i64 addrspace(1)* align 8
%ptr, i64 %value) {
store_entry:
    store atomic i64 %value, i64 addrspace(1)* %ptr release, align 8
    ret void
}

and command line:
$ llc < %s -mtriple=thumbv7-linux-gnueabihf

with error: "invalid bit-cast".

The problem is in ARMISelLowering.cpp::emitLoadLinked:

Addr = Builder.CreateBitCast(Addr, Type::getInt8PtrTy(M->getContext()));

where Addr is not in the default address space.

The questions are:

1. What is the semantics in this case?
2. Do we create the i8* on the same address space?
3. Do we even want to know about address spaces at that level?

If the answer to (3) is "yes", then (2) seems like a valid solution. But I may
be missing something obvious.</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>