[ir] Make Builder::Function add the function

There isn't a use case for not automatically adding the function.

Fix a couple of SPIR-V backend tests that had invaild IR.

Bug: tint:1718
Change-Id: I4988b3177d7a8fbaffcf950e04b8e9ba27946b4a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/139263
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/ir/builder.cc b/src/tint/ir/builder.cc
index bef450f..ad8b8f7 100644
--- a/src/tint/ir/builder.cc
+++ b/src/tint/ir/builder.cc
@@ -50,6 +50,7 @@
     auto* ir_func = ir.values.Create<ir::Function>(return_type, stage, wg_size);
     ir_func->SetBlock(Block());
     ir.SetName(ir_func, name);
+    ir.functions.Push(ir_func);
     return ir_func;
 }
 
diff --git a/src/tint/ir/from_program.cc b/src/tint/ir/from_program.cc
index 191178c..1303dad 100644
--- a/src/tint/ir/from_program.cc
+++ b/src/tint/ir/from_program.cc
@@ -263,7 +263,6 @@
         auto* ir_func = builder_.Function(ast_func->name->symbol.NameView(),
                                           sem->ReturnType()->Clone(clone_ctx_.type_ctx));
         current_function_ = ir_func;
-        builder_.ir.functions.Push(ir_func);
 
         scopes_.Set(ast_func->name->symbol, ir_func);
 
diff --git a/src/tint/ir/to_program_test.cc b/src/tint/ir/to_program_test.cc
index 91840b1..bdfc8c6 100644
--- a/src/tint/ir/to_program_test.cc
+++ b/src/tint/ir/to_program_test.cc
@@ -62,8 +62,7 @@
 }
 
 TEST_F(IRToProgramTest, SingleFunction_Empty) {
-    auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
+    b.Function("f", ty.void_());
 
     EXPECT_WGSL(R"(
 fn f() {
@@ -73,7 +72,6 @@
 
 TEST_F(IRToProgramTest, SingleFunction_Return) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     fn->Block()->Append(b.Return(fn));
 
@@ -85,7 +83,6 @@
 
 TEST_F(IRToProgramTest, SingleFunction_Return_i32) {
     auto* fn = b.Function("f", ty.i32());
-    mod.functions.Push(fn);
 
     fn->Block()->Append(b.Return(fn, 42_i));
 
@@ -101,7 +98,6 @@
     auto* i = b.FunctionParam("i", ty.i32());
     auto* u = b.FunctionParam("u", ty.u32());
     fn->SetParams({i, u});
-    mod.functions.Push(fn);
 
     fn->Block()->Append(b.Return(fn, i));
 
@@ -119,7 +115,6 @@
     auto* fn = b.Function("f", ty.i32());
     auto* i = b.FunctionParam("i", ty.i32());
     fn->SetParams({i});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.Negation(ty.i32(), i)); });
 
@@ -134,7 +129,6 @@
     auto* fn = b.Function("f", ty.u32());
     auto* i = b.FunctionParam("i", ty.u32());
     fn->SetParams({i});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.Complement(ty.u32(), i)); });
 
@@ -149,7 +143,6 @@
     auto* fn = b.Function("f", ty.bool_());
     auto* i = b.FunctionParam("b", ty.bool_());
     fn->SetParams({i});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.Not(ty.bool_(), i)); });
 
@@ -168,7 +161,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.i32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.Add(ty.i32(), pa, pb)); });
 
@@ -184,7 +176,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.i32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.Subtract(ty.i32(), pa, pb)); });
 
@@ -200,7 +191,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.i32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.Multiply(ty.i32(), pa, pb)); });
 
@@ -216,7 +206,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.i32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.Divide(ty.i32(), pa, pb)); });
 
@@ -232,7 +221,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.i32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.Modulo(ty.i32(), pa, pb)); });
 
@@ -248,7 +236,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.i32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.And(ty.i32(), pa, pb)); });
 
@@ -264,7 +251,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.i32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.Or(ty.i32(), pa, pb)); });
 
@@ -280,7 +266,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.i32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.Xor(ty.i32(), pa, pb)); });
 
@@ -296,7 +281,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.i32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.Equal(ty.i32(), pa, pb)); });
 
@@ -312,7 +296,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.i32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.NotEqual(ty.i32(), pa, pb)); });
 
@@ -328,7 +311,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.i32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.LessThan(ty.i32(), pa, pb)); });
 
@@ -344,7 +326,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.i32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.GreaterThan(ty.i32(), pa, pb)); });
 
@@ -360,7 +341,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.i32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.LessThanEqual(ty.i32(), pa, pb)); });
 
@@ -376,7 +356,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.i32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.GreaterThanEqual(ty.i32(), pa, pb)); });
 
@@ -392,7 +371,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.u32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.ShiftLeft(ty.i32(), pa, pb)); });
 
@@ -408,7 +386,6 @@
     auto* pa = b.FunctionParam("a", ty.i32());
     auto* pb = b.FunctionParam("b", ty.u32());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] { b.Return(fn, b.ShiftRight(ty.i32(), pa, pb)); });
 
@@ -427,7 +404,6 @@
     auto* pa = b.FunctionParam("a", ty.bool_());
     auto* pb = b.FunctionParam("b", ty.bool_());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if_ = b.If(pa);
@@ -451,7 +427,6 @@
     auto* pb = b.FunctionParam("b", ty.bool_());
     auto* pc = b.FunctionParam("c", ty.bool_());
     fn->SetParams({pa, pb, pc});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if1 = b.If(pa);
@@ -480,7 +455,6 @@
     auto* pb = b.FunctionParam("b", ty.bool_());
     auto* pc = b.FunctionParam("c", ty.bool_());
     fn->SetParams({pa, pb, pc});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if1 = b.If(pb);
@@ -507,7 +481,6 @@
     auto* pa = b.FunctionParam("a", ty.bool_());
     auto* pb = b.FunctionParam("b", ty.bool_());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if_ = b.If(pa);
@@ -533,7 +506,6 @@
     auto* pb = b.FunctionParam("b", ty.bool_());
     auto* pc = b.FunctionParam("c", ty.bool_());
     fn->SetParams({pa, pb, pc});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if1 = b.If(pa);
@@ -564,7 +536,6 @@
     auto* pb = b.FunctionParam("b", ty.bool_());
     auto* pc = b.FunctionParam("c", ty.bool_());
     fn->SetParams({pa, pb, pc});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if1 = b.If(pb);
