[ir] Use FriendlyName for instructions

This CL updates the disassembler to use the FriendlyName for the
instruction name. Several instructions are updated to use their
contained intrinsics or builtins to form the friendly name.

Bug: tint:1718
Change-Id: Ie3df13aefc770f9ba8314acb1b1b3e86b6fb7233
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/150101
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/core/ir/access.h b/src/tint/lang/core/ir/access.h
index 1afdceb..4c76121 100644
--- a/src/tint/lang/core/ir/access.h
+++ b/src/tint/lang/core/ir/access.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_ACCESS_H_
 #define SRC_TINT_LANG_CORE_IR_ACCESS_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/operand_instruction.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -47,7 +49,7 @@
     tint::Slice<Value*> Indices() { return operands_.Slice().Offset(kIndicesOperandOffset); }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "access"; }
+    std::string FriendlyName() override { return "access"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/binary.h b/src/tint/lang/core/ir/binary.h
index f70b1a4..53ddf1a 100644
--- a/src/tint/lang/core/ir/binary.h
+++ b/src/tint/lang/core/ir/binary.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_BINARY_H_
 #define SRC_TINT_LANG_CORE_IR_BINARY_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/operand_instruction.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -70,7 +72,7 @@
     Value* RHS() { return operands_[kRhsOperandOffset]; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "binary"; }
+    std::string FriendlyName() override { return "binary"; }
 
   private:
     enum Kind kind_;
diff --git a/src/tint/lang/core/ir/bitcast.h b/src/tint/lang/core/ir/bitcast.h
index 57355c7..d5f7425 100644
--- a/src/tint/lang/core/ir/bitcast.h
+++ b/src/tint/lang/core/ir/bitcast.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_BITCAST_H_
 #define SRC_TINT_LANG_CORE_IR_BITCAST_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/call.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -36,7 +38,7 @@
     Value* Val() { return operands_[kValueOperandOffset]; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "bitcast"; }
+    std::string FriendlyName() override { return "bitcast"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/break_if.h b/src/tint/lang/core/ir/break_if.h
index 341bc70..1f73c2f 100644
--- a/src/tint/lang/core/ir/break_if.h
+++ b/src/tint/lang/core/ir/break_if.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_BREAK_IF_H_
 #define SRC_TINT_LANG_CORE_IR_BREAK_IF_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/terminator.h"
 #include "src/tint/lang/core/ir/value.h"
 #include "src/tint/utils/rtti/castable.h"
@@ -54,7 +56,7 @@
     ir::Loop* Loop() { return loop_; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "break-if"; }
+    std::string FriendlyName() override { return "break_if"; }
 
   private:
     ir::Loop* loop_ = nullptr;
diff --git a/src/tint/lang/core/ir/construct.h b/src/tint/lang/core/ir/construct.h
index e56fd48..61c9a76 100644
--- a/src/tint/lang/core/ir/construct.h
+++ b/src/tint/lang/core/ir/construct.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_CONSTRUCT_H_
 #define SRC_TINT_LANG_CORE_IR_CONSTRUCT_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/call.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -33,7 +35,7 @@
     ~Construct() override;
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "construct"; }
+    std::string FriendlyName() override { return "construct"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/continue.h b/src/tint/lang/core/ir/continue.h
index 0c8f8b1..1c393e1 100644
--- a/src/tint/lang/core/ir/continue.h
+++ b/src/tint/lang/core/ir/continue.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_CONTINUE_H_
 #define SRC_TINT_LANG_CORE_IR_CONTINUE_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/terminator.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -41,7 +43,7 @@
     ir::Loop* Loop() { return loop_; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "continue"; }
+    std::string FriendlyName() override { return "continue"; }
 
   private:
     ir::Loop* loop_ = nullptr;
diff --git a/src/tint/lang/core/ir/convert.h b/src/tint/lang/core/ir/convert.h
index e9bfa44..1c58228 100644
--- a/src/tint/lang/core/ir/convert.h
+++ b/src/tint/lang/core/ir/convert.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_CONVERT_H_
 #define SRC_TINT_LANG_CORE_IR_CONVERT_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/call.h"
 #include "src/tint/lang/core/type/type.h"
 #include "src/tint/utils/rtti/castable.h"
@@ -34,7 +36,7 @@
     ~Convert() override;
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "convert"; }
+    std::string FriendlyName() override { return "convert"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/core_builtin_call.h b/src/tint/lang/core/ir/core_builtin_call.h
index b9e1f4b..a0e05ff 100644
--- a/src/tint/lang/core/ir/core_builtin_call.h
+++ b/src/tint/lang/core/ir/core_builtin_call.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_CORE_BUILTIN_CALL_H_
 #define SRC_TINT_LANG_CORE_IR_CORE_BUILTIN_CALL_H_
 
+#include <string>
+
 #include "src/tint/lang/core/function.h"
 #include "src/tint/lang/core/ir/builtin_call.h"
 #include "src/tint/utils/rtti/castable.h"
@@ -37,7 +39,7 @@
     core::Function Func() { return func_; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "core-builtin-call"; }
+    std::string FriendlyName() override { return core::str(func_); }
 
   private:
     core::Function func_;
diff --git a/src/tint/lang/core/ir/disassembler.cc b/src/tint/lang/core/ir/disassembler.cc
index 7c3519e..5a9d29c 100644
--- a/src/tint/lang/core/ir/disassembler.cc
+++ b/src/tint/lang/core/ir/disassembler.cc
@@ -423,9 +423,9 @@
         });
 }
 
