[tint][ir][ToProgram] Handle shadowing.

Change the ir::Module naming methods to allow for duplicate names.

Change the ir::Disassembler to ensure that IDs are uniquely named.
If the disassembler has an ID that does not match the value's
name, then a new comment is appended to the end of the instruction
with the value's ID and name.

Add a new RenameConflictsWGSL transform that renames declarations
which prevent identifiers from resolving to the correct
declaration, and those with identical identifiers declared in the
same scope.

This fixes all the known issues with shadowing which the
roundtrip fuzzer uncovered.

Change-Id: Ib3c3df8093863a9917c201ca6ee8c958a4ada6dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/141321
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index 94abddc..668dc13 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -860,6 +860,8 @@
     ir/transform/block_decorated_structs.h
     ir/transform/demote_to_helper.cc
     ir/transform/demote_to_helper.h
+    ir/transform/rename_conflicts_wgsl.cc
+    ir/transform/rename_conflicts_wgsl.h
     ir/transform/shader_io.cc
     ir/transform/shader_io.h
     ir/transform/transform.cc
@@ -1365,6 +1367,12 @@
         lang/spirv/writer/var_test.cc
         lang/spirv/writer/writer_test.cc
       )
+
+      if (${TINT_BUILD_WGSL_WRITER})
+        list(APPEND TINT_TEST_SRCS
+          ir/transform/rename_conflicts_wgsl_test.cc
+        )
+      endif()
     endif()
   endif()