@@ -591,15 +562,12 @@
 
 TEST_F(IRToProgramTest, BinaryOp_LogicalAnd_Call_2) {
     auto* fn_a = b.Function("a", ty.bool_());
-    mod.functions.Push(fn_a);
     b.With(fn_a->Block(), [&] { b.Return(fn_a, true); });
 
     auto* fn_b = b.Function("b", ty.bool_());
-    mod.functions.Push(fn_b);
     b.With(fn_b->Block(), [&] { b.Return(fn_b, true); });
 
     auto* fn = b.Function("f", ty.bool_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if_ = b.If(b.Call(ty.bool_(), fn_a));
@@ -627,19 +595,15 @@
 
 TEST_F(IRToProgramTest, BinaryOp_LogicalAnd_Call_3_ab_c) {
     auto* fn_a = b.Function("a", ty.bool_());
-    mod.functions.Push(fn_a);
     b.With(fn_a->Block(), [&] { b.Return(fn_a, true); });
 
     auto* fn_b = b.Function("b", ty.bool_());
-    mod.functions.Push(fn_b);
     b.With(fn_b->Block(), [&] { b.Return(fn_b, true); });
 
     auto* fn_c = b.Function("c", ty.bool_());
-    mod.functions.Push(fn_c);
     b.With(fn_c->Block(), [&] { b.Return(fn_c, true); });
 
     auto* fn = b.Function("f", ty.bool_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if1 = b.If(b.Call(ty.bool_(), fn_a));
@@ -676,19 +640,15 @@
 
 TEST_F(IRToProgramTest, BinaryOp_LogicalAnd_Call_3_a_bc) {
     auto* fn_a = b.Function("a", ty.bool_());
-    mod.functions.Push(fn_a);
     b.With(fn_a->Block(), [&] { b.Return(fn_a, true); });
 
     auto* fn_b = b.Function("b", ty.bool_());
-    mod.functions.Push(fn_b);
     b.With(fn_b->Block(), [&] { b.Return(fn_b, true); });
 
     auto* fn_c = b.Function("c", ty.bool_());
-    mod.functions.Push(fn_c);
     b.With(fn_c->Block(), [&] { b.Return(fn_c, true); });
 
     auto* fn = b.Function("f", ty.bool_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if1 = b.If(b.Call(ty.bool_(), fn_b));
@@ -728,7 +688,6 @@
     auto* pa = b.FunctionParam("a", ty.bool_());
     auto* pb = b.FunctionParam("b", ty.bool_());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if_ = b.If(pa);
@@ -752,7 +711,6 @@
     auto* pb = b.FunctionParam("b", ty.bool_());
     auto* pc = b.FunctionParam("c", ty.bool_());
     fn->SetParams({pa, pb, pc});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if1 = b.If(pa);
@@ -781,7 +739,6 @@
     auto* pb = b.FunctionParam("b", ty.bool_());
     auto* pc = b.FunctionParam("c", ty.bool_());
     fn->SetParams({pa, pb, pc});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if1 = b.If(pb);
@@ -809,7 +766,6 @@
     auto* pa = b.FunctionParam("a", ty.bool_());
     auto* pb = b.FunctionParam("b", ty.bool_());
     fn->SetParams({pa, pb});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if_ = b.If(pa);
@@ -835,7 +791,6 @@
     auto* pb = b.FunctionParam("b", ty.bool_());
     auto* pc = b.FunctionParam("c", ty.bool_());
     fn->SetParams({pa, pb, pc});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if1 = b.If(pa);
@@ -866,7 +821,6 @@
     auto* pb = b.FunctionParam("b", ty.bool_());
     auto* pc = b.FunctionParam("c", ty.bool_());
     fn->SetParams({pa, pb, pc});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if1 = b.If(pb);
@@ -893,15 +847,12 @@
 
 TEST_F(IRToProgramTest, BinaryOp_LogicalOr_Call_2) {
     auto* fn_a = b.Function("a", ty.bool_());
-    mod.functions.Push(fn_a);
     b.With(fn_a->Block(), [&] { b.Return(fn_a, true); });
 
     auto* fn_b = b.Function("b", ty.bool_());
-    mod.functions.Push(fn_b);
     b.With(fn_b->Block(), [&] { b.Return(fn_b, true); });
 
     auto* fn = b.Function("f", ty.bool_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if_ = b.If(b.Call(ty.bool_(), fn_a));
@@ -929,19 +880,15 @@
 
 TEST_F(IRToProgramTest, BinaryOp_LogicalOr_Call_3_ab_c) {
     auto* fn_a = b.Function("a", ty.bool_());
-    mod.functions.Push(fn_a);
     b.With(fn_a->Block(), [&] { b.Return(fn_a, true); });
 
     auto* fn_b = b.Function("b", ty.bool_());
-    mod.functions.Push(fn_b);
     b.With(fn_b->Block(), [&] { b.Return(fn_b, true); });
 
     auto* fn_c = b.Function("c", ty.bool_());
-    mod.functions.Push(fn_c);
     b.With(fn_c->Block(), [&] { b.Return(fn_c, true); });
 
     auto* fn = b.Function("f", ty.bool_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if1 = b.If(b.Call(ty.bool_(), fn_a));
@@ -978,19 +925,15 @@
 
 TEST_F(IRToProgramTest, BinaryOp_LogicalOr_Call_3_a_bc) {
     auto* fn_a = b.Function("a", ty.bool_());
-    mod.functions.Push(fn_a);
     b.With(fn_a->Block(), [&] { b.Return(fn_a, true); });
 
     auto* fn_b = b.Function("b", ty.bool_());
-    mod.functions.Push(fn_b);
     b.With(fn_b->Block(), [&] { b.Return(fn_b, true); });
 
     auto* fn_c = b.Function("c", ty.bool_());
-    mod.functions.Push(fn_c);
     b.With(fn_c->Block(), [&] { b.Return(fn_c, true); });
 
     auto* fn = b.Function("f", ty.bool_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if1 = b.If(b.Call(ty.bool_(), fn_b));
@@ -1027,18 +970,15 @@
 
 TEST_F(IRToProgramTest, BinaryOp_LogicalMixed) {
     auto* fn_b = b.Function("b", ty.bool_());
-    mod.functions.Push(fn_b);
     b.With(fn_b->Block(), [&] { b.Return(fn_b, true); });
 
     auto* fn_d = b.Function("d", ty.bool_());
-    mod.functions.Push(fn_d);
     b.With(fn_d->Block(), [&] { b.Return(fn_d, true); });
 
     auto* fn = b.Function("f", ty.bool_());
     auto* pa = b.FunctionParam("a", ty.bool_());
     auto* pc = b.FunctionParam("c", ty.bool_());
     fn->SetParams({pa, pc});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if1 = b.If(pa);
@@ -1083,7 +1023,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 TEST_F(IRToProgramTest, CompoundAssign_Increment) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* v = b.Var(ty.ptr<function, i32>());
@@ -1101,7 +1040,6 @@
 
 TEST_F(IRToProgramTest, CompoundAssign_Decrement) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* v = b.Var(ty.ptr<function, i32>());
@@ -1119,7 +1057,6 @@
 
 TEST_F(IRToProgramTest, CompoundAssign_Add) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* v = b.Var(ty.ptr<function, i32>());
@@ -1137,7 +1074,6 @@
 
 TEST_F(IRToProgramTest, CompoundAssign_Subtract) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* v = b.Var(ty.ptr<function, i32>());
@@ -1155,7 +1091,6 @@
 
 TEST_F(IRToProgramTest, CompoundAssign_Multiply) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* v = b.Var(ty.ptr<function, i32>());
@@ -1173,7 +1108,6 @@
 
 TEST_F(IRToProgramTest, CompoundAssign_Divide) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* v = b.Var(ty.ptr<function, i32>());
@@ -1191,7 +1125,6 @@
 
 TEST_F(IRToProgramTest, CompoundAssign_Xor) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* v = b.Var(ty.ptr<function, i32>());
@@ -1214,7 +1147,6 @@
     auto* fn = b.Function("f", ty.u32());
     auto* i = b.FunctionParam("i", ty.u32());
     fn->SetParams({i});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* v = b.Complement(ty.u32(), i);
@@ -1234,7 +1166,6 @@
     auto* fn = b.Function("f", ty.i32());
     auto* i = b.FunctionParam("i", ty.i32());
     fn->SetParams({i});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* v = b.Multiply(ty.i32(), i, 2_i);
@@ -1255,7 +1186,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 TEST_F(IRToProgramTest, FunctionScopeVar_i32) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* i = b.Var(ty.ptr<function, i32>());
@@ -1271,7 +1201,6 @@
 
 TEST_F(IRToProgramTest, FunctionScopeVar_i32_InitLiteral) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* i = b.Var(ty.ptr<function, i32>());
@@ -1288,7 +1217,6 @@
 
 TEST_F(IRToProgramTest, FunctionScopeVar_Chained) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* va = b.Var(ty.ptr<function, i32>());
@@ -1321,12 +1249,10 @@
 ////////////////////////////////////////////////////////////////////////////////
 TEST_F(IRToProgramTest, If_CallFn) {
     auto* a = b.Function("a", ty.void_());
-    mod.functions.Push(a);
 
     auto* fn = b.Function("f", ty.void_());
     auto* cond = b.FunctionParam("cond", ty.bool_());
     fn->SetParams({cond});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* if_ = b.If(cond);
@@ -1352,7 +1278,6 @@
     auto* fn = b.Function("f", ty.void_());
     auto* cond = b.FunctionParam("cond", ty.bool_());
     fn->SetParams({cond});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto if_ = b.If(cond);
@@ -1370,7 +1295,6 @@
 
 TEST_F(IRToProgramTest, If_Return_i32) {
     auto* fn = b.Function("f", ty.i32());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* cond = b.Var(ty.ptr<function, bool>());
@@ -1394,15 +1318,12 @@
 
 TEST_F(IRToProgramTest, If_CallFn_Else_CallFn) {
     auto* fn_a = b.Function("a", ty.void_());
-    mod.functions.Push(fn_a);
 
     auto* fn_b = b.Function("b", ty.void_());
-    mod.functions.Push(fn_b);
 
     auto* fn = b.Function("f", ty.void_());
     auto* cond = b.FunctionParam("cond", ty.bool_());
     fn->SetParams({cond});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto if_ = b.If(cond);
@@ -1435,7 +1356,6 @@
 
 TEST_F(IRToProgramTest, If_Return_f32_Else_Return_f32) {
     auto* fn = b.Function("f", ty.f32());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* cond = b.Var(ty.ptr<function, bool>());
@@ -1460,13 +1380,10 @@
 
 TEST_F(IRToProgramTest, If_Return_u32_Else_CallFn) {
     auto* fn_a = b.Function("a", ty.void_());
-    mod.functions.Push(fn_a);
 
     auto* fn_b = b.Function("b", ty.void_());
-    mod.functions.Push(fn_b);
 
     auto* fn = b.Function("f", ty.u32());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* cond = b.Var(ty.ptr<function, bool>());
@@ -1504,16 +1421,12 @@
 
 TEST_F(IRToProgramTest, If_CallFn_ElseIf_CallFn) {
     auto* fn_a = b.Function("a", ty.void_());
-    mod.functions.Push(fn_a);
 
     auto* fn_b = b.Function("b", ty.void_());
-    mod.functions.Push(fn_b);
 
     auto* fn_c = b.Function("c", ty.void_());
-    mod.functions.Push(fn_c);
 
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* cond = b.Var(ty.ptr<function, bool>());
@@ -1561,7 +1474,6 @@
     auto* x = b.Function("x", ty.bool_());
     auto* i = b.FunctionParam("i", ty.i32());
     x->SetParams({i});
-    mod.functions.Push(x);
     b.With(x->Block(), [&] { b.Return(x, true); });
 
     auto* fn = b.Function("f", ty.void_());
@@ -1570,7 +1482,6 @@
     auto* pc = b.FunctionParam("c", ty.bool_());
     auto* pd = b.FunctionParam("d", ty.bool_());
     fn->SetParams({pa, pb, pc, pd});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto if1 = b.If(pa);
@@ -1621,10 +1532,8 @@
 ////////////////////////////////////////////////////////////////////////////////
 TEST_F(IRToProgramTest, Switch_Default) {
     auto* fn_a = b.Function("a", ty.void_());
-    mod.functions.Push(fn_a);
 
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* v = b.Var(ty.ptr<function, i32>());
@@ -1655,16 +1564,12 @@
 
 TEST_F(IRToProgramTest, Switch_3_Cases) {
     auto* fn_a = b.Function("a", ty.void_());
-    mod.functions.Push(fn_a);
 
     auto* fn_b = b.Function("b", ty.void_());
-    mod.functions.Push(fn_b);
 
     auto* fn_c = b.Function("c", ty.void_());
-    mod.functions.Push(fn_c);
 
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* v = b.Var(ty.ptr<function, i32>());
@@ -1720,10 +1625,8 @@
 
 TEST_F(IRToProgramTest, Switch_3_Cases_AllReturn) {
     auto* fn_a = b.Function("a", ty.void_());
-    mod.functions.Push(fn_a);
 
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* v = b.Var(ty.ptr<function, i32>());
@@ -1768,16 +1671,12 @@
 
 TEST_F(IRToProgramTest, Switch_Nested) {
     auto* fn_a = b.Function("a", ty.void_());
-    mod.functions.Push(fn_a);
 
-    auto* fn_b = b.Function("b", ty.void_());
-    mod.functions.Push(fn_b);
+    b.Function("b", ty.void_());
 
     auto* fn_c = b.Function("c", ty.void_());
-    mod.functions.Push(fn_c);
 
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* v1 = b.Var(ty.ptr<function, i32>());
@@ -1853,7 +1752,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 TEST_F(IRToProgramTest, For_Empty) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* loop = b.Loop();
@@ -1883,7 +1781,6 @@
 
 TEST_F(IRToProgramTest, For_Empty_NoInit) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* i = b.Var(ty.ptr<function, i32>());
@@ -1912,7 +1809,6 @@
 
 TEST_F(IRToProgramTest, For_Empty_NoCont) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* loop = b.Loop();
@@ -1943,10 +1839,8 @@
     auto* v = b.FunctionParam("v", ty.i32());
     a->SetParams({v});
     b.With(a->Block(), [&] { b.Return(a, b.Equal(ty.bool_(), v, 1_i)); });
-    mod.functions.Push(a);
 
     auto* fn = b.Function("f", ty.i32());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* loop = b.Loop();
@@ -1995,10 +1889,8 @@
     auto* v = b.FunctionParam("v", ty.i32());
     a->SetParams({v});
     b.With(a->Block(), [&] { b.Return(a, b.Equal(ty.bool_(), v, 1_i)); });
-    mod.functions.Push(a);
 
     auto* fn = b.Function("f", ty.i32());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* i = b.Var(ty.ptr<function, i32>());
@@ -2046,10 +1938,8 @@
     auto* v = b.FunctionParam("v", ty.i32());
     a->SetParams({v});
     b.With(a->Block(), [&] { b.Return(a, b.Equal(ty.bool_(), v, 1_i)); });
-    mod.functions.Push(a);
 
     auto* fn = b.Function("f", ty.i32());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* loop = b.Loop();
@@ -2095,10 +1985,8 @@
     auto* v = b.FunctionParam("v", ty.i32());
     fn_n->SetParams({v});
     b.With(fn_n->Block(), [&] { b.Return(fn_n, b.Add(ty.i32(), v, 1_i)); });
-    mod.functions.Push(fn_n);
 
     auto* fn_f = b.Function("f", ty.void_());
-    mod.functions.Push(fn_f);
 
     b.With(fn_f->Block(), [&] {
         auto* loop = b.Loop();
@@ -2136,7 +2024,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 TEST_F(IRToProgramTest, While_Empty) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* loop = b.Loop();
@@ -2160,7 +2047,6 @@
     auto* fn = b.Function("f", ty.void_());
     auto* cond = b.FunctionParam("cond", ty.bool_());
     fn->SetParams({cond});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* loop = b.Loop();
@@ -2182,7 +2068,6 @@
 
 TEST_F(IRToProgramTest, While_Break) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* loop = b.Loop();
@@ -2208,7 +2093,6 @@
     auto* fn = b.Function("f", ty.void_());
     auto* cond = b.FunctionParam("cond", ty.bool_());
     fn->SetParams({cond});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* loop = b.Loop();
@@ -2238,7 +2122,6 @@
     auto* fn = b.Function("f", ty.void_());
     auto* cond = b.FunctionParam("cond", ty.bool_());
     fn->SetParams({cond});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* loop = b.Loop();
@@ -2269,7 +2152,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 TEST_F(IRToProgramTest, Loop_Break) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* loop = b.Loop();
@@ -2290,7 +2172,6 @@
     auto* fn = b.Function("f", ty.void_());
     auto* cond = b.FunctionParam("cond", ty.bool_());
     fn->SetParams({cond});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* loop = b.Loop();
@@ -2315,7 +2196,6 @@
     auto* fn = b.Function("f", ty.void_());
     auto* cond = b.FunctionParam("cond", ty.bool_());
     fn->SetParams({cond});
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* loop = b.Loop();
@@ -2339,7 +2219,6 @@
 
 TEST_F(IRToProgramTest, Loop_IfContinuing) {
     auto* fn = b.Function("f", ty.void_());
-    mod.functions.Push(fn);
 
     b.With(fn->Block(), [&] {
         auto* cond = b.Var(ty.ptr<function, bool>());
@@ -2374,7 +2253,6 @@
 
 TEST_F(IRToProgramTest, Loop_VarsDeclaredOutsideAndInside) {
     auto* f = b.Function("f", ty.void_());
-    mod.functions.Push(f);
 
     b.With(f->Block(), [&] {
         auto* var_b = b.Var(ty.ptr<function, i32>());
diff --git a/src/tint/ir/transform/add_empty_entry_point.cc b/src/tint/ir/transform/add_empty_entry_point.cc
index 5781e93..985c2ff 100644
--- a/src/tint/ir/transform/add_empty_entry_point.cc
+++ b/src/tint/ir/transform/add_empty_entry_point.cc
@@ -38,7 +38,6 @@
     auto* ep = builder.Function("unused_entry_point", ir->Types().void_(),
                                 Function::PipelineStage::kCompute, std::array{1u, 1u, 1u});
     ep->Block()->Append(builder.Return(ep));
-    ir->functions.Push(ep);
 }
 
 }  // namespace tint::ir::transform
diff --git a/src/tint/ir/transform/add_empty_entry_point_test.cc b/src/tint/ir/transform/add_empty_entry_point_test.cc
index 567feae..d74ed0e 100644
--- a/src/tint/ir/transform/add_empty_entry_point_test.cc
+++ b/src/tint/ir/transform/add_empty_entry_point_test.cc
@@ -40,7 +40,6 @@
 TEST_F(IR_AddEmptyEntryPointTest, ExistingEntryPoint) {
     auto* ep = b.Function("main", mod.Types().void_(), Function::PipelineStage::kFragment);
     ep->Block()->Append(b.Return(ep));
-    mod.functions.Push(ep);
 
     auto* expect = R"(
 %main = @fragment func():void -> %b1 {
diff --git a/src/tint/ir/transform/block_decorated_structs_test.cc b/src/tint/ir/transform/block_decorated_structs_test.cc
index 2d2a856..2d93a2d 100644
--- a/src/tint/ir/transform/block_decorated_structs_test.cc
+++ b/src/tint/ir/transform/block_decorated_structs_test.cc
@@ -32,7 +32,6 @@
 TEST_F(IR_BlockDecoratedStructsTest, NoRootBlock) {
     auto* func = b.Function("foo", ty.void_());
     func->Block()->Append(b.Return(func));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 %foo = func():void -> %b1 {
@@ -57,7 +56,6 @@
     auto* block = func->Block();
     auto* load = block->Append(b.Load(buffer));
     block->Append(b.Return(func, load));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 tint_symbol_1 = struct @align(4), @block {
@@ -90,7 +88,6 @@
     auto* func = b.Function("foo", ty.void_());
     func->Block()->Append(b.Store(buffer, 42_i));
     func->Block()->Append(b.Return(func));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 tint_symbol_1 = struct @align(4), @block {
@@ -128,8 +125,6 @@
         b.Return(func);
     });
 
-    mod.functions.Push(func);
-
     auto* expect = R"(
 tint_symbol_1 = struct @align(4), @block {
   tint_symbol:array<i32> @offset(0)
@@ -177,8 +172,6 @@
         b.Return(func);
     });
 
-    mod.functions.Push(func);
-
     auto* expect = R"(
 MyStruct = struct @align(4) {
   i:i32 @offset(0)
@@ -226,7 +219,6 @@
     auto* func = b.Function("foo", ty.void_());
     func->Block()->Append(b.Store(buffer, private_var));
     func->Block()->Append(b.Return(func));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 MyStruct = struct @align(4) {
@@ -275,7 +267,6 @@
     auto* load_c = block->Append(b.Load(buffer_c));
     block->Append(b.Store(buffer_a, b.Add(ty.i32(), load_b, load_c)));
     block->Append(b.Return(func));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 tint_symbol_1 = struct @align(4), @block {
diff --git a/src/tint/ir/transform/merge_return_test.cc b/src/tint/ir/transform/merge_return_test.cc
index 2d20f25..b01d49e 100644
--- a/src/tint/ir/transform/merge_return_test.cc
+++ b/src/tint/ir/transform/merge_return_test.cc
@@ -30,7 +30,6 @@
     auto* in = b.FunctionParam(ty.i32());
     auto* func = b.Function("foo", ty.i32());
     func->SetParams({in});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] { b.Return(func, b.Add(ty.i32(), in, 1_i)); });
 
@@ -56,7 +55,6 @@
     auto* cond = b.FunctionParam(ty.bool_());
     auto* func = b.Function("foo", ty.i32());
     func->SetParams({in});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* ifelse = b.If(cond);
@@ -97,7 +95,6 @@
     auto* cond = b.FunctionParam(ty.bool_());
     auto* func = b.Function("foo", ty.i32());
     func->SetParams({in});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* swtch = b.Switch(in);
@@ -150,7 +147,6 @@
     auto* cond = b.FunctionParam(ty.bool_());
     auto* func = b.Function("foo", ty.void_());
     func->SetParams({cond});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* ifelse = b.If(cond);
@@ -204,7 +200,6 @@
     auto* cond = b.FunctionParam(ty.bool_());
     auto* func = b.Function("foo", ty.void_());
     func->SetParams({cond});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* ifelse = b.If(cond);
@@ -256,7 +251,6 @@
     auto* cond = b.FunctionParam(ty.bool_());
     auto* func = b.Function("foo", ty.i32());
     func->SetParams({cond});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* ifelse = b.If(cond);
@@ -320,7 +314,6 @@
     auto* cond = b.FunctionParam(ty.bool_());
     auto* func = b.Function("foo", ty.i32());
     func->SetParams({cond});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* ifelse = b.If(cond);
@@ -385,7 +378,6 @@
     auto* cond = b.FunctionParam(ty.bool_());
     auto* func = b.Function("foo", ty.i32());
     func->SetParams({cond});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* ifelse = b.If(cond);
@@ -450,7 +442,6 @@
     auto* cond = b.FunctionParam(ty.bool_());
     auto* func = b.Function("foo", ty.void_());
     func->SetParams({cond});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* ifelse = b.If(cond);
@@ -506,7 +497,6 @@
     auto* cond = b.FunctionParam(ty.bool_());
     auto* func = b.Function("foo", ty.void_());
     func->SetParams({cond});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* ifelse = b.If(cond);
@@ -583,7 +573,6 @@
     auto* cond = b.FunctionParam(ty.bool_());
     auto* func = b.Function("foo", ty.void_());
     func->SetParams({cond});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* ifelse = b.If(cond);
@@ -660,7 +649,6 @@
     auto* condB = b.FunctionParam("condB", ty.bool_());
     auto* condC = b.FunctionParam("condC", ty.bool_());
     func->SetParams({condA, condB, condC});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* ifelse_outer = b.If(condA);
@@ -807,7 +795,6 @@
     auto* condB = b.FunctionParam("condB", ty.bool_());
     auto* condC = b.FunctionParam("condC", ty.bool_());
     func->SetParams({condA, condB, condC});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* ifelse_outer = b.If(condA);
@@ -929,7 +916,6 @@
     auto* condB = b.FunctionParam("condB", ty.bool_());
     auto* condC = b.FunctionParam("condC", ty.bool_());
     func->SetParams({condA, condB, condC});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* ifelse_outer = b.If(condA);
@@ -1071,7 +1057,6 @@
 
 TEST_F(IR_MergeReturnTest, Loop_UnconditionalReturnInBody) {
     auto* func = b.Function("foo", ty.i32());
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* loop = b.Loop();
@@ -1121,7 +1106,6 @@
     auto* cond = b.FunctionParam(ty.bool_());
     auto* func = b.Function("foo", ty.i32());
     func->SetParams({cond});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* loop = b.Loop();
@@ -1236,7 +1220,6 @@
     auto* cond = b.FunctionParam(ty.bool_());
     auto* func = b.Function("foo", ty.i32());
     func->SetParams({cond});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* loop = b.Loop();
@@ -1342,7 +1325,6 @@
     auto* cond = b.FunctionParam(ty.bool_());
     auto* func = b.Function("foo", ty.i32());
     func->SetParams({cond});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* loop = b.Loop();
@@ -1454,7 +1436,6 @@
     auto* cond = b.FunctionParam(ty.i32());
     auto* func = b.Function("foo", ty.i32());
     func->SetParams({cond});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* sw = b.Switch(cond);
@@ -1521,7 +1502,6 @@
     auto* cond = b.FunctionParam(ty.i32());
     auto* func = b.Function("foo", ty.i32());
     func->SetParams({cond});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* sw = b.Switch(cond);
@@ -1625,7 +1605,6 @@
     auto* cond = b.FunctionParam(ty.i32());
     auto* func = b.Function("foo", ty.i32());
     func->SetParams({cond});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* sw = b.Switch(cond);
@@ -1704,7 +1683,6 @@
 
 TEST_F(IR_MergeReturnTest, LoopIfReturnThenContinue) {
     auto* func = b.Function("foo", ty.void_());
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         auto* loop = b.Loop();
@@ -1767,7 +1745,6 @@
 
 TEST_F(IR_MergeReturnTest, NestedIfsWithReturns) {
     auto* func = b.Function("foo", ty.i32());
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         b.With(b.If(true)->True(), [&] {
diff --git a/src/tint/ir/transform/shader_io.cc b/src/tint/ir/transform/shader_io.cc
index a1e9baa..6456710 100644
--- a/src/tint/ir/transform/shader_io.cc
+++ b/src/tint/ir/transform/shader_io.cc
@@ -130,7 +130,6 @@
         if (wgsize) {
             ep->SetWorkgroupSize((*wgsize)[0], (*wgsize)[1], (*wgsize)[2]);
         }
-        ir->functions.Push(ep);
         auto wrapper = b.With(ep->Block());
 
         // Call the original function, passing it the inputs and capturing its return value.
diff --git a/src/tint/ir/transform/shader_io_test.cc b/src/tint/ir/transform/shader_io_test.cc
index bd94416..7f18722 100644
--- a/src/tint/ir/transform/shader_io_test.cc
+++ b/src/tint/ir/transform/shader_io_test.cc
@@ -30,7 +30,6 @@
 TEST_F(IR_ShaderIOTest, NoInputsOrOutputs) {
     auto* ep = b.Function("foo", ty.void_());
     ep->SetStage(Function::PipelineStage::kCompute);
-    mod.functions.Push(ep);
 
     b.With(ep->Block(), [&] {  //
         b.Return(ep);
@@ -69,7 +68,6 @@
 
     ep->SetParams({front_facing, position, color1, color2});
     ep->SetStage(Function::PipelineStage::kFragment);
-    mod.functions.Push(ep);
 
     b.With(ep->Block(), [&] {
         auto* ifelse = b.If(front_facing);
@@ -182,7 +180,6 @@
     auto* str_param = b.FunctionParam("inputs", str_ty);
     ep->SetParams({str_param});
     ep->SetStage(Function::PipelineStage::kFragment);
-    mod.functions.Push(ep);
 
     b.With(ep->Block(), [&] {
         auto* ifelse = b.If(b.Access(ty.bool_(), str_param, 0_i));
@@ -311,7 +308,6 @@
 
     ep->SetParams({front_facing, str_param, color2});
     ep->SetStage(Function::PipelineStage::kFragment);
-    mod.functions.Push(ep);
 
     b.With(ep->Block(), [&] {
         auto* ifelse = b.If(front_facing);
@@ -411,7 +407,6 @@
     ep->SetReturnBuiltin(Function::ReturnBuiltin::kPosition);
     ep->SetReturnInvariant(true);
     ep->SetStage(Function::PipelineStage::kVertex);
-    mod.functions.Push(ep);
 
     b.With(ep->Block(), [&] {  //
         b.Return(ep, b.Construct(ty.vec4<f32>(), 0.5_f));
@@ -463,7 +458,6 @@
     auto* ep = b.Function("foo", ty.vec4<f32>());
     ep->SetReturnLocation(1u, {});
     ep->SetStage(Function::PipelineStage::kFragment);
-    mod.functions.Push(ep);
 
     b.With(ep->Block(), [&] {  //
         b.Return(ep, b.Construct(ty.vec4<f32>(), 0.5_f));
@@ -539,7 +533,6 @@
 
     auto* ep = b.Function("foo", str_ty);
     ep->SetStage(Function::PipelineStage::kVertex);
-    mod.functions.Push(ep);
 
     b.With(ep->Block(), [&] {  //
         b.Return(ep, b.Construct(str_ty, b.Construct(ty.vec4<f32>(), 0_f), 0.25_f, 0.75_f));
@@ -634,7 +627,6 @@
     {
         auto* ep = b.Function("vert", str_ty);
         ep->SetStage(Function::PipelineStage::kVertex);
-        mod.functions.Push(ep);
 
         b.With(ep->Block(), [&] {  //
             auto* position = b.Construct(vec4f, 0_f);
@@ -649,7 +641,6 @@
         auto* inputs = b.FunctionParam("inputs", str_ty);
         ep->SetStage(Function::PipelineStage::kFragment);
         ep->SetParams({inputs});
-        mod.functions.Push(ep);
 
         b.With(ep->Block(), [&] {  //
             auto* position = b.Access(vec4f, inputs, 0_u);
@@ -787,7 +778,6 @@
 
     auto* ep = b.Function("vert", str_ty);
     ep->SetStage(Function::PipelineStage::kVertex);
-    mod.functions.Push(ep);
 
     b.With(ep->Block(), [&] {  //
         b.Return(ep, b.Load(buffer));
@@ -881,7 +871,6 @@
     auto* ep = b.Function("foo", str_ty);
     ep->SetStage(Function::PipelineStage::kFragment);
     ep->SetParams({mask_in});
-    mod.functions.Push(ep);
 
     b.With(ep->Block(), [&] {  //
         b.Return(ep, b.Construct(str_ty, 0.5_f, mask_in));
diff --git a/src/tint/ir/transform/var_for_dynamic_index_test.cc b/src/tint/ir/transform/var_for_dynamic_index_test.cc
index ce0d691..7848174 100644
--- a/src/tint/ir/transform/var_for_dynamic_index_test.cc
+++ b/src/tint/ir/transform/var_for_dynamic_index_test.cc
@@ -37,7 +37,6 @@
     auto* block = func->Block();
     auto* access = block->Append(b.Access(ty.i32(), arr, 1_i));
     block->Append(b.Return(func, access));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 %foo = func(%2:array<i32, 4>):i32 -> %b1 {
@@ -61,7 +60,6 @@
     auto* block = func->Block();
     auto* access = block->Append(b.Access(ty.f32(), mat, 1_i, 0_i));
     block->Append(b.Return(func, access));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 %foo = func(%2:mat2x2<f32>):f32 -> %b1 {
@@ -87,7 +85,6 @@
     auto* access = block->Append(b.Access(ty.ptr<function, i32>(), arr, idx));
     auto* load = block->Append(b.Load(access));
     block->Append(b.Return(func, load));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 %foo = func(%2:ptr<function, array<i32, 4>, read_write>, %3:i32):i32 -> %b1 {
@@ -114,7 +111,6 @@
     auto* access = block->Append(b.Access(ty.ptr<function, f32>(), mat, idx, idx));
     auto* load = block->Append(b.Load(access));
     block->Append(b.Return(func, load));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 %foo = func(%2:ptr<function, mat2x2<f32>, read_write>, %3:i32):f32 -> %b1 {
@@ -140,7 +136,6 @@
     auto* block = func->Block();
     auto* access = block->Append(b.Access(ty.f32(), vec, idx));
     block->Append(b.Return(func, access));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 %foo = func(%2:vec4<f32>, %3:i32):f32 -> %b1 {
@@ -165,7 +160,6 @@
     auto* block = func->Block();
     auto* access = block->Append(b.Access(ty.i32(), arr, idx));
     block->Append(b.Return(func, access));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 %foo = func(%2:array<i32, 4>, %3:i32):i32 -> %b1 {
@@ -192,7 +186,6 @@
     auto* block = func->Block();
     auto* access = block->Append(b.Access(ty.vec2<f32>(), mat, idx));
     block->Append(b.Return(func, access));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 %foo = func(%2:mat2x2<f32>, %3:i32):vec2<f32> -> %b1 {
@@ -219,7 +212,6 @@
     auto* block = func->Block();
     auto* access = block->Append(b.Access(ty.i32(), arr, idx, 1_u, idx));
     block->Append(b.Return(func, access));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 %foo = func(%2:array<array<array<i32, 4>, 4>, 4>, %3:i32):i32 -> %b1 {
@@ -246,7 +238,6 @@
     auto* block = func->Block();
     auto* access = block->Append(b.Access(ty.i32(), arr, 1_u, 2_u, idx));
     block->Append(b.Return(func, access));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 %foo = func(%2:array<array<array<i32, 4>, 4>, 4>, %3:i32):i32 -> %b1 {
@@ -274,7 +265,6 @@
     auto* block = func->Block();
     auto* access = block->Append(b.Access(ty.i32(), arr, 1_u, idx, 2_u, idx));
     block->Append(b.Return(func, access));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 %foo = func(%2:array<array<array<array<i32, 4>, 4>, 4>, 4>, %3:i32):i32 -> %b1 {
@@ -308,7 +298,6 @@
     auto* block = func->Block();
     auto* access = block->Append(b.Access(ty.f32(), str_val, 1_u, idx, 0_u));
     block->Append(b.Return(func, access));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 MyStruct = struct @align(16) {
@@ -346,7 +335,6 @@
     block->Append(b.Access(ty.i32(), arr, idx_b));
     auto* access_c = block->Append(b.Access(ty.i32(), arr, idx_c));
     block->Append(b.Return(func, access_c));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 %foo = func(%2:array<i32, 4>, %3:i32, %4:i32, %5:i32):i32 -> %b1 {
@@ -381,7 +369,6 @@
     block->Append(b.Access(ty.i32(), arr, 1_u, 2_u, idx_b));
     auto* access_c = block->Append(b.Access(ty.i32(), arr, 1_u, 2_u, idx_c));
     block->Append(b.Return(func, access_c));
-    mod.functions.Push(func);
 
     auto* expect = R"(
 %foo = func(%2:array<array<array<i32, 4>, 4>, 4>, %3:i32, %4:i32, %5:i32):i32 -> %b1 {
diff --git a/src/tint/ir/validate_test.cc b/src/tint/ir/validate_test.cc
index 8a8b478..07b903a 100644
--- a/src/tint/ir/validate_test.cc
+++ b/src/tint/ir/validate_test.cc
@@ -68,7 +68,6 @@
 
 TEST_F(IR_ValidateTest, Function) {
     auto* f = b.Function("my_func", ty.void_());
-    mod.functions.Push(f);
 
     f->SetParams({b.FunctionParam(ty.i32()), b.FunctionParam(ty.f32())});
     f->Block()->Append(b.Return(f));
@@ -78,8 +77,7 @@
 }
 
 TEST_F(IR_ValidateTest, Block_NoTerminator) {
-    auto* f = b.Function("my_func", ty.void_());
-    mod.functions.Push(f);
+    b.Function("my_func", ty.void_());
 
     auto res = ir::Validate(mod);
     ASSERT_FALSE(res);
@@ -99,7 +97,6 @@
     auto* f = b.Function("my_func", ty.void_());
     auto* obj = b.FunctionParam(ty.mat3x2<f32>());
     f->SetParams({obj});
-    mod.functions.Push(f);
 
     b.With(f->Block(), [&] {
         b.Access(ty.f32(), obj, 1_u, 0_u);
@@ -114,7 +111,6 @@
     auto* f = b.Function("my_func", ty.void_());
     auto* obj = b.FunctionParam(ty.ptr<private_, mat3x2<f32>>());
     f->SetParams({obj});
-    mod.functions.Push(f);
 
     b.With(f->Block(), [&] {
         b.Access(ty.ptr<private_, f32>(), obj, 1_u, 0_u);
@@ -129,7 +125,6 @@
     auto* f = b.Function("my_func", ty.void_());
     auto* obj = b.FunctionParam(ty.vec3<f32>());
     f->SetParams({obj});
-    mod.functions.Push(f);
 
     b.With(f->Block(), [&] {
         b.Access(ty.f32(), obj, -1_i);
@@ -160,7 +155,6 @@
     auto* f = b.Function("my_func", ty.void_());
     auto* obj = b.FunctionParam(ty.mat3x2<f32>());
     f->SetParams({obj});
-    mod.functions.Push(f);
 
     b.With(f->Block(), [&] {
         b.Access(ty.f32(), obj, 1_u, 3_u);
@@ -195,7 +189,6 @@
     auto* f = b.Function("my_func", ty.void_());
     auto* obj = b.FunctionParam(ty.ptr<private_, mat3x2<f32>>());
     f->SetParams({obj});
-    mod.functions.Push(f);
 
     b.With(f->Block(), [&] {
         b.Access(ty.ptr<private_, f32>(), obj, 1_u, 3_u);
@@ -231,7 +224,6 @@
     auto* f = b.Function("my_func", ty.void_());
     auto* obj = b.FunctionParam(ty.f32());
     f->SetParams({obj});
-    mod.functions.Push(f);
 
     b.With(f->Block(), [&] {
         b.Access(ty.f32(), obj, 1_u);
@@ -262,7 +254,6 @@
     auto* f = b.Function("my_func", ty.void_());
     auto* obj = b.FunctionParam(ty.ptr<private_, f32>());
     f->SetParams({obj});
-    mod.functions.Push(f);
 
     b.With(f->Block(), [&] {
         b.Access(ty.ptr<private_, f32>(), obj, 1_u);
@@ -299,7 +290,6 @@
     auto* obj = b.FunctionParam(str_ty);
     auto* idx = b.FunctionParam(ty.i32());
     f->SetParams({obj, idx});
-    mod.functions.Push(f);
 
     b.With(f->Block(), [&] {
         b.Access(ty.i32(), obj, idx);
@@ -342,7 +332,6 @@
     auto* obj = b.FunctionParam(ty.ptr<private_, read_write>(str_ty));
     auto* idx = b.FunctionParam(ty.i32());
     f->SetParams({obj, idx});
-    mod.functions.Push(f);
 
     b.With(f->Block(), [&] {
         b.Access(ty.i32(), obj, idx);
@@ -379,7 +368,6 @@
     auto* f = b.Function("my_func", ty.void_());
     auto* obj = b.FunctionParam(ty.mat3x2<f32>());
     f->SetParams({obj});
-    mod.functions.Push(f);
 
     b.With(f->Block(), [&] {
         b.Access(ty.i32(), obj, 1_u, 1_u);
@@ -411,7 +399,6 @@
     auto* f = b.Function("my_func", ty.void_());
     auto* obj = b.FunctionParam(ty.ptr<private_, mat3x2<f32>>());
     f->SetParams({obj});
-    mod.functions.Push(f);
 
     b.With(f->Block(), [&] {
         b.Access(ty.ptr<private_, i32>(), obj, 1_u, 1_u);
@@ -444,7 +431,6 @@
     auto* f = b.Function("my_func", ty.void_());
     auto* obj = b.FunctionParam(ty.ptr<private_, mat3x2<f32>>());
     f->SetParams({obj});
-    mod.functions.Push(f);
 
     b.With(f->Block(), [&] {
         b.Access(ty.f32(), obj, 1_u, 1_u);
@@ -475,7 +461,6 @@
 
 TEST_F(IR_ValidateTest, Block_TerminatorInMiddle) {
     auto* f = b.Function("my_func", ty.void_());
-    mod.functions.Push(f);
 
     b.With(f->Block(), [&] {
         b.Return(f);
@@ -505,7 +490,6 @@
 
 TEST_F(IR_ValidateTest, If_ConditionIsBool) {
     auto* f = b.Function("my_func", ty.void_());
-    mod.functions.Push(f);
 
     auto* if_ = b.If(1_i);
     if_->True()->Append(b.Return(f));
@@ -567,7 +551,6 @@
     auto* v = mod.instructions.Create<ir::Var>(nullptr);
 
     auto* f = b.Function("my_func", ty.void_());
-    mod.functions.Push(f);
 
     auto sb = b.With(f->Block());
     sb.Append(v);
@@ -595,7 +578,6 @@
 
 TEST_F(IR_ValidateTest, Var_Init_WrongType) {
     auto* f = b.Function("my_func", ty.void_());
-    mod.functions.Push(f);
 
     auto sb = b.With(f->Block());
     auto* v = sb.Var(ty.ptr<function, f32>());
@@ -626,7 +608,6 @@
 
 TEST_F(IR_ValidateTest, Instruction_AppendedDead) {
     auto* f = b.Function("my_func", ty.void_());
-    mod.functions.Push(f);
 
     auto sb = b.With(f->Block());
     auto* v = sb.Var(ty.ptr<function, f32>());
@@ -665,7 +646,6 @@
 
 TEST_F(IR_ValidateTest, Instruction_NullSource) {
     auto* f = b.Function("my_func", ty.void_());
-    mod.functions.Push(f);
 
     auto sb = b.With(f->Block());
     auto* v = sb.Var(ty.ptr<function, f32>());
@@ -695,7 +675,6 @@
 
 TEST_F(IR_ValidateTest, Instruction_DeadOperand) {
     auto* f = b.Function("my_func", ty.void_());
-    mod.functions.Push(f);
 
     auto sb = b.With(f->Block());
     auto* v = sb.Var(ty.ptr<function, f32>());
@@ -727,7 +706,6 @@
 
 TEST_F(IR_ValidateTest, Instruction_OperandUsageRemoved) {
     auto* f = b.Function("my_func", ty.void_());
-    mod.functions.Push(f);
 
     auto sb = b.With(f->Block());
     auto* v = sb.Var(ty.ptr<function, f32>());
@@ -759,7 +737,6 @@
 
 TEST_F(IR_ValidateTest, Binary_LHS_Nullptr) {
     auto* f = b.Function("my_func", ty.void_());
-    mod.functions.Push(f);
 
     auto sb = b.With(f->Block());
     sb.Add(ty.i32(), nullptr, sb.Constant(2_i));
@@ -787,7 +764,6 @@
 
 TEST_F(IR_ValidateTest, Binary_RHS_Nullptr) {
     auto* f = b.Function("my_func", ty.void_());
-    mod.functions.Push(f);
 
     auto sb = b.With(f->Block());
     sb.Add(ty.i32(), sb.Constant(2_i), nullptr);
@@ -818,7 +794,6 @@
                                                     b.Constant(3_i), b.Constant(2_i));
 
     auto* f = b.Function("my_func", ty.void_());
-    mod.functions.Push(f);
 
     auto sb = b.With(f->Block());
     sb.Append(bin);
diff --git a/src/tint/transform/manager_test.cc b/src/tint/transform/manager_test.cc
index e578766..f8f8e0b 100644
--- a/src/tint/transform/manager_test.cc
+++ b/src/tint/transform/manager_test.cc
@@ -52,7 +52,6 @@
         ir::Builder builder(*mod);
         auto* func = builder.Function("ir_func", mod->Types().Get<type::Void>());
         func->Block()->Append(builder.Return(func));
-        mod->functions.Push(func);
     }
 };
 #endif  // TINT_BUILD_IR
@@ -69,7 +68,6 @@
     ir::Builder builder(mod);
     auto* func = builder.Function("main", mod.Types().Get<type::Void>());
     func->Block()->Append(builder.Return(func));
-    builder.ir.functions.Push(func);
     return mod;
 }
 #endif  // TINT_BUILD_IR
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_access_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_access_test.cc
index 40f4d4d..a6ed2f1 100644
--- a/src/tint/writer/spirv/ir/generator_impl_ir_access_test.cc
+++ b/src/tint/writer/spirv/ir/generator_impl_ir_access_test.cc
@@ -393,7 +393,7 @@
     func->SetParams({str_val});
 
     b.With(func->Block(), [&] {
-        b.Access(ty.i32(), str_val, 1_u);
+        b.Access(ty.f32(), str_val, 0_u);
         b.Access(ty.i32(), str_val, 1_u, 2_u);
         b.Return(func);
     });
@@ -416,7 +416,7 @@
 %1 = OpFunction %2 None %8
 %7 = OpFunctionParameter %3
 %9 = OpLabel
-%10 = OpCompositeExtract %6 %7 1
+%10 = OpCompositeExtract %4 %7 0
 %11 = OpCompositeExtract %6 %7 1 2
 OpReturn
 OpFunctionEnd
@@ -433,7 +433,7 @@
 
     b.With(func->Block(), [&] {
         auto* str_var = b.Var(ty.ptr(function, str, read_write));
-        b.Access(ty.ptr<function, i32>(), str_var, 1_u);
+        b.Access(ty.ptr<function, f32>(), str_var, 0_u);
         b.Access(ty.ptr<function, i32>(), str_var, 1_u, 2_u);
         b.Return(func);
     });
@@ -454,15 +454,17 @@
 %9 = OpTypeVector %10 4
 %7 = OpTypeStruct %8 %9
 %6 = OpTypePointer Function %7
-%12 = OpTypePointer Function %10
+%12 = OpTypePointer Function %8
 %14 = OpTypeInt 32 0
-%13 = OpConstant %14 1
-%16 = OpConstant %14 2
+%13 = OpConstant %14 0
+%16 = OpTypePointer Function %10
+%17 = OpConstant %14 1
+%18 = OpConstant %14 2
 %1 = OpFunction %2 None %3
 %4 = OpLabel
 %5 = OpVariable %6 Function
 %11 = OpAccessChain %12 %5 %13
-%15 = OpAccessChain %12 %5 %13 %16
+%15 = OpAccessChain %16 %5 %17 %18
 OpReturn
 OpFunctionEnd
 )");
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_var_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_var_test.cc
index f0d3e0d..7ec7d51 100644
--- a/src/tint/writer/spirv/ir/generator_impl_ir_var_test.cc
+++ b/src/tint/writer/spirv/ir/generator_impl_ir_var_test.cc
@@ -269,7 +269,6 @@
 
 TEST_F(SpvGeneratorImplTest, PrivateVar_LoadAndStore) {
     auto* func = b.Function("foo", ty.void_(), ir::Function::PipelineStage::kFragment);
-    mod.functions.Push(func);
 
     auto* store_ty = ty.i32();
     auto* v = b.Var(ty.ptr(private_, store_ty));
@@ -353,7 +352,6 @@
 TEST_F(SpvGeneratorImplTest, WorkgroupVar_LoadAndStore) {
     auto* func = b.Function("foo", ty.void_(), ir::Function::PipelineStage::kCompute,
                             std::array{1u, 1u, 1u});
-    mod.functions.Push(func);
 
     auto* store_ty = ty.i32();
     auto* v = b.RootBlock()->Append(b.Var(ty.ptr(workgroup, store_ty)));
@@ -479,7 +477,6 @@
 
     auto* func = b.Function("foo", ty.void_(), ir::Function::PipelineStage::kCompute,
                             std::array{1u, 1u, 1u});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         b.Load(v);
@@ -591,7 +588,6 @@
 
     auto* func = b.Function("foo", ty.void_(), ir::Function::PipelineStage::kCompute,
                             std::array{1u, 1u, 1u});
-    mod.functions.Push(func);
 
     b.With(func->Block(), [&] {
         b.Load(v);