[ir] Allow setting the string for when the transform is run

When dumping IR validation, instead of always saying `before` all the
transform to set it's own string. This is done by the `spirv.Lower`
transform which does the validation after it's finished.

Change-Id: I4a656a2e7333fc55a2ec30c397a66680b3cf2641
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/241114
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/lang/core/ir/validator.cc b/src/tint/lang/core/ir/validator.cc
index 5a21d64..f8ee718 100644
--- a/src/tint/lang/core/ir/validator.cc
+++ b/src/tint/lang/core/ir/validator.cc
@@ -3796,11 +3796,12 @@
 
 Result<SuccessType> ValidateAndDumpIfNeeded([[maybe_unused]] const Module& ir,
                                             [[maybe_unused]] const char* msg,
-                                            [[maybe_unused]] Capabilities capabilities) {
+                                            [[maybe_unused]] Capabilities capabilities,
+                                            [[maybe_unused]] std::string_view timing) {
 #if TINT_DUMP_IR_WHEN_VALIDATING
     auto printer = StyledTextPrinter::Create(stdout);
     std::cout << "=========================================================\n";
-    std::cout << "== IR dump before " << msg << ":\n";
+    std::cout << "== IR dump " << timing << " " << msg << ":\n";
     std::cout << "=========================================================\n";
     printer->Print(Disassembler(ir).Text());
 #endif
diff --git a/src/tint/lang/core/ir/validator.h b/src/tint/lang/core/ir/validator.h
index 5cab735..b7efa1d 100644
--- a/src/tint/lang/core/ir/validator.h
+++ b/src/tint/lang/core/ir/validator.h
@@ -85,10 +85,12 @@
 /// @param ir the module to transform
 /// @param msg the msg to accompany the output
 /// @param capabilities the optional capabilities that are allowed
+/// @param timing when the validation is run.
 /// @returns success or failure
 Result<SuccessType> ValidateAndDumpIfNeeded(const Module& ir,
                                             const char* msg,
-                                            Capabilities capabilities = {});
+                                            Capabilities capabilities = {},
+                                            std::string_view timing = "before");
 
 }  // namespace tint::core::ir
 
diff --git a/src/tint/lang/spirv/reader/lower/lower.cc b/src/tint/lang/spirv/reader/lower/lower.cc
index 12bd35e..4870fbe 100644
--- a/src/tint/lang/spirv/reader/lower/lower.cc
+++ b/src/tint/lang/spirv/reader/lower/lower.cc
@@ -63,7 +63,8 @@
     auto res = core::ir::ValidateAndDumpIfNeeded(mod, "spirv.Lower",
                                                  core::ir::Capabilities{
                                                      core::ir::Capability::kAllowOverrides,
-                                                 });
+                                                 },
+                                                 "after");
     if (res != Success) {
         return res.Failure();
     }