-void Disassembler::EmitInstructionName(std::string_view name, Instruction* inst) {
+void Disassembler::EmitInstructionName(Instruction* inst) {
     SourceMarker sm(this);
-    out_ << name;
+    out_ << inst->FriendlyName();
     sm.Store(inst);
 }
 
@@ -445,74 +445,23 @@
         [&](Loop* l) { EmitLoop(l); },      //
         [&](Binary* b) { EmitBinary(b); },  //
         [&](Unary* u) { EmitUnary(u); },    //
-        [&](Bitcast* b) {
-            EmitValueWithType(b);
-            out_ << " = ";
-            EmitInstructionName("bitcast", b);
-            out_ << " ";
-            EmitOperandList(b);
-        },
-        [&](Discard* d) { EmitInstructionName("discard", d); },
-        [&](CoreBuiltinCall* b) {
-            EmitValueWithType(b);
-            out_ << " = ";
-            EmitInstructionName(core::str(b->Func()), b);
-            out_ << " ";
-            EmitOperandList(b);
-        },
-        [&](Construct* c) {
-            EmitValueWithType(c);
-            out_ << " = ";
-            EmitInstructionName("construct", c);
-            if (!c->Operands().IsEmpty()) {
-                out_ << " ";
-                EmitOperandList(c);
-            }
-        },
-        [&](Convert* c) {
-            EmitValueWithType(c);
-            out_ << " = ";
-            EmitInstructionName("convert", c);
-            out_ << " ";
-            EmitOperandList(c);
-        },
-        [&](IntrinsicCall* i) {
-            EmitValueWithType(i);
-            out_ << " = ";
-            EmitInstructionName(i->KindName(), i);
-            out_ << " ";
-            EmitOperandList(i);
-        },
-        [&](Load* l) {
-            EmitValueWithType(l);
-            out_ << " = ";
-            EmitInstructionName("load", l);
-            out_ << " ";
-            EmitValue(l->From());
-        },
+        [&](Discard* d) { EmitInstructionName(d); },
         [&](Store* s) {
-            EmitInstructionName("store", s);
+            EmitInstructionName(s);
             out_ << " ";
             EmitValue(s->To());
             out_ << ", ";
             EmitValue(s->From());
         },
-        [&](LoadVectorElement* l) {
-            EmitValueWithType(l);
-            out_ << " = ";
-            EmitInstructionName("load_vector_element", l);
-            out_ << " ";
-            EmitOperandList(l);
-        },
         [&](StoreVectorElement* s) {
-            EmitInstructionName("store_vector_element", s);
+            EmitInstructionName(s);
             out_ << " ";
             EmitOperandList(s);
         },
         [&](UserCall* uc) {
             EmitValueWithType(uc);
             out_ << " = ";
-            EmitInstructionName("call", uc);
+            EmitInstructionName(uc);
             out_ << " %" << IdOf(uc->Func());
             if (!uc->Args().IsEmpty()) {
                 out_ << ", ";
@@ -522,7 +471,7 @@
         [&](Var* v) {
             EmitValueWithType(v);
             out_ << " = ";
-            EmitInstructionName("var", v);
+            EmitInstructionName(v);
             if (v->Initializer()) {
                 out_ << ", ";
                 EmitOperand(v, Var::kInitializerOperandOffset);
@@ -532,24 +481,10 @@
                 EmitBindingPoint(v->BindingPoint().value());
             }
         },
-        [&](Let* l) {
-            EmitValueWithType(l);
-            out_ << " = ";
-            EmitInstructionName("let", l);
-            out_ << " ";
-            EmitOperandList(l);
-        },
-        [&](Access* a) {
-            EmitValueWithType(a);
-            out_ << " = ";
-            EmitInstructionName("access", a);
-            out_ << " ";
-            EmitOperandList(a);
-        },
         [&](Swizzle* s) {
             EmitValueWithType(s);
             out_ << " = ";
-            EmitInstructionName("swizzle", s);
+            EmitInstructionName(s);
             out_ << " ";
             EmitValue(s->Object());
             out_ << ", ";
@@ -571,7 +506,15 @@
             }
         },
         [&](Terminator* b) { EmitTerminator(b); },
-        [&](Default) { out_ << "Unknown instruction: " << inst->TypeInfo().name; });
+        [&](Default) {
+            EmitValueWithType(inst);
+            out_ << " = ";
+            EmitInstructionName(inst);
+            if (!inst->Operands().IsEmpty()) {
+                out_ << " ";
+                EmitOperandList(inst);
+            }
+        });
 
     {  // Add a comment if the result IDs don't match their names
         Vector<std::string, 4> names;
diff --git a/src/tint/lang/core/ir/disassembler.h b/src/tint/lang/core/ir/disassembler.h
index e29a857..bb0bd44 100644
--- a/src/tint/lang/core/ir/disassembler.h
+++ b/src/tint/lang/core/ir/disassembler.h
@@ -144,7 +144,7 @@
     void EmitLine();
     void EmitOperand(Instruction* inst, size_t index);
     void EmitOperandList(Instruction* inst, size_t start_index = 0);
-    void EmitInstructionName(std::string_view name, Instruction* inst);
+    void EmitInstructionName(Instruction* inst);
 
     Module& mod_;
     StringStream out_;
diff --git a/src/tint/lang/core/ir/discard.h b/src/tint/lang/core/ir/discard.h
index 2fb03e0..b98c753 100644
--- a/src/tint/lang/core/ir/discard.h
+++ b/src/tint/lang/core/ir/discard.h
@@ -15,8 +15,9 @@
 #ifndef SRC_TINT_LANG_CORE_IR_DISCARD_H_
 #define SRC_TINT_LANG_CORE_IR_DISCARD_H_
 
-#include "src/tint/lang/core/ir/call.h"
+#include <string>
 
+#include "src/tint/lang/core/ir/call.h"
 #include "src/tint/utils/rtti/castable.h"
 
 namespace tint::core::ir {
@@ -29,7 +30,7 @@
     ~Discard() override;
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "discard"; }
+    std::string FriendlyName() override { return "discard"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/exit_if.h b/src/tint/lang/core/ir/exit_if.h
index 24f97b3..31e6d55 100644
--- a/src/tint/lang/core/ir/exit_if.h
+++ b/src/tint/lang/core/ir/exit_if.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_EXIT_IF_H_
 #define SRC_TINT_LANG_CORE_IR_EXIT_IF_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/exit.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -45,7 +47,7 @@
     ir::If* If();
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "exit-if"; }
+    std::string FriendlyName() override { return "exit_if"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/exit_loop.h b/src/tint/lang/core/ir/exit_loop.h
index 5212262..6e173df 100644
--- a/src/tint/lang/core/ir/exit_loop.h
+++ b/src/tint/lang/core/ir/exit_loop.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_EXIT_LOOP_H_
 #define SRC_TINT_LANG_CORE_IR_EXIT_LOOP_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/exit.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -45,7 +47,7 @@
     ir::Loop* Loop();
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "exit-loop"; }
+    std::string FriendlyName() override { return "exit_loop"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/exit_switch.h b/src/tint/lang/core/ir/exit_switch.h
index 80e2a54..45a2733 100644
--- a/src/tint/lang/core/ir/exit_switch.h
+++ b/src/tint/lang/core/ir/exit_switch.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_EXIT_SWITCH_H_
 #define SRC_TINT_LANG_CORE_IR_EXIT_SWITCH_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/exit.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -45,7 +47,7 @@
     ir::Switch* Switch();
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "exit-switch"; }
+    std::string FriendlyName() override { return "exit_switch"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/if.h b/src/tint/lang/core/ir/if.h
index 1c852df..aa68508 100644
--- a/src/tint/lang/core/ir/if.h
+++ b/src/tint/lang/core/ir/if.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_IF_H_
 #define SRC_TINT_LANG_CORE_IR_IF_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/control_instruction.h"
 
 // Forward declarations
@@ -65,7 +67,7 @@
     ir::Block* False() { return false_; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "if"; }
+    std::string FriendlyName() override { return "if"; }
 
   private:
     ir::Block* true_ = nullptr;
diff --git a/src/tint/lang/core/ir/instruction.h b/src/tint/lang/core/ir/instruction.h
index 192b4d7..d2503d2 100644
--- a/src/tint/lang/core/ir/instruction.h
+++ b/src/tint/lang/core/ir/instruction.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_INSTRUCTION_H_
 #define SRC_TINT_LANG_CORE_IR_INSTRUCTION_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/instruction_result.h"
 #include "src/tint/lang/core/ir/value.h"
 #include "src/tint/utils/containers/enum_set.h"
@@ -58,7 +60,7 @@
     virtual void Destroy();
 
     /// @returns the friendly name for the instruction
-    virtual std::string_view FriendlyName() = 0;
+    virtual std::string FriendlyName() = 0;
 
     /// @returns true if the Instruction has not been destroyed with Destroy()
     bool Alive() const { return !flags_.Contains(Flag::kDead); }
diff --git a/src/tint/lang/core/ir/intrinsic_call.h b/src/tint/lang/core/ir/intrinsic_call.h
index 2c902b2..175d902 100644
--- a/src/tint/lang/core/ir/intrinsic_call.h
+++ b/src/tint/lang/core/ir/intrinsic_call.h
@@ -33,9 +33,6 @@
     /// @param args the intrinsic call arguments
     explicit IntrinsicCall(InstructionResult* result, VectorRef<Value*> args = tint::Empty);
     ~IntrinsicCall() override;
-
-    /// @returns the intrinsic name
-    virtual std::string KindName() const = 0;
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/let.h b/src/tint/lang/core/ir/let.h
index 51fd71b..5c0355b 100644
--- a/src/tint/lang/core/ir/let.h
+++ b/src/tint/lang/core/ir/let.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_LET_H_
 #define SRC_TINT_LANG_CORE_IR_LET_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/operand_instruction.h"
 
 namespace tint::core::ir {
@@ -35,7 +37,7 @@
     ir::Value* Value() { return operands_[kValueOperandOffset]; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "let"; }
+    std::string FriendlyName() override { return "let"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/load.h b/src/tint/lang/core/ir/load.h
index ec969d1..55fb983 100644
--- a/src/tint/lang/core/ir/load.h
+++ b/src/tint/lang/core/ir/load.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_LOAD_H_
 #define SRC_TINT_LANG_CORE_IR_LOAD_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/operand_instruction.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -37,7 +39,7 @@
     Value* From() { return operands_[kFromOperandOffset]; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "load"; }
+    std::string FriendlyName() override { return "load"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/load_vector_element.h b/src/tint/lang/core/ir/load_vector_element.h
index f66018e..cd7e206 100644
--- a/src/tint/lang/core/ir/load_vector_element.h
+++ b/src/tint/lang/core/ir/load_vector_element.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_LOAD_VECTOR_ELEMENT_H_
 #define SRC_TINT_LANG_CORE_IR_LOAD_VECTOR_ELEMENT_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/operand_instruction.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -43,7 +45,7 @@
     ir::Value* Index() { return operands_[kIndexOperandOffset]; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "load-vector-element"; }
+    std::string FriendlyName() override { return "load_vector_element"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/loop.h b/src/tint/lang/core/ir/loop.h
index 79547b6..689b9e2 100644
--- a/src/tint/lang/core/ir/loop.h
+++ b/src/tint/lang/core/ir/loop.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_LOOP_H_
 #define SRC_TINT_LANG_CORE_IR_LOOP_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/control_instruction.h"
 
 // Forward declarations
@@ -80,7 +82,7 @@
     ir::MultiInBlock* Continuing() { return continuing_; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "loop"; }
+    std::string FriendlyName() override { return "loop"; }
 
   private:
     ir::Block* initializer_ = nullptr;
diff --git a/src/tint/lang/core/ir/next_iteration.h b/src/tint/lang/core/ir/next_iteration.h
index 2489232..87de579 100644
--- a/src/tint/lang/core/ir/next_iteration.h
+++ b/src/tint/lang/core/ir/next_iteration.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_NEXT_ITERATION_H_
 #define SRC_TINT_LANG_CORE_IR_NEXT_ITERATION_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/terminator.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -41,7 +43,7 @@
     ir::Loop* Loop() { return loop_; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "next-iteration"; }
+    std::string FriendlyName() override { return "next_iteration"; }
 
   private:
     ir::Loop* loop_ = nullptr;
diff --git a/src/tint/lang/core/ir/return.h b/src/tint/lang/core/ir/return.h
index 883f427..f44b284 100644
--- a/src/tint/lang/core/ir/return.h
+++ b/src/tint/lang/core/ir/return.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_RETURN_H_
 #define SRC_TINT_LANG_CORE_IR_RETURN_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/terminator.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -63,7 +65,7 @@
     }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "return"; }
+    std::string FriendlyName() override { return "return"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/store.h b/src/tint/lang/core/ir/store.h
index 7da1d7e..924a6b8 100644
--- a/src/tint/lang/core/ir/store.h
+++ b/src/tint/lang/core/ir/store.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_STORE_H_
 #define SRC_TINT_LANG_CORE_IR_STORE_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/operand_instruction.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -42,7 +44,7 @@
     Value* From() { return operands_[kFromOperandOffset]; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "store"; }
+    std::string FriendlyName() override { return "store"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/store_vector_element.h b/src/tint/lang/core/ir/store_vector_element.h
index 7e8f4fc..a4b31a8 100644
--- a/src/tint/lang/core/ir/store_vector_element.h
+++ b/src/tint/lang/core/ir/store_vector_element.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_STORE_VECTOR_ELEMENT_H_
 #define SRC_TINT_LANG_CORE_IR_STORE_VECTOR_ELEMENT_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/operand_instruction.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -49,7 +51,7 @@
     ir::Value* Value() { return operands_[kValueOperandOffset]; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "store-vector-element"; }
+    std::string FriendlyName() override { return "store_vector_element"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/switch.h b/src/tint/lang/core/ir/switch.h
index 120c860..1b450ac 100644
--- a/src/tint/lang/core/ir/switch.h
+++ b/src/tint/lang/core/ir/switch.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_SWITCH_H_
 #define SRC_TINT_LANG_CORE_IR_SWITCH_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/control_instruction.h"
 
 // Forward declarations
@@ -81,7 +83,7 @@
     Value* Condition() { return operands_[kConditionOperandOffset]; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "switch"; }
+    std::string FriendlyName() override { return "switch"; }
 
   private:
     Vector<Case, 4> cases_;
diff --git a/src/tint/lang/core/ir/swizzle.h b/src/tint/lang/core/ir/swizzle.h
index 6632515..48a838e 100644
--- a/src/tint/lang/core/ir/swizzle.h
+++ b/src/tint/lang/core/ir/swizzle.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_SWIZZLE_H_
 #define SRC_TINT_LANG_CORE_IR_SWIZZLE_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/operand_instruction.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -40,7 +42,7 @@
     VectorRef<uint32_t> Indices() { return indices_; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "swizzle"; }
+    std::string FriendlyName() override { return "swizzle"; }
 
   private:
     Vector<uint32_t, 4> indices_;
diff --git a/src/tint/lang/core/ir/terminate_invocation.h b/src/tint/lang/core/ir/terminate_invocation.h
index 60fa964..8edf03e 100644
--- a/src/tint/lang/core/ir/terminate_invocation.h
+++ b/src/tint/lang/core/ir/terminate_invocation.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_TERMINATE_INVOCATION_H_
 #define SRC_TINT_LANG_CORE_IR_TERMINATE_INVOCATION_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/terminator.h"
 
 namespace tint::core::ir {
@@ -25,7 +27,7 @@
     ~TerminateInvocation() override;
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "terminate-invocation"; }
+    std::string FriendlyName() override { return "terminate_invocation"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/unary.h b/src/tint/lang/core/ir/unary.h
index 4013c47..2e55cc3 100644
--- a/src/tint/lang/core/ir/unary.h
+++ b/src/tint/lang/core/ir/unary.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_UNARY_H_
 #define SRC_TINT_LANG_CORE_IR_UNARY_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/operand_instruction.h"
 #include "src/tint/utils/rtti/castable.h"
 
@@ -46,7 +48,7 @@
     enum Kind Kind() { return kind_; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "unary"; }
+    std::string FriendlyName() override { return "unary"; }
 
   private:
     enum Kind kind_;
diff --git a/src/tint/lang/core/ir/unreachable.h b/src/tint/lang/core/ir/unreachable.h
index 97d052e..fd92538 100644
--- a/src/tint/lang/core/ir/unreachable.h
+++ b/src/tint/lang/core/ir/unreachable.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_UNREACHABLE_H_
 #define SRC_TINT_LANG_CORE_IR_UNREACHABLE_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/terminator.h"
 
 namespace tint::core::ir {
@@ -25,7 +27,7 @@
     ~Unreachable() override;
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "unreachable"; }
+    std::string FriendlyName() override { return "unreachable"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/user_call.h b/src/tint/lang/core/ir/user_call.h
index ed0f9eb..58a381f 100644
--- a/src/tint/lang/core/ir/user_call.h
+++ b/src/tint/lang/core/ir/user_call.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_USER_CALL_H_
 #define SRC_TINT_LANG_CORE_IR_USER_CALL_H_
 
+#include <string>
+
 #include "src/tint/lang/core/ir/call.h"
 #include "src/tint/lang/core/ir/function.h"
 #include "src/tint/utils/rtti/castable.h"
@@ -44,7 +46,7 @@
     Function* Func() { return operands_[kFunctionOperandOffset]->As<ir::Function>(); }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "user-call"; }
+    std::string FriendlyName() override { return "call"; }
 };
 
 }  // namespace tint::core::ir
diff --git a/src/tint/lang/core/ir/validator_test.cc b/src/tint/lang/core/ir/validator_test.cc
index 7d09e7b..52aad79 100644
--- a/src/tint/lang/core/ir/validator_test.cc
+++ b/src/tint/lang/core/ir/validator_test.cc
@@ -1267,7 +1267,7 @@
 
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
-    EXPECT_EQ(res.Failure().str(), R"(:5:9 error: exit-if: has no parent control instruction
+    EXPECT_EQ(res.Failure().str(), R"(:5:9 error: exit_if: has no parent control instruction
         exit_if  # undef
         ^^^^^^^
 
@@ -1306,7 +1306,7 @@
     ASSERT_FALSE(res);
     EXPECT_EQ(
         res.Failure().str(),
-        R"(:5:9 error: exit-if: args count (1) does not match control instruction result count (2)
+        R"(:5:9 error: exit_if: args count (1) does not match control instruction result count (2)
         exit_if 1i  # if_1
         ^^^^^^^^^^
 
@@ -1350,7 +1350,7 @@
     ASSERT_FALSE(res);
     EXPECT_EQ(
         res.Failure().str(),
-        R"(:5:9 error: exit-if: args count (3) does not match control instruction result count (2)
+        R"(:5:9 error: exit_if: args count (3) does not match control instruction result count (2)
         exit_if 1i, 2.0f, 3i  # if_1
         ^^^^^^^^^^^^^^^^^^^^
 
@@ -1411,7 +1411,7 @@
     ASSERT_FALSE(res);
     EXPECT_EQ(
         res.Failure().str(),
-        R"(:5:21 error: exit-if: argument type (f32) does not match control instruction type (i32)
+        R"(:5:21 error: exit_if: argument type (f32) does not match control instruction type (i32)
         exit_if 1i, 2i  # if_1
                     ^^
 
@@ -1451,7 +1451,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:8:5 error: exit-if: found outside all control instructions
+              R"(:8:5 error: exit_if: found outside all control instructions
     exit_if  # if_1
     ^^^^^^^
 
@@ -1494,7 +1494,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:7:13 error: exit-if: if target jumps over other control instructions
+              R"(:7:13 error: exit_if: if target jumps over other control instructions
             exit_if  # if_1
             ^^^^^^^
 
@@ -1547,7 +1547,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:7:13 error: exit-if: if target jumps over other control instructions
+              R"(:7:13 error: exit_if: if target jumps over other control instructions
             exit_if  # if_1
             ^^^^^^^
 
@@ -1599,7 +1599,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:7:13 error: exit-if: if target jumps over other control instructions
+              R"(:7:13 error: exit_if: if target jumps over other control instructions
             exit_if  # if_1
             ^^^^^^^
 
@@ -1658,7 +1658,7 @@
 
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
-    EXPECT_EQ(res.Failure().str(), R"(:5:9 error: exit-switch: has no parent control instruction
+    EXPECT_EQ(res.Failure().str(), R"(:5:9 error: exit_switch: has no parent control instruction
         exit_switch  # undef
         ^^^^^^^^^^^
 
@@ -1699,7 +1699,7 @@
     ASSERT_FALSE(res);
     EXPECT_EQ(
         res.Failure().str(),
-        R"(:5:9 error: exit-switch: args count (1) does not match control instruction result count (2)
+        R"(:5:9 error: exit_switch: args count (1) does not match control instruction result count (2)
         exit_switch 1i  # switch_1
         ^^^^^^^^^^^^^^
 
@@ -1743,7 +1743,7 @@
     ASSERT_FALSE(res);
     EXPECT_EQ(
         res.Failure().str(),
-        R"(:5:9 error: exit-switch: args count (3) does not match control instruction result count (2)
+        R"(:5:9 error: exit_switch: args count (3) does not match control instruction result count (2)
         exit_switch 1i, 2.0f, 3i  # switch_1
         ^^^^^^^^^^^^^^^^^^^^^^^^
 
@@ -1805,7 +1805,7 @@
     ASSERT_FALSE(res);
     EXPECT_EQ(
         res.Failure().str(),
-        R"(:5:25 error: exit-switch: argument type (f32) does not match control instruction type (i32)
+        R"(:5:25 error: exit_switch: argument type (f32) does not match control instruction type (i32)
         exit_switch 1i, 2i  # switch_1
                         ^^
 
@@ -1849,7 +1849,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:10:9 error: exit-switch: switch not found in parent control instructions
+              R"(:10:9 error: exit_switch: switch not found in parent control instructions
         exit_switch  # switch_1
         ^^^^^^^^^^^
 
@@ -1931,7 +1931,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:7:13 error: exit-switch: switch target jumps over other control instructions
+              R"(:7:13 error: exit_switch: switch target jumps over other control instructions
             exit_switch  # switch_1
             ^^^^^^^^^^^
 
@@ -1982,7 +1982,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:7:13 error: exit-switch: switch target jumps over other control instructions
+              R"(:7:13 error: exit_switch: switch target jumps over other control instructions
             exit_switch  # switch_1
             ^^^^^^^^^^^
 
@@ -2039,7 +2039,7 @@
 
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
-    EXPECT_EQ(res.Failure().str(), R"(:5:9 error: exit-loop: has no parent control instruction
+    EXPECT_EQ(res.Failure().str(), R"(:5:9 error: exit_loop: has no parent control instruction
         exit_loop  # undef
         ^^^^^^^^^
 
@@ -2082,7 +2082,7 @@
     ASSERT_FALSE(res);
     EXPECT_EQ(
         res.Failure().str(),
-        R"(:5:9 error: exit-loop: args count (1) does not match control instruction result count (2)
+        R"(:5:9 error: exit_loop: args count (1) does not match control instruction result count (2)
         exit_loop 1i  # loop_1
         ^^^^^^^^^^^^
 
@@ -2129,7 +2129,7 @@
     ASSERT_FALSE(res);
     EXPECT_EQ(
         res.Failure().str(),
-        R"(:5:9 error: exit-loop: args count (3) does not match control instruction result count (2)
+        R"(:5:9 error: exit_loop: args count (3) does not match control instruction result count (2)
         exit_loop 1i, 2.0f, 3i  # loop_1
         ^^^^^^^^^^^^^^^^^^^^^^
 
@@ -2194,7 +2194,7 @@
     ASSERT_FALSE(res);
     EXPECT_EQ(
         res.Failure().str(),
-        R"(:5:23 error: exit-loop: argument type (f32) does not match control instruction type (i32)
+        R"(:5:23 error: exit_loop: argument type (f32) does not match control instruction type (i32)
         exit_loop 1i, 2i  # loop_1
                       ^^
 
@@ -2240,7 +2240,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:13:9 error: exit-loop: loop not found in parent control instructions
+              R"(:13:9 error: exit_loop: loop not found in parent control instructions
         exit_loop  # loop_1
         ^^^^^^^^^
 
@@ -2324,7 +2324,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:7:13 error: exit-loop: loop target jumps over other control instructions
+              R"(:7:13 error: exit_loop: loop target jumps over other control instructions
             exit_loop  # loop_1
             ^^^^^^^^^
 
@@ -2379,7 +2379,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:7:13 error: exit-loop: loop target jumps over other control instructions
+              R"(:7:13 error: exit_loop: loop target jumps over other control instructions
             exit_loop  # loop_1
             ^^^^^^^^^
 
@@ -2429,7 +2429,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:8:9 error: exit-loop: loop exit jumps out of continuing block
+              R"(:8:9 error: exit_loop: loop exit jumps out of continuing block
         exit_loop  # loop_1
         ^^^^^^^^^
 
@@ -2475,7 +2475,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:10:13 error: exit-loop: loop exit jumps out of continuing block
+              R"(:10:13 error: exit_loop: loop exit jumps out of continuing block
             exit_loop  # loop_1
             ^^^^^^^^^
 
@@ -2527,7 +2527,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:5:9 error: exit-loop: loop exit not permitted in loop initializer
+              R"(:5:9 error: exit_loop: loop exit not permitted in loop initializer
         exit_loop  # loop_1
         ^^^^^^^^^
 
@@ -2577,7 +2577,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:7:13 error: exit-loop: loop exit not permitted in loop initializer
+              R"(:7:13 error: exit_loop: loop exit not permitted in loop initializer
             exit_loop  # loop_1
             ^^^^^^^^^
 
@@ -2748,7 +2748,7 @@
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
     EXPECT_EQ(res.Failure().str(),
-              R"(:4:5 error: load-vector-element: instruction result is undefined
+              R"(:4:5 error: load_vector_element: instruction result is undefined
     undef = load_vector_element %2, 1i
     ^^^^^
 
@@ -2778,7 +2778,7 @@
 
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
-    EXPECT_EQ(res.Failure().str(), R"(:3:34 error: load-vector-element: operand is undefined
+    EXPECT_EQ(res.Failure().str(), R"(:3:34 error: load_vector_element: operand is undefined
     %2:f32 = load_vector_element undef, 1i
                                  ^^^^^
 
@@ -2808,7 +2808,7 @@
 
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
-    EXPECT_EQ(res.Failure().str(), R"(:4:38 error: load-vector-element: operand is undefined
+    EXPECT_EQ(res.Failure().str(), R"(:4:38 error: load_vector_element: operand is undefined
     %3:f32 = load_vector_element %2, undef
                                      ^^^^^
 
@@ -2838,7 +2838,7 @@
 
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
-    EXPECT_EQ(res.Failure().str(), R"(:3:26 error: store-vector-element: operand is undefined
+    EXPECT_EQ(res.Failure().str(), R"(:3:26 error: store_vector_element: operand is undefined
     store_vector_element undef, 1i, 2i
                          ^^^^^
 
@@ -2868,7 +2868,7 @@
 
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
-    EXPECT_EQ(res.Failure().str(), R"(:4:30 error: store-vector-element: operand is undefined
+    EXPECT_EQ(res.Failure().str(), R"(:4:30 error: store_vector_element: operand is undefined
     store_vector_element %2, undef, 2i
                              ^^^^^
 
@@ -2907,7 +2907,7 @@
 
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
-    EXPECT_EQ(res.Failure().str(), R"(:4:34 error: store-vector-element: operand is undefined
+    EXPECT_EQ(res.Failure().str(), R"(:4:34 error: store_vector_element: operand is undefined
     store_vector_element %2, 1i, undef
                                  ^^^^^
 
diff --git a/src/tint/lang/core/ir/var.h b/src/tint/lang/core/ir/var.h
index 8349be5..c10adf3 100644
--- a/src/tint/lang/core/ir/var.h
+++ b/src/tint/lang/core/ir/var.h
@@ -15,6 +15,8 @@
 #ifndef SRC_TINT_LANG_CORE_IR_VAR_H_
 #define SRC_TINT_LANG_CORE_IR_VAR_H_
 
+#include <string>
+
 #include "src/tint/api/common/binding_point.h"
 #include "src/tint/lang/core/access.h"
 #include "src/tint/lang/core/address_space.h"
@@ -53,7 +55,7 @@
     void DestroyIfOnlyAssigned();
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "var"; }
+    std::string FriendlyName() override { return "var"; }
 
   private:
     std::optional<struct BindingPoint> binding_point_;
diff --git a/src/tint/lang/spirv/ir/intrinsic_call.h b/src/tint/lang/spirv/ir/intrinsic_call.h
index 3f49991..d7c2d43 100644
--- a/src/tint/lang/spirv/ir/intrinsic_call.h
+++ b/src/tint/lang/spirv/ir/intrinsic_call.h
@@ -39,9 +39,7 @@
     Intrinsic Kind() const { return intrinsic_; }
 
     /// @returns the friendly name for the instruction
-    std::string_view FriendlyName() override { return "spirv-intrinsic-call"; }
-
-    std::string KindName() const override { return "spirv." + std::string(ToString(intrinsic_)); }
+    std::string FriendlyName() override { return "spirv." + std::string(ToString(intrinsic_)); }
 
   private:
     Intrinsic intrinsic_ = Intrinsic::kUndefined;