<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Usage of attribute address_space causes error in backend"
   href="https://llvm.org/bugs/show_bug.cgi?id=23114">23114</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Usage of attribute address_space causes error in backend
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>svenk.public@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=14144" name="attach_14144" title="run script">attachment 14144</a> <a href="attachment.cgi?id=14144&action=edit" title="run script">[details]</a></span>
run script

Casting to a pointer with the 'address_space' attribute causes a fatal error in
the backend.

Error message:
fatal error: error in backend: Cannot select: 0x38752a0: i64 = addrspacecast
      0x3875190[0 -> 257] [ORD=8] [ID=12]
  0x3875190: i64,ch = load 0x3875080, 0x3874910, 0x3874b30<LD8[%1]> [ORD=7]
[ID=11]
    0x3874910: i64 = FrameIndex<0> [ID=2]
    0x3874b30: i64 = undef [ID=3]
In function: func
clang-3.7: error: clang frontend command failed with exit code 70 (use -v to
see invocation)

Example code to reproduce error:

#define FS_RELATIVE __attribute__((address_space(257)))
void func(char * p1, char * p2) {
    FS_RELATIVE char * p11 = (FS_RELATIVE char *) p1; /* 01 */
    *p11 = *p2;
}

Possible workaround is to introduce a cast to a non-pointer-type, i.e. replace
line marked /* 01 */ with:
FS_RELATIVE char * p11 = (FS_RELATIVE char *)(unsigned long)p1;</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>