<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/139023>139023</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[DirectX] Validator is erroring with Internal declaration '.*' is unused
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:DirectX
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
farzonl
</td>
</tr>
</table>
<pre>
Three examples. In all three its happeing on array flattened values.
```
96x error: Internal declaration 'bTile.scalarized.1dim' is unused.
64x error: Internal declaration 'aTile.1dim' is unused.
32x error: Internal declaration 'aTile.scalarized.1dim' is unused.
```
Its curious that there was anything to flatten in these cases since we flatten after optimizations. I suspect these two types were used in a function that was cleaned up by Finalize Linkage but the global lived on.
looking at:
```bash
clang-dxc DirectML/Product/Shaders/Generated/ConvolutionIntegerFastPathShortGemm4_int_TRUE.hlsl -E CSMain -T cs_6_4 -enable-16bit-types -O3 -D DXC_COMPILER=1 -D __SHADER_TARGET_MAJOR=6 -D __SHADER_TARGET_MINOR=4 -I DirectML/Product/Shaders/
```
I see these two and they are defined but not used. We should probably delete them if this is the case.
@aTile.1dim = local_unnamed_addr addrspace(3) global [64 x i32] zeroinitializer, align 4
@bTile.scalarized.1dim = local_unnamed_addr addrspace(3) global [512 x i32] zeroinitializer, align 4
We could add a check for uses to both [DXILDataScalarization.cpp](https://github.com/llvm/llvm-project/blob/c7f350f1428df14e3114977b830ab4dcd3008983/llvm/lib/Target/DirectX/DXILDataScalarization.cpp) and [DXILFlattenArrays.cpp](https://github.com/llvm/llvm-project/blob/c7f350f1428df14e3114977b830ab4dcd3008983/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp). If there are no uses then we just delete and don't do transformations.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVU1v4zYQ_TX0ZWBBomTZOvigjeKti6S7SNzu3owRObK4oUmBpJI4v76g4uwHmsWmPRUQElv0PM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