<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/source/slang/slang-ir-variable-scope-correction.cpp, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2025-01-27T18:58:01+00:00</updated>
<entry>
<title>Fix an incorrect iteration with a workList (#6177)</title>
<updated>2025-01-27T18:58:01+00:00</updated>
<author>
<name>Jay Kwak</name>
<email>82421531+jkwak-work@users.noreply.github.com</email>
</author>
<published>2025-01-27T18:58:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=da3dc98f96cc7be2accb5c6f86aa6f6e5502bada'/>
<id>urn:sha1:da3dc98f96cc7be2accb5c6f86aa6f6e5502bada</id>
<content type='text'>
* Fix an incorrect iteration with a workList

We cannot modify workList while iterating it, because its type `List` is
actually an array container.

* Change based on the feedback

* Use `Index` instead of `int` for for-loop index

---------

Co-authored-by: Yong He &lt;yonghe@outlook.com&gt;</content>
</entry>
<entry>
<title>Move switch statement bodies to their own lines (#5493)</title>
<updated>2024-11-05T17:47:26+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2024-11-05T17:47:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=b118451e301d734e3e783b3acdf871f3f6ea851c'/>
<id>urn:sha1:b118451e301d734e3e783b3acdf871f3f6ea851c</id>
<content type='text'>
* Move switch statement bodies to their own lines

* format

---------

Co-authored-by: Yong He &lt;yonghe@outlook.com&gt;</content>
</entry>
<entry>
<title>format</title>
<updated>2024-10-29T06:49:26+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2024-10-29T06:49:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21'/>
<id>urn:sha1:f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21</id>
<content type='text'>
* format

* Minor test fixes

* enable checking cpp format in ci</content>
</entry>
<entry>
<title>WIP: Fix the variable scope issue (#3838) (#3892)</title>
<updated>2024-04-12T02:37:44+00:00</updated>
<author>
<name>kaizhangNV</name>
<email>149626564+kaizhangNV@users.noreply.github.com</email>
</author>
<published>2024-04-12T02:37:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=2a5d126c32d459c9ed6cec005b2a4351e18ed04b'/>
<id>urn:sha1:2a5d126c32d459c9ed6cec005b2a4351e18ed04b</id>
<content type='text'>
* Fix the variable scope issue (#3838)

In the IR optimization pass, we turn all the loop to do-while loop form.
But in the do-while loop form, the loop body block is dominating the
blocks after the loop break block. This assumption is fine for SPIRV and
IR code, however, it's incorrect for all the other language target (e.g.
c/c++/cuda/glsl/hlsl) because the instructions defined in the loop body
is invisible from outside of the loop. Therefore, when translating to
other textual language, there could be issue for the variables scope.

To fix this issue, we first detect the instructions that are defined
inside the loop block, then check if these instructions are used after
the break block. If so, we duplicate these instructions right before
their users such that we can make those instructions available globally.

* Update slang vcxproj file because of add new source files

* Minor fix

- Update the method to get the block of an instruction
- Avoid query the hash-map twice by using "add" method directly.

* Reduce complexity

In searching loop region blocks, we don't actually need to traverse the
instructions. Instead, we only have to check each block to see if it's
in a loop region, and hash such block for later on processing.
So we can remove one level of loop.

In the second pass, we can use that hash to filter out the blocks that
are not in the loop region, and only process the instructions inside the
loop region.

Add description for the new fix-up pass declared in
slang-ir-variable-scope-correction.h.

* Categorize the unstorable and storable instructs

1. When checking the loop regions, there could be multi-levels nested
   loops, so we should use a list to store the loopHeaders.

2. Categorize the instructs based on storable and non-storable, because
   we only have to duplicate the non-storable instructs. Note pointer
   type instruct is also belonged to non-storable class because we can
   not store a pointer in local variable.

* Fix some test failure

* Fix test failures

* Recursively process the operands

Besides process the out-of-scope instruction, we have to also process
all the operands of this instructions. Therefore, we have to make the
process logic recursive until all the involved instructions are
accessible.

* Change how to check storable type

* Add target checking for CPP/CUDA

In decide whether the type is storable, add target checking for CPP/CUDA
as they can store any types.

Cleanup the code to remove those debug log prints.

* Addressing feedbacks

Address some feedbacks.

Change the depth-first traverse to breadth-first traverse when
processing instruction and its operands.

* Minor fix for the variable names</content>
</entry>
</feed>
