[webkit-changes] [WebKit/WebKit] 7687bb: [WGSL] GlobalRewriter reads and defs shouldn't lea...

Tadeu Zagallo noreply at github.com
Tue Jun 6 23:57:17 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7687bb2974f4423c83cdfa0a8fd6e1df48fa4678
      https://github.com/WebKit/WebKit/commit/7687bb2974f4423c83cdfa0a8fd6e1df48fa4678
  Author: Tadeu Zagallo <tzagallo at apple.com>
  Date:   2023-06-06 (Tue, 06 Jun 2023)

  Changed paths:
    M Source/WebGPU/WGSL/GlobalVariableRewriter.cpp
    M Source/WebGPU/WGSL/tests/valid/global-used-by-callee.wgsl

  Log Message:
  -----------
  [WGSL] GlobalRewriter reads and defs shouldn't leak between callees
https://bugs.webkit.org/show_bug.cgi?id=257715
rdar://110264659

Reviewed by Myles C. Maxfield.

The global rewriter was only cleaning reads and defs in between different entry
points, but that's not correct. As a result, two subsequent calls, e.g. `f(); g()`,
would cause the globals read by `f` to also be passed to `g` and variables defined
in `f` to shadow globals used in `g`. To fix that we need to clean defs on every
function, since they are local to a function (not an entrypoint), and reads have
to be computed individually per calle and then merged in the caller, since the
caller needs all globals used by its callees in order to propagate it down.

* Source/WebGPU/WGSL/GlobalVariableRewriter.cpp:
(WGSL::RewriteGlobalVariables::run):
(WGSL::RewriteGlobalVariables::visitCallee):
(WGSL::RewriteGlobalVariables::visit):
(WGSL::RewriteGlobalVariables::collectGlobals):
(WGSL::RewriteGlobalVariables::visitEntryPoint):
(WGSL::RewriteGlobalVariables::def):
(WGSL::RewriteGlobalVariables::readVariable):
* Source/WebGPU/WGSL/tests/valid/global-used-by-callee.wgsl:

Canonical link: https://commits.webkit.org/264927@main




More information about the webkit-changes mailing list