<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 --- - [OpenCL] Produces illegal address space conversions for automatic local struct arrays" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24004&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=0sHRyEjJxXn1fQGtbvaB_oRKYQLzBrEk-6Ga0jLbre4&s=6TGefAEaQ_9VW9mertRdbXeIocg1ZkbaOyGcXwkOBh4&e=">24004</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[OpenCL] Produces illegal address space conversions for automatic local struct arrays
          </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>pekka.jaaskelainen@tut.fi
          </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>Related pocl bug: <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_pocl_pocl_issues_195&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=0sHRyEjJxXn1fQGtbvaB_oRKYQLzBrEk-6Ga0jLbre4&s=6_TXMTg_8M3V6PaXcAZl2wAUiTxGb2MoqwdLwqLDbbE&e=">https://github.com/pocl/pocl/issues/195</a>

Reproduce with a scan.cl:

typedef struct {
  int c00;
  int c01;
} scan_t;

scan_t add(scan_t a, scan_t b)
{
  return b;
}

kernel
void scan_scan_intervals_lev1()
{
  local scan_t psc_ldata[2];

  psc_ldata[0] = add(psc_ldata[0], psc_ldata[1]);
}

clang -Xclang -ffake-address-space-map -x cl scan.cl -emit-llvm  -c -S -o -

This either crashes with an assertion (in case Clang built with assertions) or
generates an illegal bitcast between address spaceslike this:

%1 = load i64* bitcast (%struct.scan_t addrspace(2)* getelementptr inbounds ([2
x %struct.scan_t] addrspace(2)* @scan_scan_intervals_lev1.psc_ldata, i64 0, i64
1) to i6</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>