<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>197448</bug_id>
          
          <creation_ts>2019-04-30 17:46:51 -0700</creation_ts>
          <short_desc>[WHLSL] Cannot assign through pointers</short_desc>
          <delta_ts>2019-05-31 09:12:13 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebGPU</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>198198</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P1</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>195925</dependson>
          <blocked>198399</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Myles C. Maxfield">mmaxfield</reporter>
          <assigned_to name="Saam Barati">saam</assigned_to>
          <cc>justin_fan</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1531808</commentid>
    <comment_count>0</comment_count>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2019-04-30 17:46:51 -0700</bug_when>
    <thetext>Consider the following WHLSL statement:

*x = y;

When we compile this, we naively turn this into

auto temp1 = *x;
temp1 = y;

This doesn&apos;t actually assign through the pointer, instead it just reassigns a temporary

The WHLSLFunctionWriter needs to be smart enough to understand how to emit code that assigns through a pointer. We also need to determine which situations it needs to be made smarter about.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1531815</commentid>
    <comment_count>1</comment_count>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2019-04-30 17:58:28 -0700</bug_when>
    <thetext>It looks like after the property resolver runs, lvalues can only be either variable references or dereference expressions. Assigning to a variable reference will just work, so it looks like we only need to special case assigning to a dereference expression. Also, we shouldn&apos;t need to go digging through the AST; we can just handle the outermost dereference expression.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1531817</commentid>
    <comment_count>2</comment_count>
      <attachid>368638</attachid>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2019-04-30 18:08:54 -0700</bug_when>
    <thetext>Created attachment 368638
WIP</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1535878</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-05-13 17:07:32 -0700</bug_when>
    <thetext>&lt;rdar://problem/50746281&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1535928</commentid>
    <comment_count>4</comment_count>
      <attachid>368638</attachid>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2019-05-13 19:30:47 -0700</bug_when>
    <thetext>Comment on attachment 368638
WIP

View in context: https://bugs.webkit.org/attachment.cgi?id=368638&amp;action=review

&gt; Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp:495
&gt; +        m_stack.append(rightName);

This &quot;if&quot; block needs a return.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1538466</commentid>
    <comment_count>5</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2019-05-22 16:42:47 -0700</bug_when>
    <thetext>Myles is doing the WIP here in the property resolver patch. The only question we need to answer is if there are other areas where this matters?

Maybe things to consider:
*p++, etc

These should probably be desugared though. Need to verify</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1540647</commentid>
    <comment_count>6</comment_count>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2019-05-30 22:53:30 -0700</bug_when>
    <thetext>This is needed for https://bugs.webkit.org/show_bug.cgi?id=198399.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1540648</commentid>
    <comment_count>7</comment_count>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2019-05-30 22:54:17 -0700</bug_when>
    <thetext>void FunctionDefinitionWriter::visit(AST::DereferenceExpression&amp; dereferenceExpression)
{
    checkErrorAndVisit(dereferenceExpression.pointer());
    auto right = m_stack.takeLast();
    auto variableName = generateNextVariableName();
    m_stringBuilder.append(makeString(AST::toString(*dereferenceExpression.typeAnnotation().leftAddressSpace()), &apos; &apos;, m_typeNamer.mangledNameForType(dereferenceExpression.resolvedType()), &quot;&amp; &quot;, variableName, &quot; = *&quot;, right, &quot;;\n&quot;));
    m_stack.append(variableName);
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1540677</commentid>
    <comment_count>8</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2019-05-31 01:57:26 -0700</bug_when>
    <thetext>(In reply to Myles C. Maxfield from comment #6)
&gt; This is needed for https://bugs.webkit.org/show_bug.cgi?id=198399.

Maybe you were running into the &quot;&amp;*x&quot; problem? I also ran into this issue while trying to test the zero filling code. I took your change and turned it into a patch with a test here:
https://bugs.webkit.org/show_bug.cgi?id=198198</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1540730</commentid>
    <comment_count>9</comment_count>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2019-05-31 09:12:13 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 198198 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>368638</attachid>
            <date>2019-04-30 18:08:54 -0700</date>
            <delta_ts>2019-05-30 22:58:22 -0700</delta_ts>
            <desc>WIP</desc>
            <filename>file.txt</filename>
            <type>text/plain</type>
            <size>1391</size>
            <attacher name="Myles C. Maxfield">mmax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