Просмотр исходного кода

Add line-level debug info (#4247)

Seems to work with lldb ( https://pastebin.com/igKkNECm ), though gdb
has /some/ trouble with the paths (they aren't complete - just using the
filename directly, not providing the working directory - might be some
quick hacks that can help there).
David Blaikie 1 год назад
Родитель
Сommit
0ae2a3907e
100 измененных файлов с 1512 добавлено и 971 удалено
  1. 10 3
      toolchain/lower/file_context.cpp
  2. 4 0
      toolchain/lower/file_context.h
  3. 10 1
      toolchain/lower/function_context.cpp
  4. 3 0
      toolchain/lower/function_context.h
  5. 8 4
      toolchain/lower/testdata/alias/local.carbon
  6. 11 6
      toolchain/lower/testdata/array/array_in_place.carbon
  7. 23 18
      toolchain/lower/testdata/array/assign_return_value.carbon
  8. 48 33
      toolchain/lower/testdata/array/base.carbon
  9. 17 12
      toolchain/lower/testdata/array/function_param.carbon
  10. 6 4
      toolchain/lower/testdata/basics/false_true.carbon
  11. 14 10
      toolchain/lower/testdata/basics/int_types.carbon
  12. 22 15
      toolchain/lower/testdata/basics/numeric_literals.carbon
  13. 10 7
      toolchain/lower/testdata/basics/type_values.carbon
  14. 2 1
      toolchain/lower/testdata/basics/zero.carbon
  15. 64 42
      toolchain/lower/testdata/builtins/float.carbon
  16. 106 70
      toolchain/lower/testdata/builtins/int.carbon
  17. 10 6
      toolchain/lower/testdata/builtins/method_vs_nonmethod.carbon
  18. 8 6
      toolchain/lower/testdata/builtins/overloaded_operator.carbon
  19. 4 2
      toolchain/lower/testdata/builtins/print.carbon
  20. 14 7
      toolchain/lower/testdata/builtins/types.carbon
  21. 106 70
      toolchain/lower/testdata/builtins/uint.carbon
  22. 31 20
      toolchain/lower/testdata/class/adapt.carbon
  23. 29 21
      toolchain/lower/testdata/class/base.carbon
  24. 8 4
      toolchain/lower/testdata/class/basic.carbon
  25. 22 14
      toolchain/lower/testdata/class/field.carbon
  26. 6 3
      toolchain/lower/testdata/class/method.carbon
  27. 12 8
      toolchain/lower/testdata/class/self.carbon
  28. 19 17
      toolchain/lower/testdata/class/value_access.carbon
  29. 10 6
      toolchain/lower/testdata/function/call/empty_struct.carbon
  30. 10 6
      toolchain/lower/testdata/function/call/empty_tuple.carbon
  31. 12 7
      toolchain/lower/testdata/function/call/i32.carbon
  32. 17 11
      toolchain/lower/testdata/function/call/implicit_empty_tuple_as_arg.carbon
  33. 8 5
      toolchain/lower/testdata/function/call/params_one.carbon
  34. 10 6
      toolchain/lower/testdata/function/call/params_one_comma.carbon
  35. 8 5
      toolchain/lower/testdata/function/call/params_two.carbon
  36. 10 6
      toolchain/lower/testdata/function/call/params_two_comma.carbon
  37. 8 5
      toolchain/lower/testdata/function/call/params_zero.carbon
  38. 10 6
      toolchain/lower/testdata/function/call/return_implicit.carbon
  39. 8 5
      toolchain/lower/testdata/function/call/struct_param.carbon
  40. 8 5
      toolchain/lower/testdata/function/call/tuple_param.carbon
  41. 24 17
      toolchain/lower/testdata/function/call/tuple_param_with_return_slot.carbon
  42. 14 8
      toolchain/lower/testdata/function/call/var_param.carbon
  43. 4 2
      toolchain/lower/testdata/function/declaration/simple.carbon
  44. 2 1
      toolchain/lower/testdata/function/definition/empty_struct.carbon
  45. 2 1
      toolchain/lower/testdata/function/definition/params_one.carbon
  46. 2 1
      toolchain/lower/testdata/function/definition/params_two.carbon
  47. 2 1
      toolchain/lower/testdata/function/definition/params_zero.carbon
  48. 4 2
      toolchain/lower/testdata/global/class_obj.carbon
  49. 9 6
      toolchain/lower/testdata/global/class_with_fun.carbon
  50. 4 2
      toolchain/lower/testdata/global/simple_init.carbon
  51. 10 6
      toolchain/lower/testdata/global/simple_with_fun.carbon
  52. 25 16
      toolchain/lower/testdata/if/else.carbon
  53. 18 11
      toolchain/lower/testdata/if/no_else.carbon
  54. 18 12
      toolchain/lower/testdata/if_expr/basic.carbon
  55. 14 10
      toolchain/lower/testdata/if_expr/empty_block.carbon
  56. 11 7
      toolchain/lower/testdata/impl/assoc_fn_alias.carbon
  57. 14 9
      toolchain/lower/testdata/impl/extend_impl.carbon
  58. 11 7
      toolchain/lower/testdata/impl/impl.carbon
  59. 8 5
      toolchain/lower/testdata/impl/instance_method.carbon
  60. 53 37
      toolchain/lower/testdata/index/array_element_access.carbon
  61. 2 1
      toolchain/lower/testdata/interface/assoc.carbon
  62. 6 4
      toolchain/lower/testdata/interface/basic.carbon
  63. 2 1
      toolchain/lower/testdata/let/local.carbon
  64. 52 41
      toolchain/lower/testdata/let/tuple.carbon
  65. 12 8
      toolchain/lower/testdata/namespace/function.carbon
  66. 8 5
      toolchain/lower/testdata/namespace/nested.carbon
  67. 16 11
      toolchain/lower/testdata/operators/and.carbon
  68. 5 3
      toolchain/lower/testdata/operators/and_empty_block.carbon
  69. 15 8
      toolchain/lower/testdata/operators/assignment.carbon
  70. 4 2
      toolchain/lower/testdata/operators/not.carbon
  71. 17 12
      toolchain/lower/testdata/operators/or.carbon
  72. 6 4
      toolchain/lower/testdata/operators/or_empty_block.carbon
  73. 49 34
      toolchain/lower/testdata/operators/overloaded.carbon
  74. 6 3
      toolchain/lower/testdata/packages/cross_package_call.carbon
  75. 13 7
      toolchain/lower/testdata/pointer/address_of_field.carbon
  76. 6 3
      toolchain/lower/testdata/pointer/address_of_unused.carbon
  77. 14 8
      toolchain/lower/testdata/pointer/basic.carbon
  78. 22 11
      toolchain/lower/testdata/pointer/pointer_to_pointer.carbon
  79. 6 4
      toolchain/lower/testdata/return/code_after_return.carbon
  80. 2 1
      toolchain/lower/testdata/return/no_value.carbon
  81. 6 4
      toolchain/lower/testdata/return/return_var.carbon
  82. 7 4
      toolchain/lower/testdata/return/return_var_byval.carbon
  83. 2 1
      toolchain/lower/testdata/return/value.carbon
  84. 8 4
      toolchain/lower/testdata/return/var.carbon
  85. 6 3
      toolchain/lower/testdata/struct/empty.carbon
  86. 22 12
      toolchain/lower/testdata/struct/member_access.carbon
  87. 2 1
      toolchain/lower/testdata/struct/nested_struct.carbon
  88. 11 6
      toolchain/lower/testdata/struct/nested_struct_in_place.carbon
  89. 14 8
      toolchain/lower/testdata/struct/one_entry.carbon
  90. 20 14
      toolchain/lower/testdata/struct/two_entries.carbon
  91. 24 14
      toolchain/lower/testdata/tuple/access/element_access.carbon
  92. 19 13
      toolchain/lower/testdata/tuple/access/return_value_access.carbon
  93. 6 3
      toolchain/lower/testdata/tuple/empty.carbon
  94. 2 1
      toolchain/lower/testdata/tuple/nested_tuple.carbon
  95. 11 6
      toolchain/lower/testdata/tuple/nested_tuple_in_place.carbon
  96. 14 8
      toolchain/lower/testdata/tuple/one_entry.carbon
  97. 20 14
      toolchain/lower/testdata/tuple/two_entries.carbon
  98. 42 35
      toolchain/lower/testdata/tuple/value_formation.carbon
  99. 10 7
      toolchain/lower/testdata/tuple/value_forwarding.carbon
  100. 8 4
      toolchain/lower/testdata/var/local.carbon

+ 10 - 3
toolchain/lower/file_context.cpp

@@ -291,9 +291,9 @@ auto FileContext::BuildFunctionDefinition(SemIR::FunctionId function_id)
     return;
   }
 
-  llvm_function->setSubprogram(BuildDISubprogram(function, llvm_function));
-
-  FunctionContext function_lowering(*this, llvm_function, vlog_stream_);
+  FunctionContext function_lowering(*this, llvm_function,
+                                    BuildDISubprogram(function, llvm_function),
+                                    vlog_stream_);
 
   // TODO: Pass in a specific ID for generic functions.
   const auto specific_id = SemIR::SpecificId::Invalid;
@@ -540,4 +540,11 @@ auto FileContext::BuildGlobalVariableDecl(SemIR::VarStorage var_storage)
                                   /*Initializer=*/nullptr, mangled_name);
 }
 
+auto FileContext::GetDiagnosticLoc(SemIR::InstId inst_id) -> DiagnosticLoc {
+  return converter_.ConvertLoc(
+      inst_id,
+      [&](DiagnosticLoc /*context_loc*/,
+          const Internal::DiagnosticBase<>& /*context_diagnostic_base*/) {});
+}
+
 }  // namespace Carbon::Lower

+ 4 - 0
toolchain/lower/file_context.h

@@ -46,6 +46,9 @@ class FileContext {
     return types_[type_id.index];
   }
 
+  // Returns the DiagnosticLoc associated with the specified inst_id.
+  auto GetDiagnosticLoc(SemIR::InstId inst_id) -> DiagnosticLoc;
+
   // Returns a lowered value to use for a value of type `type`.
   auto GetTypeAsValue() -> llvm::Constant* {
     return llvm::ConstantStruct::get(GetTypeType());
@@ -104,6 +107,7 @@ class FileContext {
   // The DICompileUnit, if any - null implies debug info is not being emitted.
   llvm::DICompileUnit* di_compile_unit_;
 
+  // The source location converter.
   const Check::SemIRDiagnosticConverter& converter_;
 
   // The input SemIR.

+ 10 - 1
toolchain/lower/function_context.cpp

@@ -12,12 +12,16 @@ namespace Carbon::Lower {
 
 FunctionContext::FunctionContext(FileContext& file_context,
                                  llvm::Function* function,
+                                 llvm::DISubprogram* di_subprogram,
                                  llvm::raw_ostream* vlog_stream)
     : file_context_(&file_context),
       function_(function),
       builder_(file_context.llvm_context(), llvm::ConstantFolder(),
                Inserter(file_context.inst_namer())),
-      vlog_stream_(vlog_stream) {}
+      di_subprogram_(di_subprogram),
+      vlog_stream_(vlog_stream) {
+  function_->setSubprogram(di_subprogram_);
+}
 
 auto FunctionContext::GetBlock(SemIR::InstBlockId block_id)
     -> llvm::BasicBlock* {
@@ -93,6 +97,10 @@ auto FunctionContext::LowerInst(SemIR::InstId inst_id) -> void {
   auto inst = sem_ir().insts().Get(inst_id);
   CARBON_VLOG() << "Lowering " << inst_id << ": " << inst << "\n";
   builder_.getInserter().SetCurrentInstId(inst_id);
+  auto loc = file_context_->GetDiagnosticLoc(inst_id);
+  builder_.SetCurrentDebugLocation(
+      llvm::DILocation::get(builder_.getContext(), loc.line_number,
+                            loc.column_number, di_subprogram_));
 
   CARBON_KIND_SWITCH(inst) {
 #define CARBON_SEM_IR_INST_KIND(Name)            \
@@ -104,6 +112,7 @@ auto FunctionContext::LowerInst(SemIR::InstId inst_id) -> void {
   }
 
   builder_.getInserter().SetCurrentInstId(SemIR::InstId::Invalid);
+  builder_.SetCurrentDebugLocation(llvm::DebugLoc());
 }
 
 auto FunctionContext::GetBlockArg(SemIR::InstBlockId block_id,

+ 3 - 0
toolchain/lower/function_context.h

@@ -19,6 +19,7 @@ namespace Carbon::Lower {
 class FunctionContext {
  public:
   explicit FunctionContext(FileContext& file_context, llvm::Function* function,
+                           llvm::DISubprogram* di_subprogram,
                            llvm::raw_ostream* vlog_stream);
 
   // Returns a basic block corresponding to the start of the given semantics
@@ -149,6 +150,8 @@ class FunctionContext {
 
   llvm::IRBuilder<llvm::ConstantFolder, Inserter> builder_;
 
+  llvm::DISubprogram* di_subprogram_;
+
   // The optional vlog stream.
   llvm::raw_ostream* vlog_stream_;
 

+ 8 - 4
toolchain/lower/testdata/alias/local.carbon

@@ -19,10 +19,10 @@ fn F() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %a.var = alloca i32, align 4
-// CHECK:STDOUT:   store i32 0, ptr %a.var, align 4
-// CHECK:STDOUT:   %.loc14 = load i32, ptr %a.var, align 4
-// CHECK:STDOUT:   ret i32 %.loc14
+// CHECK:STDOUT:   %a.var = alloca i32, align 4, !dbg !7
+// CHECK:STDOUT:   store i32 0, ptr %a.var, align 4, !dbg !8
+// CHECK:STDOUT:   %.loc14 = load i32, ptr %a.var, align 4, !dbg !9
+// CHECK:STDOUT:   ret i32 %.loc14, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -35,3 +35,7 @@ fn F() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 10, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 3, scope: !4)

+ 11 - 6
toolchain/lower/testdata/array/array_in_place.carbon

@@ -21,12 +21,12 @@ fn G() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @G() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %v.var = alloca [2 x { i32, i32, i32 }], align 8
-// CHECK:STDOUT:   %.loc14_42.2.array.index = getelementptr inbounds [2 x { i32, i32, i32 }], ptr %v.var, i32 0, i32 0
-// CHECK:STDOUT:   call void @F(ptr %.loc14_42.2.array.index)
-// CHECK:STDOUT:   %.loc14_42.5.array.index = getelementptr inbounds [2 x { i32, i32, i32 }], ptr %v.var, i32 0, i32 1
-// CHECK:STDOUT:   call void @F(ptr %.loc14_42.5.array.index)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %v.var = alloca [2 x { i32, i32, i32 }], align 8, !dbg !7
+// CHECK:STDOUT:   %.loc14_42.2.array.index = getelementptr inbounds [2 x { i32, i32, i32 }], ptr %v.var, i32 0, i32 0, !dbg !8
+// CHECK:STDOUT:   call void @F(ptr %.loc14_42.2.array.index), !dbg !9
+// CHECK:STDOUT:   %.loc14_42.5.array.index = getelementptr inbounds [2 x { i32, i32, i32 }], ptr %v.var, i32 0, i32 1, !dbg !8
+// CHECK:STDOUT:   call void @F(ptr %.loc14_42.5.array.index), !dbg !10
+// CHECK:STDOUT:   ret void, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -39,3 +39,8 @@ fn G() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 33, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 34, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 39, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 1, scope: !4)

+ 23 - 18
toolchain/lower/testdata/array/assign_return_value.carbon

@@ -21,26 +21,26 @@ fn Run() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F(ptr sret({ i32, i32 }) %return) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc11_38.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 0
-// CHECK:STDOUT:   %.loc11_38.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 1
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %return, ptr align 4 @tuple.loc11_39, i64 8, i1 false)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %.loc11_38.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 0, !dbg !7
+// CHECK:STDOUT:   %.loc11_38.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 1, !dbg !7
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %return, ptr align 4 @tuple.loc11_39, i64 8, i1 false), !dbg !8
+// CHECK:STDOUT:   ret void, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @main() !dbg !7 {
+// CHECK:STDOUT: define void @main() !dbg !9 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %t.var = alloca [2 x i32], align 4
-// CHECK:STDOUT:   %.loc14_22.1.temp = alloca { i32, i32 }, align 8
-// CHECK:STDOUT:   call void @F(ptr %.loc14_22.1.temp)
-// CHECK:STDOUT:   %.loc14_22.3.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc14_22.1.temp, i32 0, i32 0
-// CHECK:STDOUT:   %.loc14_22.4 = load i32, ptr %.loc14_22.3.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc14_22.6.array.index = getelementptr inbounds [2 x i32], ptr %t.var, i32 0, i32 0
-// CHECK:STDOUT:   store i32 %.loc14_22.4, ptr %.loc14_22.6.array.index, align 4
-// CHECK:STDOUT:   %.loc14_22.8.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc14_22.1.temp, i32 0, i32 1
-// CHECK:STDOUT:   %.loc14_22.9 = load i32, ptr %.loc14_22.8.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc14_22.11.array.index = getelementptr inbounds [2 x i32], ptr %t.var, i32 0, i32 1
-// CHECK:STDOUT:   store i32 %.loc14_22.9, ptr %.loc14_22.11.array.index, align 4
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %t.var = alloca [2 x i32], align 4, !dbg !10
+// CHECK:STDOUT:   %.loc14_22.1.temp = alloca { i32, i32 }, align 8, !dbg !11
+// CHECK:STDOUT:   call void @F(ptr %.loc14_22.1.temp), !dbg !11
+// CHECK:STDOUT:   %.loc14_22.3.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc14_22.1.temp, i32 0, i32 0, !dbg !11
+// CHECK:STDOUT:   %.loc14_22.4 = load i32, ptr %.loc14_22.3.tuple.elem, align 4, !dbg !11
+// CHECK:STDOUT:   %.loc14_22.6.array.index = getelementptr inbounds [2 x i32], ptr %t.var, i32 0, i32 0, !dbg !11
+// CHECK:STDOUT:   store i32 %.loc14_22.4, ptr %.loc14_22.6.array.index, align 4, !dbg !11
+// CHECK:STDOUT:   %.loc14_22.8.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc14_22.1.temp, i32 0, i32 1, !dbg !11
+// CHECK:STDOUT:   %.loc14_22.9 = load i32, ptr %.loc14_22.8.tuple.elem, align 4, !dbg !11
+// CHECK:STDOUT:   %.loc14_22.11.array.index = getelementptr inbounds [2 x i32], ptr %t.var, i32 0, i32 1, !dbg !11
+// CHECK:STDOUT:   store i32 %.loc14_22.9, ptr %.loc14_22.11.array.index, align 4, !dbg !11
+// CHECK:STDOUT:   ret void, !dbg !12
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -58,4 +58,9 @@ fn Run() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 31, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 11, column: 24, scope: !4)
+// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 7, scope: !9)
+// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 21, scope: !9)
+// CHECK:STDOUT: !12 = !DILocation(line: 13, column: 1, scope: !9)

+ 48 - 33
toolchain/lower/testdata/array/base.carbon

@@ -26,39 +26,39 @@ fn Run() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %a.var = alloca [1 x i32], align 4
-// CHECK:STDOUT:   %.loc12_24.3.array.index = getelementptr inbounds [1 x i32], ptr %a.var, i32 0, i32 0
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a.var, ptr align 4 @array.1.loc12_25, i64 4, i1 false)
-// CHECK:STDOUT:   %b.var = alloca [2 x double], align 8
-// CHECK:STDOUT:   %.loc13_32.3.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc13_32.6.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i32 1
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 8 %b.var, ptr align 8 @array.2.loc13_33, i64 16, i1 false)
-// CHECK:STDOUT:   %c.var = alloca [5 x {}], align 8
-// CHECK:STDOUT:   %.loc14_40.3.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc14_40.6.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i32 1
-// CHECK:STDOUT:   %.loc14_40.9.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i32 2
-// CHECK:STDOUT:   %.loc14_40.12.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i32 3
-// CHECK:STDOUT:   %.loc14_40.15.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i32 4
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 1 %c.var, ptr align 1 @array.3.loc14_41, i64 0, i1 false)
-// CHECK:STDOUT:   %d.var = alloca { i32, i32, i32 }, align 8
-// CHECK:STDOUT:   %.loc15_36.2.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc15_36.4.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 1
-// CHECK:STDOUT:   %.loc15_36.6.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 2
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %d.var, ptr align 4 @tuple.2.loc15_37, i64 12, i1 false)
-// CHECK:STDOUT:   %e.var = alloca [3 x i32], align 4
-// CHECK:STDOUT:   %.loc16_21.1.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc16_21.2 = load i32, ptr %.loc16_21.1.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc16_21.4.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i32 0
-// CHECK:STDOUT:   store i32 %.loc16_21.2, ptr %.loc16_21.4.array.index, align 4
-// CHECK:STDOUT:   %.loc16_21.6.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 1
-// CHECK:STDOUT:   %.loc16_21.7 = load i32, ptr %.loc16_21.6.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc16_21.9.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i32 1
-// CHECK:STDOUT:   store i32 %.loc16_21.7, ptr %.loc16_21.9.array.index, align 4
-// CHECK:STDOUT:   %.loc16_21.11.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 2
-// CHECK:STDOUT:   %.loc16_21.12 = load i32, ptr %.loc16_21.11.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc16_21.14.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i32 2
-// CHECK:STDOUT:   store i32 %.loc16_21.12, ptr %.loc16_21.14.array.index, align 4
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %a.var = alloca [1 x i32], align 4, !dbg !7
+// CHECK:STDOUT:   %.loc12_24.3.array.index = getelementptr inbounds [1 x i32], ptr %a.var, i32 0, i32 0, !dbg !8
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a.var, ptr align 4 @array.1.loc12_25, i64 4, i1 false), !dbg !9
+// CHECK:STDOUT:   %b.var = alloca [2 x double], align 8, !dbg !10
+// CHECK:STDOUT:   %.loc13_32.3.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i32 0, !dbg !11
+// CHECK:STDOUT:   %.loc13_32.6.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i32 1, !dbg !11
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 8 %b.var, ptr align 8 @array.2.loc13_33, i64 16, i1 false), !dbg !12
+// CHECK:STDOUT:   %c.var = alloca [5 x {}], align 8, !dbg !13
+// CHECK:STDOUT:   %.loc14_40.3.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i32 0, !dbg !14
+// CHECK:STDOUT:   %.loc14_40.6.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i32 1, !dbg !14
+// CHECK:STDOUT:   %.loc14_40.9.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i32 2, !dbg !14
+// CHECK:STDOUT:   %.loc14_40.12.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i32 3, !dbg !14
+// CHECK:STDOUT:   %.loc14_40.15.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i32 4, !dbg !14
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 1 %c.var, ptr align 1 @array.3.loc14_41, i64 0, i1 false), !dbg !15
+// CHECK:STDOUT:   %d.var = alloca { i32, i32, i32 }, align 8, !dbg !16
+// CHECK:STDOUT:   %.loc15_36.2.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 0, !dbg !17
+// CHECK:STDOUT:   %.loc15_36.4.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 1, !dbg !17
+// CHECK:STDOUT:   %.loc15_36.6.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 2, !dbg !17
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %d.var, ptr align 4 @tuple.2.loc15_37, i64 12, i1 false), !dbg !18
+// CHECK:STDOUT:   %e.var = alloca [3 x i32], align 4, !dbg !19
+// CHECK:STDOUT:   %.loc16_21.1.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 0, !dbg !20
+// CHECK:STDOUT:   %.loc16_21.2 = load i32, ptr %.loc16_21.1.tuple.elem, align 4, !dbg !20
+// CHECK:STDOUT:   %.loc16_21.4.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i32 0, !dbg !20
+// CHECK:STDOUT:   store i32 %.loc16_21.2, ptr %.loc16_21.4.array.index, align 4, !dbg !20
+// CHECK:STDOUT:   %.loc16_21.6.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 1, !dbg !20
+// CHECK:STDOUT:   %.loc16_21.7 = load i32, ptr %.loc16_21.6.tuple.elem, align 4, !dbg !20
+// CHECK:STDOUT:   %.loc16_21.9.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i32 1, !dbg !20
+// CHECK:STDOUT:   store i32 %.loc16_21.7, ptr %.loc16_21.9.array.index, align 4, !dbg !20
+// CHECK:STDOUT:   %.loc16_21.11.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 2, !dbg !20
+// CHECK:STDOUT:   %.loc16_21.12 = load i32, ptr %.loc16_21.11.tuple.elem, align 4, !dbg !20
+// CHECK:STDOUT:   %.loc16_21.14.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i32 2, !dbg !20
+// CHECK:STDOUT:   store i32 %.loc16_21.12, ptr %.loc16_21.14.array.index, align 4, !dbg !20
+// CHECK:STDOUT:   ret void, !dbg !21
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -79,3 +79,18 @@ fn Run() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 21, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 7, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 21, scope: !4)
+// CHECK:STDOUT: !12 = !DILocation(line: 13, column: 3, scope: !4)
+// CHECK:STDOUT: !13 = !DILocation(line: 14, column: 7, scope: !4)
+// CHECK:STDOUT: !14 = !DILocation(line: 14, column: 20, scope: !4)
+// CHECK:STDOUT: !15 = !DILocation(line: 14, column: 3, scope: !4)
+// CHECK:STDOUT: !16 = !DILocation(line: 15, column: 7, scope: !4)
+// CHECK:STDOUT: !17 = !DILocation(line: 15, column: 28, scope: !4)
+// CHECK:STDOUT: !18 = !DILocation(line: 15, column: 3, scope: !4)
+// CHECK:STDOUT: !19 = !DILocation(line: 16, column: 7, scope: !4)
+// CHECK:STDOUT: !20 = !DILocation(line: 16, column: 21, scope: !4)
+// CHECK:STDOUT: !21 = !DILocation(line: 11, column: 1, scope: !4)

+ 17 - 12
toolchain/lower/testdata/array/function_param.carbon

@@ -23,20 +23,20 @@ fn G() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @F(ptr %arr, i32 %i) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc12_15.2.array.index = getelementptr inbounds [3 x i32], ptr %arr, i32 0, i32 %i
-// CHECK:STDOUT:   %.loc12_15.3 = load i32, ptr %.loc12_15.2.array.index, align 4
-// CHECK:STDOUT:   ret i32 %.loc12_15.3
+// CHECK:STDOUT:   %.loc12_15.2.array.index = getelementptr inbounds [3 x i32], ptr %arr, i32 0, i32 %i, !dbg !7
+// CHECK:STDOUT:   %.loc12_15.3 = load i32, ptr %.loc12_15.2.array.index, align 4, !dbg !7
+// CHECK:STDOUT:   ret i32 %.loc12_15.3, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @G() !dbg !7 {
+// CHECK:STDOUT: define i32 @G() !dbg !9 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc16_20.2.temp = alloca [3 x i32], align 4
-// CHECK:STDOUT:   %.loc16_20.4.array.index = getelementptr inbounds [3 x i32], ptr %.loc16_20.2.temp, i32 0, i32 0
-// CHECK:STDOUT:   %.loc16_20.7.array.index = getelementptr inbounds [3 x i32], ptr %.loc16_20.2.temp, i32 0, i32 1
-// CHECK:STDOUT:   %.loc16_20.10.array.index = getelementptr inbounds [3 x i32], ptr %.loc16_20.2.temp, i32 0, i32 2
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %.loc16_20.2.temp, ptr align 4 @array.loc16_11.1, i64 12, i1 false)
-// CHECK:STDOUT:   %F.call = call i32 @F(ptr %.loc16_20.2.temp, i32 1)
-// CHECK:STDOUT:   ret i32 %F.call
+// CHECK:STDOUT:   %.loc16_20.2.temp = alloca [3 x i32], align 4, !dbg !10
+// CHECK:STDOUT:   %.loc16_20.4.array.index = getelementptr inbounds [3 x i32], ptr %.loc16_20.2.temp, i32 0, i32 0, !dbg !10
+// CHECK:STDOUT:   %.loc16_20.7.array.index = getelementptr inbounds [3 x i32], ptr %.loc16_20.2.temp, i32 0, i32 1, !dbg !10
+// CHECK:STDOUT:   %.loc16_20.10.array.index = getelementptr inbounds [3 x i32], ptr %.loc16_20.2.temp, i32 0, i32 2, !dbg !10
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %.loc16_20.2.temp, ptr align 4 @array.loc16_11.1, i64 12, i1 false), !dbg !11
+// CHECK:STDOUT:   %F.call = call i32 @F(ptr %.loc16_20.2.temp, i32 1), !dbg !11
+// CHECK:STDOUT:   ret i32 %F.call, !dbg !12
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -54,4 +54,9 @@ fn G() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 10, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !10 = !DILocation(line: 16, column: 12, scope: !9)
+// CHECK:STDOUT: !11 = !DILocation(line: 16, column: 10, scope: !9)
+// CHECK:STDOUT: !12 = !DILocation(line: 16, column: 3, scope: !9)

+ 6 - 4
toolchain/lower/testdata/basics/false_true.carbon

@@ -21,12 +21,12 @@ fn T() -> bool {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i1 @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i1 false
+// CHECK:STDOUT:   ret i1 false, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @T() !dbg !7 {
+// CHECK:STDOUT: define i1 @T() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i1 true
+// CHECK:STDOUT:   ret i1 true, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -39,4 +39,6 @@ fn T() -> bool {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "T", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "T", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 3, scope: !8)

+ 14 - 10
toolchain/lower/testdata/basics/int_types.carbon

@@ -18,22 +18,22 @@ fn F_u65536(a: u65536) -> u65536 { return a; }
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i8 @F_i8(i8 %a) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i8 %a
+// CHECK:STDOUT:   ret i8 %a, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i16 @F_u16(i16 %a) !dbg !7 {
+// CHECK:STDOUT: define i16 @F_u16(i16 %a) !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i16 %a
+// CHECK:STDOUT:   ret i16 %a, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i64 @F_i64(i64 %a) !dbg !8 {
+// CHECK:STDOUT: define i64 @F_i64(i64 %a) !dbg !10 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i64 %a
+// CHECK:STDOUT:   ret i64 %a, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i65536 @F_u65536(i65536 %a) !dbg !9 {
+// CHECK:STDOUT: define i65536 @F_u65536(i65536 %a) !dbg !12 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i65536 %a
+// CHECK:STDOUT:   ret i65536 %a, !dbg !13
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -46,6 +46,10 @@ fn F_u65536(a: u65536) -> u65536 { return a; }
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F_i8", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "F_u16", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "F_i64", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "F_u65536", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 24, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "F_u16", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 27, scope: !8)
+// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "F_i64", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 27, scope: !10)
+// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "F_u65536", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !13 = !DILocation(line: 14, column: 36, scope: !12)

+ 22 - 15
toolchain/lower/testdata/basics/numeric_literals.carbon

@@ -35,21 +35,21 @@ fn F() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %ints.var = alloca [4 x i32], align 4
-// CHECK:STDOUT:   %.loc19_3.3.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc19_3.6.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i32 1
-// CHECK:STDOUT:   %.loc19_3.9.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i32 2
-// CHECK:STDOUT:   %.loc19_3.12.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i32 3
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %ints.var, ptr align 4 @array.1.loc19_4, i64 16, i1 false)
-// CHECK:STDOUT:   %floats.var = alloca [6 x double], align 8
-// CHECK:STDOUT:   %.loc27_3.3.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc27_3.6.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 1
-// CHECK:STDOUT:   %.loc27_3.9.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 2
-// CHECK:STDOUT:   %.loc27_3.12.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 3
-// CHECK:STDOUT:   %.loc27_3.15.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 4
-// CHECK:STDOUT:   %.loc27_3.18.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 5
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 8 %floats.var, ptr align 8 @array.2.loc27_4, i64 48, i1 false)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %ints.var = alloca [4 x i32], align 4, !dbg !7
+// CHECK:STDOUT:   %.loc19_3.3.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i32 0, !dbg !8
+// CHECK:STDOUT:   %.loc19_3.6.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i32 1, !dbg !8
+// CHECK:STDOUT:   %.loc19_3.9.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i32 2, !dbg !8
+// CHECK:STDOUT:   %.loc19_3.12.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i32 3, !dbg !8
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %ints.var, ptr align 4 @array.1.loc19_4, i64 16, i1 false), !dbg !9
+// CHECK:STDOUT:   %floats.var = alloca [6 x double], align 8, !dbg !10
+// CHECK:STDOUT:   %.loc27_3.3.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 0, !dbg !11
+// CHECK:STDOUT:   %.loc27_3.6.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 1, !dbg !11
+// CHECK:STDOUT:   %.loc27_3.9.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 2, !dbg !11
+// CHECK:STDOUT:   %.loc27_3.12.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 3, !dbg !11
+// CHECK:STDOUT:   %.loc27_3.15.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 4, !dbg !11
+// CHECK:STDOUT:   %.loc27_3.18.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 5, !dbg !11
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 8 %floats.var, ptr align 8 @array.2.loc27_4, i64 48, i1 false), !dbg !12
+// CHECK:STDOUT:   ret void, !dbg !13
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -70,3 +70,10 @@ fn F() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 24, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 20, column: 7, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 20, column: 26, scope: !4)
+// CHECK:STDOUT: !12 = !DILocation(line: 20, column: 3, scope: !4)
+// CHECK:STDOUT: !13 = !DILocation(line: 11, column: 1, scope: !4)

+ 10 - 7
toolchain/lower/testdata/basics/type_values.carbon

@@ -30,17 +30,17 @@ fn F64() -> type {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define %type @I32() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret %type zeroinitializer
+// CHECK:STDOUT:   ret %type zeroinitializer, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define %type @I48() !dbg !7 {
+// CHECK:STDOUT: define %type @I48() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret %type zeroinitializer
+// CHECK:STDOUT:   ret %type zeroinitializer, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define %type @F64() !dbg !8 {
+// CHECK:STDOUT: define %type @F64() !dbg !10 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret %type zeroinitializer
+// CHECK:STDOUT:   ret %type zeroinitializer, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -53,5 +53,8 @@ fn F64() -> type {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "I32", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "I48", scope: null, file: !3, line: 18, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "F64", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 15, column: 3, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "I48", scope: null, file: !3, line: 18, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 19, column: 3, scope: !8)
+// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "F64", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !11 = !DILocation(line: 23, column: 3, scope: !10)

+ 2 - 1
toolchain/lower/testdata/basics/zero.carbon

@@ -17,7 +17,7 @@ fn Main() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @Main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i32 0
+// CHECK:STDOUT:   ret i32 0, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -30,3 +30,4 @@ fn Main() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4)

+ 64 - 42
toolchain/lower/testdata/builtins/float.carbon

@@ -46,68 +46,68 @@ fn TestGreaterEq(a: f64, b: f64) -> bool { return GreaterEq(a, b); }
 // CHECK:STDOUT:
 // CHECK:STDOUT: define double @TestNegate(double %a) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %float.negate = fneg double %a
-// CHECK:STDOUT:   ret double %float.negate
+// CHECK:STDOUT:   %float.negate = fneg double %a, !dbg !7
+// CHECK:STDOUT:   ret double %float.negate, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define double @TestAdd(double %a, double %b) !dbg !7 {
+// CHECK:STDOUT: define double @TestAdd(double %a, double %b) !dbg !9 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %float.add = fadd double %a, %b
-// CHECK:STDOUT:   ret double %float.add
+// CHECK:STDOUT:   %float.add = fadd double %a, %b, !dbg !10
+// CHECK:STDOUT:   ret double %float.add, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define double @TestSub(double %a, double %b) !dbg !8 {
+// CHECK:STDOUT: define double @TestSub(double %a, double %b) !dbg !12 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %float.sub = fsub double %a, %b
-// CHECK:STDOUT:   ret double %float.sub
+// CHECK:STDOUT:   %float.sub = fsub double %a, %b, !dbg !13
+// CHECK:STDOUT:   ret double %float.sub, !dbg !14
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define double @TestMul(double %a, double %b) !dbg !9 {
+// CHECK:STDOUT: define double @TestMul(double %a, double %b) !dbg !15 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %float.mul = fmul double %a, %b
-// CHECK:STDOUT:   ret double %float.mul
+// CHECK:STDOUT:   %float.mul = fmul double %a, %b, !dbg !16
+// CHECK:STDOUT:   ret double %float.mul, !dbg !17
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define double @TestDiv(double %a, double %b) !dbg !10 {
+// CHECK:STDOUT: define double @TestDiv(double %a, double %b) !dbg !18 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %float.div = fdiv double %a, %b
-// CHECK:STDOUT:   ret double %float.div
+// CHECK:STDOUT:   %float.div = fdiv double %a, %b, !dbg !19
+// CHECK:STDOUT:   ret double %float.div, !dbg !20
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestEq(double %a, double %b) !dbg !11 {
+// CHECK:STDOUT: define i1 @TestEq(double %a, double %b) !dbg !21 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %float.eq = fcmp oeq double %a, %b
-// CHECK:STDOUT:   ret i1 %float.eq
+// CHECK:STDOUT:   %float.eq = fcmp oeq double %a, %b, !dbg !22
+// CHECK:STDOUT:   ret i1 %float.eq, !dbg !23
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestNeq(double %a, double %b) !dbg !12 {
+// CHECK:STDOUT: define i1 @TestNeq(double %a, double %b) !dbg !24 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %float.neq = fcmp one double %a, %b
-// CHECK:STDOUT:   ret i1 %float.neq
+// CHECK:STDOUT:   %float.neq = fcmp one double %a, %b, !dbg !25
+// CHECK:STDOUT:   ret i1 %float.neq, !dbg !26
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestLess(double %a, double %b) !dbg !13 {
+// CHECK:STDOUT: define i1 @TestLess(double %a, double %b) !dbg !27 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %float.less = fcmp olt double %a, %b
-// CHECK:STDOUT:   ret i1 %float.less
+// CHECK:STDOUT:   %float.less = fcmp olt double %a, %b, !dbg !28
+// CHECK:STDOUT:   ret i1 %float.less, !dbg !29
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestLessEq(double %a, double %b) !dbg !14 {
+// CHECK:STDOUT: define i1 @TestLessEq(double %a, double %b) !dbg !30 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %float.less_eq = fcmp ole double %a, %b
-// CHECK:STDOUT:   ret i1 %float.less_eq
+// CHECK:STDOUT:   %float.less_eq = fcmp ole double %a, %b, !dbg !31
+// CHECK:STDOUT:   ret i1 %float.less_eq, !dbg !32
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestGreater(double %a, double %b) !dbg !15 {
+// CHECK:STDOUT: define i1 @TestGreater(double %a, double %b) !dbg !33 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %float.greater = fcmp ogt double %a, %b
-// CHECK:STDOUT:   ret i1 %float.greater
+// CHECK:STDOUT:   %float.greater = fcmp ogt double %a, %b, !dbg !34
+// CHECK:STDOUT:   ret i1 %float.greater, !dbg !35
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestGreaterEq(double %a, double %b) !dbg !16 {
+// CHECK:STDOUT: define i1 @TestGreaterEq(double %a, double %b) !dbg !36 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %float.greater_eq = fcmp oge double %a, %b
-// CHECK:STDOUT:   ret i1 %float.greater_eq
+// CHECK:STDOUT:   %float.greater_eq = fcmp oge double %a, %b, !dbg !37
+// CHECK:STDOUT:   ret i1 %float.greater_eq, !dbg !38
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -120,13 +120,35 @@ fn TestGreaterEq(a: f64, b: f64) -> bool { return GreaterEq(a, b); }
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "TestNegate", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "TestAdd", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "TestSub", scope: null, file: !3, line: 18, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "TestMul", scope: null, file: !3, line: 21, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "TestDiv", scope: null, file: !3, line: 24, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !11 = distinct !DISubprogram(name: "TestEq", scope: null, file: !3, line: 27, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "TestNeq", scope: null, file: !3, line: 30, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !13 = distinct !DISubprogram(name: "TestLess", scope: null, file: !3, line: 33, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !14 = distinct !DISubprogram(name: "TestLessEq", scope: null, file: !3, line: 36, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !15 = distinct !DISubprogram(name: "TestGreater", scope: null, file: !3, line: 39, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !16 = distinct !DISubprogram(name: "TestGreaterEq", scope: null, file: !3, line: 42, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 39, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 32, scope: !4)
+// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "TestAdd", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 44, scope: !9)
+// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 37, scope: !9)
+// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "TestSub", scope: null, file: !3, line: 18, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !13 = !DILocation(line: 18, column: 44, scope: !12)
+// CHECK:STDOUT: !14 = !DILocation(line: 18, column: 37, scope: !12)
+// CHECK:STDOUT: !15 = distinct !DISubprogram(name: "TestMul", scope: null, file: !3, line: 21, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !16 = !DILocation(line: 21, column: 44, scope: !15)
+// CHECK:STDOUT: !17 = !DILocation(line: 21, column: 37, scope: !15)
+// CHECK:STDOUT: !18 = distinct !DISubprogram(name: "TestDiv", scope: null, file: !3, line: 24, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !19 = !DILocation(line: 24, column: 44, scope: !18)
+// CHECK:STDOUT: !20 = !DILocation(line: 24, column: 37, scope: !18)
+// CHECK:STDOUT: !21 = distinct !DISubprogram(name: "TestEq", scope: null, file: !3, line: 27, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !22 = !DILocation(line: 27, column: 44, scope: !21)
+// CHECK:STDOUT: !23 = !DILocation(line: 27, column: 37, scope: !21)
+// CHECK:STDOUT: !24 = distinct !DISubprogram(name: "TestNeq", scope: null, file: !3, line: 30, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !25 = !DILocation(line: 30, column: 45, scope: !24)
+// CHECK:STDOUT: !26 = !DILocation(line: 30, column: 38, scope: !24)
+// CHECK:STDOUT: !27 = distinct !DISubprogram(name: "TestLess", scope: null, file: !3, line: 33, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !28 = !DILocation(line: 33, column: 46, scope: !27)
+// CHECK:STDOUT: !29 = !DILocation(line: 33, column: 39, scope: !27)
+// CHECK:STDOUT: !30 = distinct !DISubprogram(name: "TestLessEq", scope: null, file: !3, line: 36, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !31 = !DILocation(line: 36, column: 48, scope: !30)
+// CHECK:STDOUT: !32 = !DILocation(line: 36, column: 41, scope: !30)
+// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "TestGreater", scope: null, file: !3, line: 39, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !34 = !DILocation(line: 39, column: 49, scope: !33)
+// CHECK:STDOUT: !35 = !DILocation(line: 39, column: 42, scope: !33)
+// CHECK:STDOUT: !36 = distinct !DISubprogram(name: "TestGreaterEq", scope: null, file: !3, line: 42, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !37 = !DILocation(line: 42, column: 51, scope: !36)
+// CHECK:STDOUT: !38 = !DILocation(line: 42, column: 44, scope: !36)

+ 106 - 70
toolchain/lower/testdata/builtins/int.carbon

@@ -67,110 +67,110 @@ fn TestGreaterEq(a: i32, b: i32) -> bool { return GreaterEq(a, b); }
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @TestNegate(i32 %a) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.snegate = sub i32 0, %a
-// CHECK:STDOUT:   ret i32 %int.snegate
+// CHECK:STDOUT:   %int.snegate = sub i32 0, %a, !dbg !7
+// CHECK:STDOUT:   ret i32 %int.snegate, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @TestAdd(i32 %a, i32 %b) !dbg !7 {
+// CHECK:STDOUT: define i32 @TestAdd(i32 %a, i32 %b) !dbg !9 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.sadd = add i32 %a, %b
-// CHECK:STDOUT:   ret i32 %int.sadd
+// CHECK:STDOUT:   %int.sadd = add i32 %a, %b, !dbg !10
+// CHECK:STDOUT:   ret i32 %int.sadd, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @TestSub(i32 %a, i32 %b) !dbg !8 {
+// CHECK:STDOUT: define i32 @TestSub(i32 %a, i32 %b) !dbg !12 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.ssub = sub i32 %a, %b
-// CHECK:STDOUT:   ret i32 %int.ssub
+// CHECK:STDOUT:   %int.ssub = sub i32 %a, %b, !dbg !13
+// CHECK:STDOUT:   ret i32 %int.ssub, !dbg !14
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @TestMul(i32 %a, i32 %b) !dbg !9 {
+// CHECK:STDOUT: define i32 @TestMul(i32 %a, i32 %b) !dbg !15 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.smul = mul i32 %a, %b
-// CHECK:STDOUT:   ret i32 %int.smul
+// CHECK:STDOUT:   %int.smul = mul i32 %a, %b, !dbg !16
+// CHECK:STDOUT:   ret i32 %int.smul, !dbg !17
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @TestDiv(i32 %a, i32 %b) !dbg !10 {
+// CHECK:STDOUT: define i32 @TestDiv(i32 %a, i32 %b) !dbg !18 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.sdiv = sdiv i32 %a, %b
-// CHECK:STDOUT:   ret i32 %int.sdiv
+// CHECK:STDOUT:   %int.sdiv = sdiv i32 %a, %b, !dbg !19
+// CHECK:STDOUT:   ret i32 %int.sdiv, !dbg !20
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @TestMod(i32 %a, i32 %b) !dbg !11 {
+// CHECK:STDOUT: define i32 @TestMod(i32 %a, i32 %b) !dbg !21 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.smod = srem i32 %a, %b
-// CHECK:STDOUT:   ret i32 %int.smod
+// CHECK:STDOUT:   %int.smod = srem i32 %a, %b, !dbg !22
+// CHECK:STDOUT:   ret i32 %int.smod, !dbg !23
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @TestComplement(i32 %a) !dbg !12 {
+// CHECK:STDOUT: define i32 @TestComplement(i32 %a) !dbg !24 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.complement = xor i32 -1, %a
-// CHECK:STDOUT:   ret i32 %int.complement
+// CHECK:STDOUT:   %int.complement = xor i32 -1, %a, !dbg !25
+// CHECK:STDOUT:   ret i32 %int.complement, !dbg !26
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @TestAnd(i32 %a, i32 %b) !dbg !13 {
+// CHECK:STDOUT: define i32 @TestAnd(i32 %a, i32 %b) !dbg !27 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.and = and i32 %a, %b
-// CHECK:STDOUT:   ret i32 %int.and
+// CHECK:STDOUT:   %int.and = and i32 %a, %b, !dbg !28
+// CHECK:STDOUT:   ret i32 %int.and, !dbg !29
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @TestOr(i32 %a, i32 %b) !dbg !14 {
+// CHECK:STDOUT: define i32 @TestOr(i32 %a, i32 %b) !dbg !30 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.or = or i32 %a, %b
-// CHECK:STDOUT:   ret i32 %int.or
+// CHECK:STDOUT:   %int.or = or i32 %a, %b, !dbg !31
+// CHECK:STDOUT:   ret i32 %int.or, !dbg !32
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @TestXor(i32 %a, i32 %b) !dbg !15 {
+// CHECK:STDOUT: define i32 @TestXor(i32 %a, i32 %b) !dbg !33 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.xor = xor i32 %a, %b
-// CHECK:STDOUT:   ret i32 %int.xor
+// CHECK:STDOUT:   %int.xor = xor i32 %a, %b, !dbg !34
+// CHECK:STDOUT:   ret i32 %int.xor, !dbg !35
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @TestLeftShift(i32 %a, i32 %b) !dbg !16 {
+// CHECK:STDOUT: define i32 @TestLeftShift(i32 %a, i32 %b) !dbg !36 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.left_shift = shl i32 %a, %b
-// CHECK:STDOUT:   ret i32 %int.left_shift
+// CHECK:STDOUT:   %int.left_shift = shl i32 %a, %b, !dbg !37
+// CHECK:STDOUT:   ret i32 %int.left_shift, !dbg !38
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @TestRightShift(i32 %a, i32 %b) !dbg !17 {
+// CHECK:STDOUT: define i32 @TestRightShift(i32 %a, i32 %b) !dbg !39 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.right_shift = ashr i32 %a, %b
-// CHECK:STDOUT:   ret i32 %int.right_shift
+// CHECK:STDOUT:   %int.right_shift = ashr i32 %a, %b, !dbg !40
+// CHECK:STDOUT:   ret i32 %int.right_shift, !dbg !41
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestEq(i32 %a, i32 %b) !dbg !18 {
+// CHECK:STDOUT: define i1 @TestEq(i32 %a, i32 %b) !dbg !42 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.eq = icmp eq i32 %a, %b
-// CHECK:STDOUT:   ret i1 %int.eq
+// CHECK:STDOUT:   %int.eq = icmp eq i32 %a, %b, !dbg !43
+// CHECK:STDOUT:   ret i1 %int.eq, !dbg !44
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestNeq(i32 %a, i32 %b) !dbg !19 {
+// CHECK:STDOUT: define i1 @TestNeq(i32 %a, i32 %b) !dbg !45 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.neq = icmp ne i32 %a, %b
-// CHECK:STDOUT:   ret i1 %int.neq
+// CHECK:STDOUT:   %int.neq = icmp ne i32 %a, %b, !dbg !46
+// CHECK:STDOUT:   ret i1 %int.neq, !dbg !47
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestLess(i32 %a, i32 %b) !dbg !20 {
+// CHECK:STDOUT: define i1 @TestLess(i32 %a, i32 %b) !dbg !48 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.less = icmp slt i32 %a, %b
-// CHECK:STDOUT:   ret i1 %int.less
+// CHECK:STDOUT:   %int.less = icmp slt i32 %a, %b, !dbg !49
+// CHECK:STDOUT:   ret i1 %int.less, !dbg !50
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestLessEq(i32 %a, i32 %b) !dbg !21 {
+// CHECK:STDOUT: define i1 @TestLessEq(i32 %a, i32 %b) !dbg !51 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.less_eq = icmp sle i32 %a, %b
-// CHECK:STDOUT:   ret i1 %int.less_eq
+// CHECK:STDOUT:   %int.less_eq = icmp sle i32 %a, %b, !dbg !52
+// CHECK:STDOUT:   ret i1 %int.less_eq, !dbg !53
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestGreater(i32 %a, i32 %b) !dbg !22 {
+// CHECK:STDOUT: define i1 @TestGreater(i32 %a, i32 %b) !dbg !54 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.greater = icmp sgt i32 %a, %b
-// CHECK:STDOUT:   ret i1 %int.greater
+// CHECK:STDOUT:   %int.greater = icmp sgt i32 %a, %b, !dbg !55
+// CHECK:STDOUT:   ret i1 %int.greater, !dbg !56
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestGreaterEq(i32 %a, i32 %b) !dbg !23 {
+// CHECK:STDOUT: define i1 @TestGreaterEq(i32 %a, i32 %b) !dbg !57 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.greater_eq = icmp sge i32 %a, %b
-// CHECK:STDOUT:   ret i1 %int.greater_eq
+// CHECK:STDOUT:   %int.greater_eq = icmp sge i32 %a, %b, !dbg !58
+// CHECK:STDOUT:   ret i1 %int.greater_eq, !dbg !59
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -183,20 +183,56 @@ fn TestGreaterEq(a: i32, b: i32) -> bool { return GreaterEq(a, b); }
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "TestNegate", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "TestAdd", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "TestSub", scope: null, file: !3, line: 18, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "TestMul", scope: null, file: !3, line: 21, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "TestDiv", scope: null, file: !3, line: 24, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !11 = distinct !DISubprogram(name: "TestMod", scope: null, file: !3, line: 27, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "TestComplement", scope: null, file: !3, line: 30, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !13 = distinct !DISubprogram(name: "TestAnd", scope: null, file: !3, line: 33, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !14 = distinct !DISubprogram(name: "TestOr", scope: null, file: !3, line: 36, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !15 = distinct !DISubprogram(name: "TestXor", scope: null, file: !3, line: 39, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !16 = distinct !DISubprogram(name: "TestLeftShift", scope: null, file: !3, line: 42, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !17 = distinct !DISubprogram(name: "TestRightShift", scope: null, file: !3, line: 45, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !18 = distinct !DISubprogram(name: "TestEq", scope: null, file: !3, line: 48, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !19 = distinct !DISubprogram(name: "TestNeq", scope: null, file: !3, line: 51, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !20 = distinct !DISubprogram(name: "TestLess", scope: null, file: !3, line: 54, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !21 = distinct !DISubprogram(name: "TestLessEq", scope: null, file: !3, line: 57, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !22 = distinct !DISubprogram(name: "TestGreater", scope: null, file: !3, line: 60, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !23 = distinct !DISubprogram(name: "TestGreaterEq", scope: null, file: !3, line: 63, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 39, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 32, scope: !4)
+// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "TestAdd", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 44, scope: !9)
+// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 37, scope: !9)
+// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "TestSub", scope: null, file: !3, line: 18, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !13 = !DILocation(line: 18, column: 44, scope: !12)
+// CHECK:STDOUT: !14 = !DILocation(line: 18, column: 37, scope: !12)
+// CHECK:STDOUT: !15 = distinct !DISubprogram(name: "TestMul", scope: null, file: !3, line: 21, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !16 = !DILocation(line: 21, column: 44, scope: !15)
+// CHECK:STDOUT: !17 = !DILocation(line: 21, column: 37, scope: !15)
+// CHECK:STDOUT: !18 = distinct !DISubprogram(name: "TestDiv", scope: null, file: !3, line: 24, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !19 = !DILocation(line: 24, column: 44, scope: !18)
+// CHECK:STDOUT: !20 = !DILocation(line: 24, column: 37, scope: !18)
+// CHECK:STDOUT: !21 = distinct !DISubprogram(name: "TestMod", scope: null, file: !3, line: 27, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !22 = !DILocation(line: 27, column: 44, scope: !21)
+// CHECK:STDOUT: !23 = !DILocation(line: 27, column: 37, scope: !21)
+// CHECK:STDOUT: !24 = distinct !DISubprogram(name: "TestComplement", scope: null, file: !3, line: 30, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !25 = !DILocation(line: 30, column: 43, scope: !24)
+// CHECK:STDOUT: !26 = !DILocation(line: 30, column: 36, scope: !24)
+// CHECK:STDOUT: !27 = distinct !DISubprogram(name: "TestAnd", scope: null, file: !3, line: 33, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !28 = !DILocation(line: 33, column: 44, scope: !27)
+// CHECK:STDOUT: !29 = !DILocation(line: 33, column: 37, scope: !27)
+// CHECK:STDOUT: !30 = distinct !DISubprogram(name: "TestOr", scope: null, file: !3, line: 36, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !31 = !DILocation(line: 36, column: 43, scope: !30)
+// CHECK:STDOUT: !32 = !DILocation(line: 36, column: 36, scope: !30)
+// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "TestXor", scope: null, file: !3, line: 39, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !34 = !DILocation(line: 39, column: 44, scope: !33)
+// CHECK:STDOUT: !35 = !DILocation(line: 39, column: 37, scope: !33)
+// CHECK:STDOUT: !36 = distinct !DISubprogram(name: "TestLeftShift", scope: null, file: !3, line: 42, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !37 = !DILocation(line: 42, column: 50, scope: !36)
+// CHECK:STDOUT: !38 = !DILocation(line: 42, column: 43, scope: !36)
+// CHECK:STDOUT: !39 = distinct !DISubprogram(name: "TestRightShift", scope: null, file: !3, line: 45, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !40 = !DILocation(line: 45, column: 51, scope: !39)
+// CHECK:STDOUT: !41 = !DILocation(line: 45, column: 44, scope: !39)
+// CHECK:STDOUT: !42 = distinct !DISubprogram(name: "TestEq", scope: null, file: !3, line: 48, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !43 = !DILocation(line: 48, column: 44, scope: !42)
+// CHECK:STDOUT: !44 = !DILocation(line: 48, column: 37, scope: !42)
+// CHECK:STDOUT: !45 = distinct !DISubprogram(name: "TestNeq", scope: null, file: !3, line: 51, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !46 = !DILocation(line: 51, column: 45, scope: !45)
+// CHECK:STDOUT: !47 = !DILocation(line: 51, column: 38, scope: !45)
+// CHECK:STDOUT: !48 = distinct !DISubprogram(name: "TestLess", scope: null, file: !3, line: 54, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !49 = !DILocation(line: 54, column: 46, scope: !48)
+// CHECK:STDOUT: !50 = !DILocation(line: 54, column: 39, scope: !48)
+// CHECK:STDOUT: !51 = distinct !DISubprogram(name: "TestLessEq", scope: null, file: !3, line: 57, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !52 = !DILocation(line: 57, column: 48, scope: !51)
+// CHECK:STDOUT: !53 = !DILocation(line: 57, column: 41, scope: !51)
+// CHECK:STDOUT: !54 = distinct !DISubprogram(name: "TestGreater", scope: null, file: !3, line: 60, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !55 = !DILocation(line: 60, column: 49, scope: !54)
+// CHECK:STDOUT: !56 = !DILocation(line: 60, column: 42, scope: !54)
+// CHECK:STDOUT: !57 = distinct !DISubprogram(name: "TestGreaterEq", scope: null, file: !3, line: 63, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !58 = !DILocation(line: 63, column: 51, scope: !57)
+// CHECK:STDOUT: !59 = !DILocation(line: 63, column: 44, scope: !57)

+ 10 - 6
toolchain/lower/testdata/builtins/method_vs_nonmethod.carbon

@@ -19,14 +19,14 @@ fn TestAddMethod(a: i32, b: i32) -> i32 { return a.(AddMethod)(b); }
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @TestAddNonmethod(i32 %a, i32 %b) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.sadd = add i32 %a, %b
-// CHECK:STDOUT:   ret i32 %int.sadd
+// CHECK:STDOUT:   %int.sadd = add i32 %a, %b, !dbg !7
+// CHECK:STDOUT:   ret i32 %int.sadd, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @TestAddMethod(i32 %a, i32 %b) !dbg !7 {
+// CHECK:STDOUT: define i32 @TestAddMethod(i32 %a, i32 %b) !dbg !9 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.sadd = add i32 %a, %b
-// CHECK:STDOUT:   ret i32 %int.sadd
+// CHECK:STDOUT:   %int.sadd = add i32 %a, %b, !dbg !10
+// CHECK:STDOUT:   ret i32 %int.sadd, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -39,4 +39,8 @@ fn TestAddMethod(a: i32, b: i32) -> i32 { return a.(AddMethod)(b); }
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "TestAddNonmethod", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "TestAddMethod", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 53, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 46, scope: !4)
+// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "TestAddMethod", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 50, scope: !9)
+// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 43, scope: !9)

+ 8 - 6
toolchain/lower/testdata/builtins/overloaded_operator.carbon

@@ -23,12 +23,12 @@ fn AddThreeIntegers(a: i32, b: i32, c: i32) -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @AddThreeIntegers(i32 %a, i32 %b, i32 %c) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.sadd.loc18_12 = add i32 %a, %b
-// CHECK:STDOUT:   %.loc18_12.2.temp = alloca i32, align 4
-// CHECK:STDOUT:   store i32 %int.sadd.loc18_12, ptr %.loc18_12.2.temp, align 4
-// CHECK:STDOUT:   %.loc18_12.4 = load i32, ptr %.loc18_12.2.temp, align 4
-// CHECK:STDOUT:   %int.sadd.loc18_16 = add i32 %.loc18_12.4, %c
-// CHECK:STDOUT:   ret i32 %int.sadd.loc18_16
+// CHECK:STDOUT:   %int.sadd.loc18_12 = add i32 %a, %b, !dbg !7
+// CHECK:STDOUT:   %.loc18_12.2.temp = alloca i32, align 4, !dbg !7
+// CHECK:STDOUT:   store i32 %int.sadd.loc18_12, ptr %.loc18_12.2.temp, align 4, !dbg !7
+// CHECK:STDOUT:   %.loc18_12.4 = load i32, ptr %.loc18_12.2.temp, align 4, !dbg !7
+// CHECK:STDOUT:   %int.sadd.loc18_16 = add i32 %.loc18_12.4, %c, !dbg !7
+// CHECK:STDOUT:   ret i32 %int.sadd.loc18_16, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -41,3 +41,5 @@ fn AddThreeIntegers(a: i32, b: i32, c: i32) -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "AddThreeIntegers", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 18, column: 10, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 18, column: 3, scope: !4)

+ 4 - 2
toolchain/lower/testdata/builtins/print.carbon

@@ -19,8 +19,8 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %print.int.printf = call i32 (ptr, ...) @printf(ptr @printf.int.format, i32 1)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %print.int.printf = call i32 (ptr, ...) @printf(ptr @printf.int.format, i32 1), !dbg !7
+// CHECK:STDOUT:   ret void, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: declare i32 @printf(ptr, ...)
@@ -35,3 +35,5 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 11, column: 1, scope: !4)

+ 14 - 7
toolchain/lower/testdata/builtins/types.carbon

@@ -23,13 +23,13 @@ fn F() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %i.var = alloca i32, align 4
-// CHECK:STDOUT:   store i32 0, ptr %i.var, align 4
-// CHECK:STDOUT:   %f.var = alloca double, align 8
-// CHECK:STDOUT:   store double 0.000000e+00, ptr %f.var, align 8
-// CHECK:STDOUT:   %b.var = alloca i1, align 1
-// CHECK:STDOUT:   store i1 false, ptr %b.var, align 1
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %i.var = alloca i32, align 4, !dbg !7
+// CHECK:STDOUT:   store i32 0, ptr %i.var, align 4, !dbg !8
+// CHECK:STDOUT:   %f.var = alloca double, align 8, !dbg !9
+// CHECK:STDOUT:   store double 0.000000e+00, ptr %f.var, align 8, !dbg !10
+// CHECK:STDOUT:   %b.var = alloca i1, align 1, !dbg !11
+// CHECK:STDOUT:   store i1 false, ptr %b.var, align 1, !dbg !12
+// CHECK:STDOUT:   ret void, !dbg !13
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -42,3 +42,10 @@ fn F() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 16, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 16, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 17, column: 7, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 17, column: 3, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 18, column: 7, scope: !4)
+// CHECK:STDOUT: !12 = !DILocation(line: 18, column: 3, scope: !4)
+// CHECK:STDOUT: !13 = !DILocation(line: 15, column: 1, scope: !4)

+ 106 - 70
toolchain/lower/testdata/builtins/uint.carbon

@@ -67,110 +67,110 @@ fn TestGreaterEq(a: u64, b: u64) -> bool { return GreaterEq(a, b); }
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i64 @TestNegate(i64 %a) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.unegate = sub i64 0, %a
-// CHECK:STDOUT:   ret i64 %int.unegate
+// CHECK:STDOUT:   %int.unegate = sub i64 0, %a, !dbg !7
+// CHECK:STDOUT:   ret i64 %int.unegate, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i64 @TestAdd(i64 %a, i64 %b) !dbg !7 {
+// CHECK:STDOUT: define i64 @TestAdd(i64 %a, i64 %b) !dbg !9 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.uadd = add i64 %a, %b
-// CHECK:STDOUT:   ret i64 %int.uadd
+// CHECK:STDOUT:   %int.uadd = add i64 %a, %b, !dbg !10
+// CHECK:STDOUT:   ret i64 %int.uadd, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i64 @TestSub(i64 %a, i64 %b) !dbg !8 {
+// CHECK:STDOUT: define i64 @TestSub(i64 %a, i64 %b) !dbg !12 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.usub = sub i64 %a, %b
-// CHECK:STDOUT:   ret i64 %int.usub
+// CHECK:STDOUT:   %int.usub = sub i64 %a, %b, !dbg !13
+// CHECK:STDOUT:   ret i64 %int.usub, !dbg !14
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i64 @TestMul(i64 %a, i64 %b) !dbg !9 {
+// CHECK:STDOUT: define i64 @TestMul(i64 %a, i64 %b) !dbg !15 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.umul = mul i64 %a, %b
-// CHECK:STDOUT:   ret i64 %int.umul
+// CHECK:STDOUT:   %int.umul = mul i64 %a, %b, !dbg !16
+// CHECK:STDOUT:   ret i64 %int.umul, !dbg !17
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i64 @TestDiv(i64 %a, i64 %b) !dbg !10 {
+// CHECK:STDOUT: define i64 @TestDiv(i64 %a, i64 %b) !dbg !18 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.udiv = udiv i64 %a, %b
-// CHECK:STDOUT:   ret i64 %int.udiv
+// CHECK:STDOUT:   %int.udiv = udiv i64 %a, %b, !dbg !19
+// CHECK:STDOUT:   ret i64 %int.udiv, !dbg !20
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i64 @TestMod(i64 %a, i64 %b) !dbg !11 {
+// CHECK:STDOUT: define i64 @TestMod(i64 %a, i64 %b) !dbg !21 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.umod = urem i64 %a, %b
-// CHECK:STDOUT:   ret i64 %int.umod
+// CHECK:STDOUT:   %int.umod = urem i64 %a, %b, !dbg !22
+// CHECK:STDOUT:   ret i64 %int.umod, !dbg !23
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i64 @TestComplement(i64 %a) !dbg !12 {
+// CHECK:STDOUT: define i64 @TestComplement(i64 %a) !dbg !24 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.complement = xor i64 -1, %a
-// CHECK:STDOUT:   ret i64 %int.complement
+// CHECK:STDOUT:   %int.complement = xor i64 -1, %a, !dbg !25
+// CHECK:STDOUT:   ret i64 %int.complement, !dbg !26
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i64 @TestAnd(i64 %a, i64 %b) !dbg !13 {
+// CHECK:STDOUT: define i64 @TestAnd(i64 %a, i64 %b) !dbg !27 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.and = and i64 %a, %b
-// CHECK:STDOUT:   ret i64 %int.and
+// CHECK:STDOUT:   %int.and = and i64 %a, %b, !dbg !28
+// CHECK:STDOUT:   ret i64 %int.and, !dbg !29
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i64 @TestOr(i64 %a, i64 %b) !dbg !14 {
+// CHECK:STDOUT: define i64 @TestOr(i64 %a, i64 %b) !dbg !30 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.or = or i64 %a, %b
-// CHECK:STDOUT:   ret i64 %int.or
+// CHECK:STDOUT:   %int.or = or i64 %a, %b, !dbg !31
+// CHECK:STDOUT:   ret i64 %int.or, !dbg !32
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i64 @TestXor(i64 %a, i64 %b) !dbg !15 {
+// CHECK:STDOUT: define i64 @TestXor(i64 %a, i64 %b) !dbg !33 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.xor = xor i64 %a, %b
-// CHECK:STDOUT:   ret i64 %int.xor
+// CHECK:STDOUT:   %int.xor = xor i64 %a, %b, !dbg !34
+// CHECK:STDOUT:   ret i64 %int.xor, !dbg !35
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i64 @TestLeftShift(i64 %a, i64 %b) !dbg !16 {
+// CHECK:STDOUT: define i64 @TestLeftShift(i64 %a, i64 %b) !dbg !36 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.left_shift = shl i64 %a, %b
-// CHECK:STDOUT:   ret i64 %int.left_shift
+// CHECK:STDOUT:   %int.left_shift = shl i64 %a, %b, !dbg !37
+// CHECK:STDOUT:   ret i64 %int.left_shift, !dbg !38
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i64 @TestRightShift(i64 %a, i64 %b) !dbg !17 {
+// CHECK:STDOUT: define i64 @TestRightShift(i64 %a, i64 %b) !dbg !39 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.right_shift = lshr i64 %a, %b
-// CHECK:STDOUT:   ret i64 %int.right_shift
+// CHECK:STDOUT:   %int.right_shift = lshr i64 %a, %b, !dbg !40
+// CHECK:STDOUT:   ret i64 %int.right_shift, !dbg !41
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestEq(i64 %a, i64 %b) !dbg !18 {
+// CHECK:STDOUT: define i1 @TestEq(i64 %a, i64 %b) !dbg !42 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.eq = icmp eq i64 %a, %b
-// CHECK:STDOUT:   ret i1 %int.eq
+// CHECK:STDOUT:   %int.eq = icmp eq i64 %a, %b, !dbg !43
+// CHECK:STDOUT:   ret i1 %int.eq, !dbg !44
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestNeq(i64 %a, i64 %b) !dbg !19 {
+// CHECK:STDOUT: define i1 @TestNeq(i64 %a, i64 %b) !dbg !45 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.neq = icmp ne i64 %a, %b
-// CHECK:STDOUT:   ret i1 %int.neq
+// CHECK:STDOUT:   %int.neq = icmp ne i64 %a, %b, !dbg !46
+// CHECK:STDOUT:   ret i1 %int.neq, !dbg !47
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestLess(i64 %a, i64 %b) !dbg !20 {
+// CHECK:STDOUT: define i1 @TestLess(i64 %a, i64 %b) !dbg !48 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.less = icmp ult i64 %a, %b
-// CHECK:STDOUT:   ret i1 %int.less
+// CHECK:STDOUT:   %int.less = icmp ult i64 %a, %b, !dbg !49
+// CHECK:STDOUT:   ret i1 %int.less, !dbg !50
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestLessEq(i64 %a, i64 %b) !dbg !21 {
+// CHECK:STDOUT: define i1 @TestLessEq(i64 %a, i64 %b) !dbg !51 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.less_eq = icmp ule i64 %a, %b
-// CHECK:STDOUT:   ret i1 %int.less_eq
+// CHECK:STDOUT:   %int.less_eq = icmp ule i64 %a, %b, !dbg !52
+// CHECK:STDOUT:   ret i1 %int.less_eq, !dbg !53
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestGreater(i64 %a, i64 %b) !dbg !22 {
+// CHECK:STDOUT: define i1 @TestGreater(i64 %a, i64 %b) !dbg !54 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.greater = icmp ugt i64 %a, %b
-// CHECK:STDOUT:   ret i1 %int.greater
+// CHECK:STDOUT:   %int.greater = icmp ugt i64 %a, %b, !dbg !55
+// CHECK:STDOUT:   ret i1 %int.greater, !dbg !56
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @TestGreaterEq(i64 %a, i64 %b) !dbg !23 {
+// CHECK:STDOUT: define i1 @TestGreaterEq(i64 %a, i64 %b) !dbg !57 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.greater_eq = icmp uge i64 %a, %b
-// CHECK:STDOUT:   ret i1 %int.greater_eq
+// CHECK:STDOUT:   %int.greater_eq = icmp uge i64 %a, %b, !dbg !58
+// CHECK:STDOUT:   ret i1 %int.greater_eq, !dbg !59
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -183,20 +183,56 @@ fn TestGreaterEq(a: u64, b: u64) -> bool { return GreaterEq(a, b); }
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "TestNegate", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "TestAdd", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "TestSub", scope: null, file: !3, line: 18, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "TestMul", scope: null, file: !3, line: 21, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "TestDiv", scope: null, file: !3, line: 24, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !11 = distinct !DISubprogram(name: "TestMod", scope: null, file: !3, line: 27, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "TestComplement", scope: null, file: !3, line: 30, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !13 = distinct !DISubprogram(name: "TestAnd", scope: null, file: !3, line: 33, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !14 = distinct !DISubprogram(name: "TestOr", scope: null, file: !3, line: 36, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !15 = distinct !DISubprogram(name: "TestXor", scope: null, file: !3, line: 39, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !16 = distinct !DISubprogram(name: "TestLeftShift", scope: null, file: !3, line: 42, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !17 = distinct !DISubprogram(name: "TestRightShift", scope: null, file: !3, line: 45, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !18 = distinct !DISubprogram(name: "TestEq", scope: null, file: !3, line: 48, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !19 = distinct !DISubprogram(name: "TestNeq", scope: null, file: !3, line: 51, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !20 = distinct !DISubprogram(name: "TestLess", scope: null, file: !3, line: 54, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !21 = distinct !DISubprogram(name: "TestLessEq", scope: null, file: !3, line: 57, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !22 = distinct !DISubprogram(name: "TestGreater", scope: null, file: !3, line: 60, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !23 = distinct !DISubprogram(name: "TestGreaterEq", scope: null, file: !3, line: 63, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 39, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 32, scope: !4)
+// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "TestAdd", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 44, scope: !9)
+// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 37, scope: !9)
+// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "TestSub", scope: null, file: !3, line: 18, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !13 = !DILocation(line: 18, column: 44, scope: !12)
+// CHECK:STDOUT: !14 = !DILocation(line: 18, column: 37, scope: !12)
+// CHECK:STDOUT: !15 = distinct !DISubprogram(name: "TestMul", scope: null, file: !3, line: 21, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !16 = !DILocation(line: 21, column: 44, scope: !15)
+// CHECK:STDOUT: !17 = !DILocation(line: 21, column: 37, scope: !15)
+// CHECK:STDOUT: !18 = distinct !DISubprogram(name: "TestDiv", scope: null, file: !3, line: 24, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !19 = !DILocation(line: 24, column: 44, scope: !18)
+// CHECK:STDOUT: !20 = !DILocation(line: 24, column: 37, scope: !18)
+// CHECK:STDOUT: !21 = distinct !DISubprogram(name: "TestMod", scope: null, file: !3, line: 27, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !22 = !DILocation(line: 27, column: 44, scope: !21)
+// CHECK:STDOUT: !23 = !DILocation(line: 27, column: 37, scope: !21)
+// CHECK:STDOUT: !24 = distinct !DISubprogram(name: "TestComplement", scope: null, file: !3, line: 30, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !25 = !DILocation(line: 30, column: 43, scope: !24)
+// CHECK:STDOUT: !26 = !DILocation(line: 30, column: 36, scope: !24)
+// CHECK:STDOUT: !27 = distinct !DISubprogram(name: "TestAnd", scope: null, file: !3, line: 33, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !28 = !DILocation(line: 33, column: 44, scope: !27)
+// CHECK:STDOUT: !29 = !DILocation(line: 33, column: 37, scope: !27)
+// CHECK:STDOUT: !30 = distinct !DISubprogram(name: "TestOr", scope: null, file: !3, line: 36, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !31 = !DILocation(line: 36, column: 43, scope: !30)
+// CHECK:STDOUT: !32 = !DILocation(line: 36, column: 36, scope: !30)
+// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "TestXor", scope: null, file: !3, line: 39, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !34 = !DILocation(line: 39, column: 44, scope: !33)
+// CHECK:STDOUT: !35 = !DILocation(line: 39, column: 37, scope: !33)
+// CHECK:STDOUT: !36 = distinct !DISubprogram(name: "TestLeftShift", scope: null, file: !3, line: 42, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !37 = !DILocation(line: 42, column: 50, scope: !36)
+// CHECK:STDOUT: !38 = !DILocation(line: 42, column: 43, scope: !36)
+// CHECK:STDOUT: !39 = distinct !DISubprogram(name: "TestRightShift", scope: null, file: !3, line: 45, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !40 = !DILocation(line: 45, column: 51, scope: !39)
+// CHECK:STDOUT: !41 = !DILocation(line: 45, column: 44, scope: !39)
+// CHECK:STDOUT: !42 = distinct !DISubprogram(name: "TestEq", scope: null, file: !3, line: 48, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !43 = !DILocation(line: 48, column: 44, scope: !42)
+// CHECK:STDOUT: !44 = !DILocation(line: 48, column: 37, scope: !42)
+// CHECK:STDOUT: !45 = distinct !DISubprogram(name: "TestNeq", scope: null, file: !3, line: 51, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !46 = !DILocation(line: 51, column: 45, scope: !45)
+// CHECK:STDOUT: !47 = !DILocation(line: 51, column: 38, scope: !45)
+// CHECK:STDOUT: !48 = distinct !DISubprogram(name: "TestLess", scope: null, file: !3, line: 54, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !49 = !DILocation(line: 54, column: 46, scope: !48)
+// CHECK:STDOUT: !50 = !DILocation(line: 54, column: 39, scope: !48)
+// CHECK:STDOUT: !51 = distinct !DISubprogram(name: "TestLessEq", scope: null, file: !3, line: 57, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !52 = !DILocation(line: 57, column: 48, scope: !51)
+// CHECK:STDOUT: !53 = !DILocation(line: 57, column: 41, scope: !51)
+// CHECK:STDOUT: !54 = distinct !DISubprogram(name: "TestGreater", scope: null, file: !3, line: 60, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !55 = !DILocation(line: 60, column: 49, scope: !54)
+// CHECK:STDOUT: !56 = !DILocation(line: 60, column: 42, scope: !54)
+// CHECK:STDOUT: !57 = distinct !DISubprogram(name: "TestGreaterEq", scope: null, file: !3, line: 63, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !58 = !DILocation(line: 63, column: 51, scope: !57)
+// CHECK:STDOUT: !59 = !DILocation(line: 63, column: 44, scope: !57)

+ 31 - 20
toolchain/lower/testdata/class/adapt.carbon

@@ -58,31 +58,31 @@ fn DoStuff(a: Int) -> Int {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Make(ptr sret({ i32, i32 }) %return) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc9_27.2.a = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 0
-// CHECK:STDOUT:   %.loc9_27.4.b = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 1
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %return, ptr align 4 @struct.loc9_28, i64 8, i1 false)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %.loc9_27.2.a = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 0, !dbg !7
+// CHECK:STDOUT:   %.loc9_27.4.b = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 1, !dbg !7
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %return, ptr align 4 @struct.loc9_28, i64 8, i1 false), !dbg !8
+// CHECK:STDOUT:   ret void, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Make.1(ptr sret({ i32, i32 }) %return) !dbg !7 {
+// CHECK:STDOUT: define void @Make.1(ptr sret({ i32, i32 }) %return) !dbg !9 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @Make(ptr %return)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @Make(ptr %return), !dbg !10
+// CHECK:STDOUT:   ret void, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @GetB(ptr %self) !dbg !8 {
+// CHECK:STDOUT: define i32 @GetB(ptr %self) !dbg !12 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc22_14.1.b = getelementptr inbounds nuw { i32, i32 }, ptr %self, i32 0, i32 1
-// CHECK:STDOUT:   %.loc22_14.2 = load i32, ptr %.loc22_14.1.b, align 4
-// CHECK:STDOUT:   ret i32 %.loc22_14.2
+// CHECK:STDOUT:   %.loc22_14.1.b = getelementptr inbounds nuw { i32, i32 }, ptr %self, i32 0, i32 1, !dbg !13
+// CHECK:STDOUT:   %.loc22_14.2 = load i32, ptr %.loc22_14.1.b, align 4, !dbg !13
+// CHECK:STDOUT:   ret i32 %.loc22_14.2, !dbg !14
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @Use() !dbg !9 {
+// CHECK:STDOUT: define i32 @Use() !dbg !15 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %pa.var = alloca { i32, i32 }, align 8
-// CHECK:STDOUT:   call void @Make.1(ptr %pa.var)
-// CHECK:STDOUT:   %GetB.call = call i32 @GetB(ptr %pa.var)
-// CHECK:STDOUT:   ret i32 %GetB.call
+// CHECK:STDOUT:   %pa.var = alloca { i32, i32 }, align 8, !dbg !16
+// CHECK:STDOUT:   call void @Make.1(ptr %pa.var), !dbg !17
+// CHECK:STDOUT:   %GetB.call = call i32 @GetB(ptr %pa.var), !dbg !18
+// CHECK:STDOUT:   ret i32 %GetB.call, !dbg !19
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -100,15 +100,25 @@ fn DoStuff(a: Int) -> Int {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Make", scope: null, file: !3, line: 8, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Make.1", scope: null, file: !3, line: 16, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "GetB", scope: null, file: !3, line: 20, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "Use", scope: null, file: !3, line: 26, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 9, column: 12, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 9, column: 5, scope: !4)
+// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "Make.1", scope: null, file: !3, line: 16, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !10 = !DILocation(line: 17, column: 12, scope: !9)
+// CHECK:STDOUT: !11 = !DILocation(line: 17, column: 5, scope: !9)
+// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "GetB", scope: null, file: !3, line: 20, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !13 = !DILocation(line: 22, column: 12, scope: !12)
+// CHECK:STDOUT: !14 = !DILocation(line: 22, column: 5, scope: !12)
+// CHECK:STDOUT: !15 = distinct !DISubprogram(name: "Use", scope: null, file: !3, line: 26, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !16 = !DILocation(line: 27, column: 7, scope: !15)
+// CHECK:STDOUT: !17 = !DILocation(line: 27, column: 25, scope: !15)
+// CHECK:STDOUT: !18 = !DILocation(line: 28, column: 10, scope: !15)
+// CHECK:STDOUT: !19 = !DILocation(line: 28, column: 3, scope: !15)
 // CHECK:STDOUT: ; ModuleID = 'adapt_int.carbon'
 // CHECK:STDOUT: source_filename = "adapt_int.carbon"
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @DoStuff(i32 %a) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i32 %a
+// CHECK:STDOUT:   ret i32 %a, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -121,3 +131,4 @@ fn DoStuff(a: Int) -> Int {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "DoStuff", scope: null, file: !3, line: 8, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 9, column: 3, scope: !4)

+ 29 - 21
toolchain/lower/testdata/class/base.carbon

@@ -37,31 +37,31 @@ fn Convert(p: Derived*) -> Base* {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Make(ptr sret({ { i32 }, i32 }) %return) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc22_35.2.base = getelementptr inbounds nuw { { i32 }, i32 }, ptr %return, i32 0, i32 0
-// CHECK:STDOUT:   %.loc22_26.2.b = getelementptr inbounds nuw { i32 }, ptr %.loc22_35.2.base, i32 0, i32 0
-// CHECK:STDOUT:   %.loc22_35.4.d = getelementptr inbounds nuw { { i32 }, i32 }, ptr %return, i32 0, i32 1
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %return, ptr align 4 @struct.2.loc22_36, i64 8, i1 false)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %.loc22_35.2.base = getelementptr inbounds nuw { { i32 }, i32 }, ptr %return, i32 0, i32 0, !dbg !7
+// CHECK:STDOUT:   %.loc22_26.2.b = getelementptr inbounds nuw { i32 }, ptr %.loc22_35.2.base, i32 0, i32 0, !dbg !8
+// CHECK:STDOUT:   %.loc22_35.4.d = getelementptr inbounds nuw { { i32 }, i32 }, ptr %return, i32 0, i32 1, !dbg !7
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %return, ptr align 4 @struct.2.loc22_36, i64 8, i1 false), !dbg !9
+// CHECK:STDOUT:   ret void, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Access(ptr sret({ i32, i32 }) %return, ptr %d) !dbg !7 {
+// CHECK:STDOUT: define void @Access(ptr sret({ i32, i32 }) %return, ptr %d) !dbg !10 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc26_12.1.d = getelementptr inbounds nuw { { i32 }, i32 }, ptr %d, i32 0, i32 1
-// CHECK:STDOUT:   %.loc26_12.2 = load i32, ptr %.loc26_12.1.d, align 4
-// CHECK:STDOUT:   %.loc26_17.1.base = getelementptr inbounds nuw { { i32 }, i32 }, ptr %d, i32 0, i32 0
-// CHECK:STDOUT:   %.loc26_22.1.b = getelementptr inbounds nuw { i32 }, ptr %.loc26_17.1.base, i32 0, i32 0
-// CHECK:STDOUT:   %.loc26_22.2 = load i32, ptr %.loc26_22.1.b, align 4
-// CHECK:STDOUT:   %.loc26_24.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 0
-// CHECK:STDOUT:   store i32 %.loc26_12.2, ptr %.loc26_24.2.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc26_24.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 1
-// CHECK:STDOUT:   store i32 %.loc26_22.2, ptr %.loc26_24.4.tuple.elem, align 4
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %.loc26_12.1.d = getelementptr inbounds nuw { { i32 }, i32 }, ptr %d, i32 0, i32 1, !dbg !11
+// CHECK:STDOUT:   %.loc26_12.2 = load i32, ptr %.loc26_12.1.d, align 4, !dbg !11
+// CHECK:STDOUT:   %.loc26_17.1.base = getelementptr inbounds nuw { { i32 }, i32 }, ptr %d, i32 0, i32 0, !dbg !12
+// CHECK:STDOUT:   %.loc26_22.1.b = getelementptr inbounds nuw { i32 }, ptr %.loc26_17.1.base, i32 0, i32 0, !dbg !12
+// CHECK:STDOUT:   %.loc26_22.2 = load i32, ptr %.loc26_22.1.b, align 4, !dbg !12
+// CHECK:STDOUT:   %.loc26_24.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 0, !dbg !13
+// CHECK:STDOUT:   store i32 %.loc26_12.2, ptr %.loc26_24.2.tuple.elem, align 4, !dbg !13
+// CHECK:STDOUT:   %.loc26_24.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 1, !dbg !13
+// CHECK:STDOUT:   store i32 %.loc26_22.2, ptr %.loc26_24.4.tuple.elem, align 4, !dbg !13
+// CHECK:STDOUT:   ret void, !dbg !14
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define ptr @Convert(ptr %p) !dbg !8 {
+// CHECK:STDOUT: define ptr @Convert(ptr %p) !dbg !15 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc30_11.2.base = getelementptr inbounds nuw { { i32 }, i32 }, ptr %p, i32 0, i32 0
-// CHECK:STDOUT:   ret ptr %.loc30_11.2.base
+// CHECK:STDOUT:   %.loc30_11.2.base = getelementptr inbounds nuw { { i32 }, i32 }, ptr %p, i32 0, i32 0, !dbg !16
+// CHECK:STDOUT:   ret ptr %.loc30_11.2.base, !dbg !16
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -79,5 +79,13 @@ fn Convert(p: Derived*) -> Base* {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Make", scope: null, file: !3, line: 21, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Access", scope: null, file: !3, line: 25, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Convert", scope: null, file: !3, line: 29, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 22, column: 10, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 22, column: 19, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 22, column: 3, scope: !4)
+// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "Access", scope: null, file: !3, line: 25, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !11 = !DILocation(line: 26, column: 11, scope: !10)
+// CHECK:STDOUT: !12 = !DILocation(line: 26, column: 16, scope: !10)
+// CHECK:STDOUT: !13 = !DILocation(line: 26, column: 10, scope: !10)
+// CHECK:STDOUT: !14 = !DILocation(line: 26, column: 3, scope: !10)
+// CHECK:STDOUT: !15 = distinct !DISubprogram(name: "Convert", scope: null, file: !3, line: 29, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !16 = !DILocation(line: 30, column: 3, scope: !15)

+ 8 - 4
toolchain/lower/testdata/class/basic.carbon

@@ -27,10 +27,10 @@ fn Run() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %c.var = alloca { i32, ptr }, align 8
-// CHECK:STDOUT:   %d.var = alloca { i32, ptr }, align 8
-// CHECK:STDOUT:   call void @F(ptr %d.var, ptr %c.var)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %c.var = alloca { i32, ptr }, align 8, !dbg !7
+// CHECK:STDOUT:   %d.var = alloca { i32, ptr }, align 8, !dbg !8
+// CHECK:STDOUT:   call void @F(ptr %d.var, ptr %c.var), !dbg !9
+// CHECK:STDOUT:   ret void, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -43,3 +43,7 @@ fn Run() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 18, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 19, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 20, column: 7, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 20, column: 14, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 18, column: 1, scope: !4)

+ 22 - 14
toolchain/lower/testdata/class/field.carbon

@@ -29,22 +29,22 @@ fn Run() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @F(ptr %c) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc17_13.1.b = getelementptr inbounds nuw { i32, ptr }, ptr %c, i32 0, i32 1
-// CHECK:STDOUT:   %.loc17_13.2 = load ptr, ptr %.loc17_13.1.b, align 8
-// CHECK:STDOUT:   %.loc17_16.1.a = getelementptr inbounds nuw { i32, ptr }, ptr %.loc17_13.2, i32 0, i32 0
-// CHECK:STDOUT:   %.loc17_16.2 = load i32, ptr %.loc17_16.1.a, align 4
-// CHECK:STDOUT:   ret i32 %.loc17_16.2
+// CHECK:STDOUT:   %.loc17_13.1.b = getelementptr inbounds nuw { i32, ptr }, ptr %c, i32 0, i32 1, !dbg !7
+// CHECK:STDOUT:   %.loc17_13.2 = load ptr, ptr %.loc17_13.1.b, align 8, !dbg !7
+// CHECK:STDOUT:   %.loc17_16.1.a = getelementptr inbounds nuw { i32, ptr }, ptr %.loc17_13.2, i32 0, i32 0, !dbg !8
+// CHECK:STDOUT:   %.loc17_16.2 = load i32, ptr %.loc17_16.1.a, align 4, !dbg !8
+// CHECK:STDOUT:   ret i32 %.loc17_16.2, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @main() !dbg !7 {
+// CHECK:STDOUT: define i32 @main() !dbg !10 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %c.var = alloca { i32, ptr }, align 8
-// CHECK:STDOUT:   %.loc22_4.a = getelementptr inbounds nuw { i32, ptr }, ptr %c.var, i32 0, i32 0
-// CHECK:STDOUT:   store i32 1, ptr %.loc22_4.a, align 4
-// CHECK:STDOUT:   %.loc23_4.b = getelementptr inbounds nuw { i32, ptr }, ptr %c.var, i32 0, i32 1
-// CHECK:STDOUT:   store ptr %c.var, ptr %.loc23_4.b, align 8
-// CHECK:STDOUT:   %F.call = call i32 @F(ptr %c.var)
-// CHECK:STDOUT:   ret i32 %F.call
+// CHECK:STDOUT:   %c.var = alloca { i32, ptr }, align 8, !dbg !11
+// CHECK:STDOUT:   %.loc22_4.a = getelementptr inbounds nuw { i32, ptr }, ptr %c.var, i32 0, i32 0, !dbg !12
+// CHECK:STDOUT:   store i32 1, ptr %.loc22_4.a, align 4, !dbg !12
+// CHECK:STDOUT:   %.loc23_4.b = getelementptr inbounds nuw { i32, ptr }, ptr %c.var, i32 0, i32 1, !dbg !13
+// CHECK:STDOUT:   store ptr %c.var, ptr %.loc23_4.b, align 8, !dbg !13
+// CHECK:STDOUT:   %F.call = call i32 @F(ptr %c.var), !dbg !14
+// CHECK:STDOUT:   ret i32 %F.call, !dbg !15
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -57,4 +57,12 @@ fn Run() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 16, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 20, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 17, column: 12, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 17, column: 10, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 17, column: 3, scope: !4)
+// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 20, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !11 = !DILocation(line: 21, column: 7, scope: !10)
+// CHECK:STDOUT: !12 = !DILocation(line: 22, column: 3, scope: !10)
+// CHECK:STDOUT: !13 = !DILocation(line: 23, column: 3, scope: !10)
+// CHECK:STDOUT: !14 = !DILocation(line: 24, column: 10, scope: !10)
+// CHECK:STDOUT: !15 = !DILocation(line: 24, column: 3, scope: !10)

+ 6 - 3
toolchain/lower/testdata/class/method.carbon

@@ -29,9 +29,9 @@ fn F(p: C*) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F(ptr %p) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %Get.call = call i32 @Get(ptr %p)
-// CHECK:STDOUT:   call void @Set(ptr %p, i32 %Get.call)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %Get.call = call i32 @Get(ptr %p), !dbg !7
+// CHECK:STDOUT:   call void @Set(ptr %p, i32 %Get.call), !dbg !8
+// CHECK:STDOUT:   ret void, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -44,3 +44,6 @@ fn F(p: C*) {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 18, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 19, column: 16, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 20, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 18, column: 1, scope: !4)

+ 12 - 8
toolchain/lower/testdata/class/self.carbon

@@ -28,16 +28,16 @@ fn C.Set[addr self: C*]() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @Get(ptr %self) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc19_14.1.a = getelementptr inbounds nuw { i32 }, ptr %self, i32 0, i32 0
-// CHECK:STDOUT:   %.loc19_14.2 = load i32, ptr %.loc19_14.1.a, align 4
-// CHECK:STDOUT:   ret i32 %.loc19_14.2
+// CHECK:STDOUT:   %.loc19_14.1.a = getelementptr inbounds nuw { i32 }, ptr %self, i32 0, i32 0, !dbg !7
+// CHECK:STDOUT:   %.loc19_14.2 = load i32, ptr %.loc19_14.1.a, align 4, !dbg !7
+// CHECK:STDOUT:   ret i32 %.loc19_14.2, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Set(ptr %self) !dbg !7 {
+// CHECK:STDOUT: define void @Set(ptr %self) !dbg !9 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc23_10.a = getelementptr inbounds nuw { i32 }, ptr %self, i32 0, i32 0
-// CHECK:STDOUT:   store i32 1, ptr %.loc23_10.a, align 4
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %.loc23_10.a = getelementptr inbounds nuw { i32 }, ptr %self, i32 0, i32 0, !dbg !10
+// CHECK:STDOUT:   store i32 1, ptr %.loc23_10.a, align 4, !dbg !10
+// CHECK:STDOUT:   ret void, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -50,4 +50,8 @@ fn C.Set[addr self: C*]() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Get", scope: null, file: !3, line: 18, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Set", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 19, column: 10, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 19, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "Set", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !10 = !DILocation(line: 23, column: 3, scope: !9)
+// CHECK:STDOUT: !11 = !DILocation(line: 22, column: 1, scope: !9)

+ 19 - 17
toolchain/lower/testdata/class/value_access.carbon

@@ -24,23 +24,23 @@ fn F(c: C) -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @F(ptr %c) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc19_11.1.a = getelementptr inbounds nuw { { i32, i32, i32 } }, ptr %c, i32 0, i32 0
-// CHECK:STDOUT:   %.loc19_11.2.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %.loc19_11.1.a, i32 0, i32 0
-// CHECK:STDOUT:   %.loc19_11.3 = load i32, ptr %.loc19_11.2.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc19_11.4.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %.loc19_11.1.a, i32 0, i32 1
-// CHECK:STDOUT:   %.loc19_11.5 = load i32, ptr %.loc19_11.4.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc19_11.6.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %.loc19_11.1.a, i32 0, i32 2
-// CHECK:STDOUT:   %.loc19_11.7 = load i32, ptr %.loc19_11.6.tuple.elem, align 4
-// CHECK:STDOUT:   %tuple = alloca { i32, i32, i32 }, align 8
-// CHECK:STDOUT:   %tuple1 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple, i32 0, i32 0
-// CHECK:STDOUT:   store i32 %.loc19_11.3, ptr %tuple1, align 4
-// CHECK:STDOUT:   %tuple2 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple, i32 0, i32 1
-// CHECK:STDOUT:   store i32 %.loc19_11.5, ptr %tuple2, align 4
-// CHECK:STDOUT:   %tuple3 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple, i32 0, i32 2
-// CHECK:STDOUT:   store i32 %.loc19_11.7, ptr %tuple3, align 4
-// CHECK:STDOUT:   %.loc19_13.tuple.index = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple, i32 0, i32 1
-// CHECK:STDOUT:   %.loc19_13.tuple.index.load = load i32, ptr %.loc19_13.tuple.index, align 4
-// CHECK:STDOUT:   ret i32 %.loc19_13.tuple.index.load
+// CHECK:STDOUT:   %.loc19_11.1.a = getelementptr inbounds nuw { { i32, i32, i32 } }, ptr %c, i32 0, i32 0, !dbg !7
+// CHECK:STDOUT:   %.loc19_11.2.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %.loc19_11.1.a, i32 0, i32 0, !dbg !7
+// CHECK:STDOUT:   %.loc19_11.3 = load i32, ptr %.loc19_11.2.tuple.elem, align 4, !dbg !7
+// CHECK:STDOUT:   %.loc19_11.4.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %.loc19_11.1.a, i32 0, i32 1, !dbg !7
+// CHECK:STDOUT:   %.loc19_11.5 = load i32, ptr %.loc19_11.4.tuple.elem, align 4, !dbg !7
+// CHECK:STDOUT:   %.loc19_11.6.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %.loc19_11.1.a, i32 0, i32 2, !dbg !7
+// CHECK:STDOUT:   %.loc19_11.7 = load i32, ptr %.loc19_11.6.tuple.elem, align 4, !dbg !7
+// CHECK:STDOUT:   %tuple = alloca { i32, i32, i32 }, align 8, !dbg !7
+// CHECK:STDOUT:   %tuple1 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple, i32 0, i32 0, !dbg !7
+// CHECK:STDOUT:   store i32 %.loc19_11.3, ptr %tuple1, align 4, !dbg !7
+// CHECK:STDOUT:   %tuple2 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple, i32 0, i32 1, !dbg !7
+// CHECK:STDOUT:   store i32 %.loc19_11.5, ptr %tuple2, align 4, !dbg !7
+// CHECK:STDOUT:   %tuple3 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple, i32 0, i32 2, !dbg !7
+// CHECK:STDOUT:   store i32 %.loc19_11.7, ptr %tuple3, align 4, !dbg !7
+// CHECK:STDOUT:   %.loc19_13.tuple.index = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple, i32 0, i32 1, !dbg !7
+// CHECK:STDOUT:   %.loc19_13.tuple.index.load = load i32, ptr %.loc19_13.tuple.index, align 4, !dbg !7
+// CHECK:STDOUT:   ret i32 %.loc19_13.tuple.index.load, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -53,3 +53,5 @@ fn F(c: C) -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 19, column: 10, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 19, column: 3, scope: !4)

+ 10 - 6
toolchain/lower/testdata/function/call/empty_struct.carbon

@@ -21,14 +21,14 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Echo() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !7 {
+// CHECK:STDOUT: define void @Main() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %b.var = alloca {}, align 8
-// CHECK:STDOUT:   call void @Echo()
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %b.var = alloca {}, align 8, !dbg !9
+// CHECK:STDOUT:   call void @Echo(), !dbg !10
+// CHECK:STDOUT:   ret void, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -41,4 +41,8 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Echo", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 7, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 16, column: 15, scope: !8)
+// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 1, scope: !8)

+ 10 - 6
toolchain/lower/testdata/function/call/empty_tuple.carbon

@@ -21,14 +21,14 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Echo() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !7 {
+// CHECK:STDOUT: define void @Main() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %b.var = alloca {}, align 8
-// CHECK:STDOUT:   call void @Echo()
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %b.var = alloca {}, align 8, !dbg !9
+// CHECK:STDOUT:   call void @Echo(), !dbg !10
+// CHECK:STDOUT:   ret void, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -41,4 +41,8 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Echo", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 7, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 16, column: 15, scope: !8)
+// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 1, scope: !8)

+ 12 - 7
toolchain/lower/testdata/function/call/i32.carbon

@@ -21,15 +21,15 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @Echo(i32 %a) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i32 %a
+// CHECK:STDOUT:   ret i32 %a, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !7 {
+// CHECK:STDOUT: define void @Main() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %b.var = alloca i32, align 4
-// CHECK:STDOUT:   %Echo.call = call i32 @Echo(i32 1)
-// CHECK:STDOUT:   store i32 %Echo.call, ptr %b.var, align 4
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %b.var = alloca i32, align 4, !dbg !9
+// CHECK:STDOUT:   %Echo.call = call i32 @Echo(i32 1), !dbg !10
+// CHECK:STDOUT:   store i32 %Echo.call, ptr %b.var, align 4, !dbg !11
+// CHECK:STDOUT:   ret void, !dbg !12
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -42,4 +42,9 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Echo", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 7, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 16, column: 16, scope: !8)
+// CHECK:STDOUT: !11 = !DILocation(line: 16, column: 3, scope: !8)
+// CHECK:STDOUT: !12 = !DILocation(line: 15, column: 1, scope: !8)

+ 17 - 11
toolchain/lower/testdata/function/call/implicit_empty_tuple_as_arg.carbon

@@ -22,21 +22,21 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Foo() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Bar() !dbg !7 {
+// CHECK:STDOUT: define void @Bar() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !8 {
+// CHECK:STDOUT: define void @Main() !dbg !10 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %x.var = alloca {}, align 8
-// CHECK:STDOUT:   call void @Foo()
-// CHECK:STDOUT:   %.loc17_22.1.temp = alloca {}, align 8
-// CHECK:STDOUT:   call void @Bar()
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %x.var = alloca {}, align 8, !dbg !11
+// CHECK:STDOUT:   call void @Foo(), !dbg !12
+// CHECK:STDOUT:   %.loc17_22.1.temp = alloca {}, align 8, !dbg !12
+// CHECK:STDOUT:   call void @Bar(), !dbg !13
+// CHECK:STDOUT:   ret void, !dbg !14
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -49,5 +49,11 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Foo", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Bar", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 16, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Bar", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 23, scope: !8)
+// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 16, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !11 = !DILocation(line: 17, column: 7, scope: !10)
+// CHECK:STDOUT: !12 = !DILocation(line: 17, column: 19, scope: !10)
+// CHECK:STDOUT: !13 = !DILocation(line: 17, column: 15, scope: !10)
+// CHECK:STDOUT: !14 = !DILocation(line: 16, column: 1, scope: !10)

+ 8 - 5
toolchain/lower/testdata/function/call/params_one.carbon

@@ -19,13 +19,13 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Foo(i32 %a) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !7 {
+// CHECK:STDOUT: define void @Main() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @Foo(i32 1)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @Foo(i32 1), !dbg !9
+// CHECK:STDOUT:   ret void, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -38,4 +38,7 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Foo", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 1, scope: !8)

+ 10 - 6
toolchain/lower/testdata/function/call/params_one_comma.carbon

@@ -20,14 +20,14 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Foo(i32 %a) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !7 {
+// CHECK:STDOUT: define void @Main() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @Foo(i32 1)
-// CHECK:STDOUT:   call void @Foo(i32 1)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @Foo(i32 1), !dbg !9
+// CHECK:STDOUT:   call void @Foo(i32 1), !dbg !10
+// CHECK:STDOUT:   ret void, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -40,4 +40,8 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Foo", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 3, scope: !8)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 1, scope: !8)

+ 8 - 5
toolchain/lower/testdata/function/call/params_two.carbon

@@ -19,13 +19,13 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Foo(i32 %a, i32 %b) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !7 {
+// CHECK:STDOUT: define void @Main() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @Foo(i32 1, i32 2)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @Foo(i32 1, i32 2), !dbg !9
+// CHECK:STDOUT:   ret void, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -38,4 +38,7 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Foo", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 1, scope: !8)

+ 10 - 6
toolchain/lower/testdata/function/call/params_two_comma.carbon

@@ -20,14 +20,14 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Foo(i32 %a, i32 %b) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !7 {
+// CHECK:STDOUT: define void @Main() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @Foo(i32 1, i32 2)
-// CHECK:STDOUT:   call void @Foo(i32 1, i32 2)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @Foo(i32 1, i32 2), !dbg !9
+// CHECK:STDOUT:   call void @Foo(i32 1, i32 2), !dbg !10
+// CHECK:STDOUT:   ret void, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -40,4 +40,8 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Foo", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 3, scope: !8)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 1, scope: !8)

+ 8 - 5
toolchain/lower/testdata/function/call/params_zero.carbon

@@ -19,13 +19,13 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Foo() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !7 {
+// CHECK:STDOUT: define void @Main() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @Foo()
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @Foo(), !dbg !9
+// CHECK:STDOUT:   ret void, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -38,4 +38,7 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Foo", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 1, scope: !8)

+ 10 - 6
toolchain/lower/testdata/function/call/return_implicit.carbon

@@ -21,14 +21,14 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @MakeImplicitEmptyTuple() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !7 {
+// CHECK:STDOUT: define void @Main() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %b.var = alloca {}, align 8
-// CHECK:STDOUT:   call void @MakeImplicitEmptyTuple()
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %b.var = alloca {}, align 8, !dbg !9
+// CHECK:STDOUT:   call void @MakeImplicitEmptyTuple(), !dbg !10
+// CHECK:STDOUT:   ret void, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -41,4 +41,8 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "MakeImplicitEmptyTuple", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 7, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 16, column: 15, scope: !8)
+// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 1, scope: !8)

+ 8 - 5
toolchain/lower/testdata/function/call/struct_param.carbon

@@ -21,13 +21,13 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F({ i32 } %b, ptr %c) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !7 {
+// CHECK:STDOUT: define void @Main() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @F({ i32 } { i32 1 }, ptr @struct.3.loc14_4.3)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @F({ i32 } { i32 1 }, ptr @struct.3.loc14_4.3), !dbg !9
+// CHECK:STDOUT:   ret void, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -40,4 +40,7 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 1, scope: !8)

+ 8 - 5
toolchain/lower/testdata/function/call/tuple_param.carbon

@@ -21,13 +21,13 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F({ i32 } %b, ptr %c) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !7 {
+// CHECK:STDOUT: define void @Main() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @F({ i32 } { i32 1 }, ptr @tuple.3.loc14_4.3)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @F({ i32 } { i32 1 }, ptr @tuple.3.loc14_4.3), !dbg !9
+// CHECK:STDOUT:   ret void, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -40,4 +40,7 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 1, scope: !8)

+ 24 - 17
toolchain/lower/testdata/function/call/tuple_param_with_return_slot.carbon

@@ -23,25 +23,25 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F(ptr sret({ i32, i32, i32 }) %return, { i32 } %b, ptr %c) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc12_12.tuple.index = extractvalue { i32 } %b, 0
-// CHECK:STDOUT:   %.loc12_17.tuple.index = getelementptr inbounds nuw { i32, i32 }, ptr %c, i32 0, i32 0
-// CHECK:STDOUT:   %.loc12_17.tuple.index.load = load i32, ptr %.loc12_17.tuple.index, align 4
-// CHECK:STDOUT:   %.loc12_22.tuple.index = getelementptr inbounds nuw { i32, i32 }, ptr %c, i32 0, i32 1
-// CHECK:STDOUT:   %.loc12_22.tuple.index.load = load i32, ptr %.loc12_22.tuple.index, align 4
-// CHECK:STDOUT:   %.loc12_24.2.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %return, i32 0, i32 0
-// CHECK:STDOUT:   store i32 %.loc12_12.tuple.index, ptr %.loc12_24.2.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc12_24.4.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %return, i32 0, i32 1
-// CHECK:STDOUT:   store i32 %.loc12_17.tuple.index.load, ptr %.loc12_24.4.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc12_24.6.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %return, i32 0, i32 2
-// CHECK:STDOUT:   store i32 %.loc12_22.tuple.index.load, ptr %.loc12_24.6.tuple.elem, align 4
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %.loc12_12.tuple.index = extractvalue { i32 } %b, 0, !dbg !7
+// CHECK:STDOUT:   %.loc12_17.tuple.index = getelementptr inbounds nuw { i32, i32 }, ptr %c, i32 0, i32 0, !dbg !8
+// CHECK:STDOUT:   %.loc12_17.tuple.index.load = load i32, ptr %.loc12_17.tuple.index, align 4, !dbg !8
+// CHECK:STDOUT:   %.loc12_22.tuple.index = getelementptr inbounds nuw { i32, i32 }, ptr %c, i32 0, i32 1, !dbg !9
+// CHECK:STDOUT:   %.loc12_22.tuple.index.load = load i32, ptr %.loc12_22.tuple.index, align 4, !dbg !9
+// CHECK:STDOUT:   %.loc12_24.2.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %return, i32 0, i32 0, !dbg !10
+// CHECK:STDOUT:   store i32 %.loc12_12.tuple.index, ptr %.loc12_24.2.tuple.elem, align 4, !dbg !10
+// CHECK:STDOUT:   %.loc12_24.4.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %return, i32 0, i32 1, !dbg !10
+// CHECK:STDOUT:   store i32 %.loc12_17.tuple.index.load, ptr %.loc12_24.4.tuple.elem, align 4, !dbg !10
+// CHECK:STDOUT:   %.loc12_24.6.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %return, i32 0, i32 2, !dbg !10
+// CHECK:STDOUT:   store i32 %.loc12_22.tuple.index.load, ptr %.loc12_24.6.tuple.elem, align 4, !dbg !10
+// CHECK:STDOUT:   ret void, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !7 {
+// CHECK:STDOUT: define void @Main() !dbg !12 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc16_4.1.temp = alloca { i32, i32, i32 }, align 8
-// CHECK:STDOUT:   call void @F(ptr %.loc16_4.1.temp, { i32 } { i32 1 }, ptr @tuple.3.loc16_4.4)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %.loc16_4.1.temp = alloca { i32, i32, i32 }, align 8, !dbg !13
+// CHECK:STDOUT:   call void @F(ptr %.loc16_4.1.temp, { i32 } { i32 1 }, ptr @tuple.3.loc16_4.4), !dbg !13
+// CHECK:STDOUT:   ret void, !dbg !14
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; uselistorder directives
@@ -57,4 +57,11 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 11, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 16, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 21, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 12, column: 10, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !13 = !DILocation(line: 16, column: 3, scope: !12)
+// CHECK:STDOUT: !14 = !DILocation(line: 15, column: 1, scope: !12)

+ 14 - 8
toolchain/lower/testdata/function/call/var_param.carbon

@@ -20,16 +20,16 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @DoNothing(i32 %a) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !7 {
+// CHECK:STDOUT: define void @Main() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %a.var = alloca i32, align 4
-// CHECK:STDOUT:   store i32 0, ptr %a.var, align 4
-// CHECK:STDOUT:   %.loc15 = load i32, ptr %a.var, align 4
-// CHECK:STDOUT:   call void @DoNothing(i32 %.loc15)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %a.var = alloca i32, align 4, !dbg !9
+// CHECK:STDOUT:   store i32 0, ptr %a.var, align 4, !dbg !10
+// CHECK:STDOUT:   %.loc15 = load i32, ptr %a.var, align 4, !dbg !11
+// CHECK:STDOUT:   call void @DoNothing(i32 %.loc15), !dbg !12
+// CHECK:STDOUT:   ret void, !dbg !13
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -42,4 +42,10 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "DoNothing", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 7, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 3, scope: !8)
+// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 13, scope: !8)
+// CHECK:STDOUT: !12 = !DILocation(line: 15, column: 3, scope: !8)
+// CHECK:STDOUT: !13 = !DILocation(line: 13, column: 1, scope: !8)

+ 4 - 2
toolchain/lower/testdata/function/declaration/simple.carbon

@@ -19,8 +19,8 @@ fn G(n: i32) { F(n); }
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @G(i32 %n) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @F(i32 %n)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @F(i32 %n), !dbg !7
+// CHECK:STDOUT:   ret void, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -33,3 +33,5 @@ fn G(n: i32) { F(n); }
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 13, column: 16, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 13, column: 1, scope: !4)

+ 2 - 1
toolchain/lower/testdata/function/definition/empty_struct.carbon

@@ -16,7 +16,7 @@ fn Echo(a: {}) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Echo() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -29,3 +29,4 @@ fn Echo(a: {}) {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Echo", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)

+ 2 - 1
toolchain/lower/testdata/function/definition/params_one.carbon

@@ -15,7 +15,7 @@ fn Foo(a: i32) {}
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Foo(i32 %a) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -28,3 +28,4 @@ fn Foo(a: i32) {}
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Foo", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)

+ 2 - 1
toolchain/lower/testdata/function/definition/params_two.carbon

@@ -15,7 +15,7 @@ fn Foo(a: i32, b: i32) {}
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Foo(i32 %a, i32 %b) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -28,3 +28,4 @@ fn Foo(a: i32, b: i32) {}
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Foo", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)

+ 2 - 1
toolchain/lower/testdata/function/definition/params_zero.carbon

@@ -15,7 +15,7 @@ fn Foo() {}
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Foo() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -28,3 +28,4 @@ fn Foo() {}
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Foo", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)

+ 4 - 2
toolchain/lower/testdata/global/class_obj.carbon

@@ -20,8 +20,8 @@ var a: A = {};
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @__global_init() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 1 @a, ptr align 1 @struct.loc12_14, i64 0, i1 false)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 1 @a, ptr align 1 @struct.loc12_14, i64 0, i1 false), !dbg !7
+// CHECK:STDOUT:   ret void, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -39,3 +39,5 @@ var a: A = {};
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "__global_init", scope: null, file: !3, line: 4294967295, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 4294967295, scope: !4)

+ 9 - 6
toolchain/lower/testdata/global/class_with_fun.carbon

@@ -25,14 +25,14 @@ var a: A = {};
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @ret_a(ptr sret({}) %return) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 1 %return, ptr align 1 @struct.loc13_12, i64 0, i1 false)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 1 %return, ptr align 1 @struct.loc13_12, i64 0, i1 false), !dbg !7
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @__global_init() !dbg !7 {
+// CHECK:STDOUT: define void @__global_init() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 1 @a, ptr align 1 @struct.loc16_14, i64 0, i1 false)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 1 @a, ptr align 1 @struct.loc16_14, i64 0, i1 false), !dbg !9
+// CHECK:STDOUT:   ret void, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -53,4 +53,7 @@ var a: A = {};
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "ret_a", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "__global_init", scope: null, file: !3, line: 4294967295, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 13, column: 3, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "__global_init", scope: null, file: !3, line: 4294967295, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 1, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 4294967295, scope: !8)

+ 4 - 2
toolchain/lower/testdata/global/simple_init.carbon

@@ -17,8 +17,8 @@ var a: i32 = 0;
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @__global_init() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   store i32 0, ptr @a, align 4
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   store i32 0, ptr @a, align 4, !dbg !7
+// CHECK:STDOUT:   ret void, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; uselistorder directives
@@ -34,3 +34,5 @@ var a: i32 = 0;
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "__global_init", scope: null, file: !3, line: 4294967295, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 10, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 4294967295, scope: !4)

+ 10 - 6
toolchain/lower/testdata/global/simple_with_fun.carbon

@@ -22,14 +22,14 @@ var a: i32 = test_a();
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @test_a() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i32 0
+// CHECK:STDOUT:   ret i32 0, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @__global_init() !dbg !7 {
+// CHECK:STDOUT: define void @__global_init() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %test_a.call = call i32 @test_a()
-// CHECK:STDOUT:   store i32 %test_a.call, ptr @a, align 4
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %test_a.call = call i32 @test_a(), !dbg !9
+// CHECK:STDOUT:   store i32 %test_a.call, ptr @a, align 4, !dbg !10
+// CHECK:STDOUT:   ret void, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; uselistorder directives
@@ -45,4 +45,8 @@ var a: i32 = test_a();
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "test_a", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "__global_init", scope: null, file: !3, line: 4294967295, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "__global_init", scope: null, file: !3, line: 4294967295, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 15, column: 14, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 1, scope: !8)
+// CHECK:STDOUT: !11 = !DILocation(line: 4294967295, scope: !8)

+ 25 - 16
toolchain/lower/testdata/if/else.carbon

@@ -26,34 +26,34 @@ fn If(b: bool) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @G() !dbg !7 {
+// CHECK:STDOUT: define void @G() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @H() !dbg !8 {
+// CHECK:STDOUT: define void @H() !dbg !10 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @If(i1 %b) !dbg !9 {
+// CHECK:STDOUT: define void @If(i1 %b) !dbg !12 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   br i1 %b, label %if.then, label %if.else
+// CHECK:STDOUT:   br i1 %b, label %if.then, label %if.else, !dbg !13
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.then:                                          ; preds = %entry
-// CHECK:STDOUT:   call void @F()
-// CHECK:STDOUT:   br label %if.done
+// CHECK:STDOUT:   call void @F(), !dbg !14
+// CHECK:STDOUT:   br label %if.done, !dbg !15
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.else:                                          ; preds = %entry
-// CHECK:STDOUT:   call void @G()
-// CHECK:STDOUT:   br label %if.done
+// CHECK:STDOUT:   call void @G(), !dbg !16
+// CHECK:STDOUT:   br label %if.done, !dbg !15
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.done:                                          ; preds = %if.else, %if.then
-// CHECK:STDOUT:   call void @H()
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @H(), !dbg !17
+// CHECK:STDOUT:   ret void, !dbg !18
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -66,6 +66,15 @@ fn If(b: bool) {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "H", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "If", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 1, scope: !8)
+// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "H", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 1, scope: !10)
+// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "If", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !13 = !DILocation(line: 16, column: 6, scope: !12)
+// CHECK:STDOUT: !14 = !DILocation(line: 17, column: 5, scope: !12)
+// CHECK:STDOUT: !15 = !DILocation(line: 16, column: 3, scope: !12)
+// CHECK:STDOUT: !16 = !DILocation(line: 19, column: 5, scope: !12)
+// CHECK:STDOUT: !17 = !DILocation(line: 21, column: 3, scope: !12)
+// CHECK:STDOUT: !18 = !DILocation(line: 15, column: 1, scope: !12)

+ 18 - 11
toolchain/lower/testdata/if/no_else.carbon

@@ -23,25 +23,25 @@ fn If(b: bool) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @G() !dbg !7 {
+// CHECK:STDOUT: define void @G() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @If(i1 %b) !dbg !8 {
+// CHECK:STDOUT: define void @If(i1 %b) !dbg !10 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   br i1 %b, label %if.then, label %if.else
+// CHECK:STDOUT:   br i1 %b, label %if.then, label %if.else, !dbg !11
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.then:                                          ; preds = %entry
-// CHECK:STDOUT:   call void @F()
-// CHECK:STDOUT:   br label %if.else
+// CHECK:STDOUT:   call void @F(), !dbg !12
+// CHECK:STDOUT:   br label %if.else, !dbg !13
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.else:                                          ; preds = %if.then, %entry
-// CHECK:STDOUT:   call void @G()
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @G(), !dbg !14
+// CHECK:STDOUT:   ret void, !dbg !15
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -54,5 +54,12 @@ fn If(b: bool) {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "If", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 1, scope: !8)
+// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "If", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 6, scope: !10)
+// CHECK:STDOUT: !12 = !DILocation(line: 16, column: 5, scope: !10)
+// CHECK:STDOUT: !13 = !DILocation(line: 15, column: 3, scope: !10)
+// CHECK:STDOUT: !14 = !DILocation(line: 18, column: 3, scope: !10)
+// CHECK:STDOUT: !15 = !DILocation(line: 14, column: 1, scope: !10)

+ 18 - 12
toolchain/lower/testdata/if_expr/basic.carbon

@@ -20,29 +20,29 @@ fn Select(b: bool) -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i32 1
+// CHECK:STDOUT:   ret i32 1, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @G() !dbg !7 {
+// CHECK:STDOUT: define i32 @G() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i32 2
+// CHECK:STDOUT:   ret i32 2, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @Select(i1 %b) !dbg !8 {
+// CHECK:STDOUT: define i32 @Select(i1 %b) !dbg !10 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   br i1 %b, label %if.expr.then, label %if.expr.else
+// CHECK:STDOUT:   br i1 %b, label %if.expr.then, label %if.expr.else, !dbg !11
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.expr.then:                                     ; preds = %entry
-// CHECK:STDOUT:   %F.call = call i32 @F()
-// CHECK:STDOUT:   br label %if.expr.result
+// CHECK:STDOUT:   %F.call = call i32 @F(), !dbg !12
+// CHECK:STDOUT:   br label %if.expr.result, !dbg !11
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.expr.else:                                     ; preds = %entry
-// CHECK:STDOUT:   %G.call = call i32 @G()
-// CHECK:STDOUT:   br label %if.expr.result
+// CHECK:STDOUT:   %G.call = call i32 @G(), !dbg !13
+// CHECK:STDOUT:   br label %if.expr.result, !dbg !11
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.expr.result:                                   ; preds = %if.expr.else, %if.expr.then
 // CHECK:STDOUT:   %0 = phi i32 [ %F.call, %if.expr.then ], [ %G.call, %if.expr.else ]
-// CHECK:STDOUT:   ret i32 %0
+// CHECK:STDOUT:   ret i32 %0, !dbg !14
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -55,5 +55,11 @@ fn Select(b: bool) -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Select", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 17, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 17, scope: !8)
+// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "Select", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 10, scope: !10)
+// CHECK:STDOUT: !12 = !DILocation(line: 15, column: 20, scope: !10)
+// CHECK:STDOUT: !13 = !DILocation(line: 15, column: 29, scope: !10)
+// CHECK:STDOUT: !14 = !DILocation(line: 15, column: 3, scope: !10)

+ 14 - 10
toolchain/lower/testdata/if_expr/empty_block.carbon

@@ -17,37 +17,37 @@ fn Select(b: bool, c: bool, d: bool) -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @Select(i1 %b, i1 %c, i1 %d) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   br i1 %b, label %if.expr.then.loc12_10, label %if.expr.else.loc12_10
+// CHECK:STDOUT:   br i1 %b, label %if.expr.then.loc12_10, label %if.expr.else.loc12_10, !dbg !7
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.expr.then.loc12_10:                            ; preds = %entry
-// CHECK:STDOUT:   br i1 %c, label %if.expr.then.loc12_20, label %if.expr.else.loc12_20
+// CHECK:STDOUT:   br i1 %c, label %if.expr.then.loc12_20, label %if.expr.else.loc12_20, !dbg !8
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.expr.then.loc12_20:                            ; preds = %if.expr.then.loc12_10
-// CHECK:STDOUT:   br label %if.expr.result.loc12_20
+// CHECK:STDOUT:   br label %if.expr.result.loc12_20, !dbg !8
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.expr.else.loc12_20:                            ; preds = %if.expr.then.loc12_10
-// CHECK:STDOUT:   br label %if.expr.result.loc12_20
+// CHECK:STDOUT:   br label %if.expr.result.loc12_20, !dbg !8
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.expr.result.loc12_20:                          ; preds = %if.expr.else.loc12_20, %if.expr.then.loc12_20
 // CHECK:STDOUT:   %0 = phi i32 [ 1, %if.expr.then.loc12_20 ], [ 2, %if.expr.else.loc12_20 ]
-// CHECK:STDOUT:   br label %if.expr.result.loc12_10
+// CHECK:STDOUT:   br label %if.expr.result.loc12_10, !dbg !7
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.expr.else.loc12_10:                            ; preds = %entry
-// CHECK:STDOUT:   br i1 %d, label %if.expr.then.loc12_44, label %if.expr.else.loc12_44
+// CHECK:STDOUT:   br i1 %d, label %if.expr.then.loc12_44, label %if.expr.else.loc12_44, !dbg !9
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.expr.then.loc12_44:                            ; preds = %if.expr.else.loc12_10
-// CHECK:STDOUT:   br label %if.expr.result.loc12_44
+// CHECK:STDOUT:   br label %if.expr.result.loc12_44, !dbg !9
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.expr.else.loc12_44:                            ; preds = %if.expr.else.loc12_10
-// CHECK:STDOUT:   br label %if.expr.result.loc12_44
+// CHECK:STDOUT:   br label %if.expr.result.loc12_44, !dbg !9
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.expr.result.loc12_44:                          ; preds = %if.expr.else.loc12_44, %if.expr.then.loc12_44
 // CHECK:STDOUT:   %1 = phi i32 [ 3, %if.expr.then.loc12_44 ], [ 4, %if.expr.else.loc12_44 ]
-// CHECK:STDOUT:   br label %if.expr.result.loc12_10
+// CHECK:STDOUT:   br label %if.expr.result.loc12_10, !dbg !7
 // CHECK:STDOUT:
 // CHECK:STDOUT: if.expr.result.loc12_10:                          ; preds = %if.expr.result.loc12_44, %if.expr.result.loc12_20
 // CHECK:STDOUT:   %2 = phi i32 [ %0, %if.expr.result.loc12_20 ], [ %1, %if.expr.result.loc12_44 ]
-// CHECK:STDOUT:   ret i32 %2
+// CHECK:STDOUT:   ret i32 %2, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -60,3 +60,7 @@ fn Select(b: bool, c: bool, d: bool) -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Select", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 10, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 20, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 44, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 12, column: 3, scope: !4)

+ 11 - 7
toolchain/lower/testdata/impl/assoc_fn_alias.carbon

@@ -32,15 +32,15 @@ fn Call(a: A) -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @F(ptr %self) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc22_16.1.n = getelementptr inbounds nuw { i32 }, ptr %self, i32 0, i32 0
-// CHECK:STDOUT:   %.loc22_16.2 = load i32, ptr %.loc22_16.1.n, align 4
-// CHECK:STDOUT:   ret i32 %.loc22_16.2
+// CHECK:STDOUT:   %.loc22_16.1.n = getelementptr inbounds nuw { i32 }, ptr %self, i32 0, i32 0, !dbg !7
+// CHECK:STDOUT:   %.loc22_16.2 = load i32, ptr %.loc22_16.1.n, align 4, !dbg !7
+// CHECK:STDOUT:   ret i32 %.loc22_16.2, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @Call(ptr %a) !dbg !7 {
+// CHECK:STDOUT: define i32 @Call(ptr %a) !dbg !9 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %F.call = call i32 @F(ptr %a)
-// CHECK:STDOUT:   ret i32 %F.call
+// CHECK:STDOUT:   %F.call = call i32 @F(ptr %a), !dbg !10
+// CHECK:STDOUT:   ret i32 %F.call, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -53,4 +53,8 @@ fn Call(a: A) -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 21, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Call", scope: null, file: !3, line: 26, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 22, column: 12, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 22, column: 5, scope: !4)
+// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "Call", scope: null, file: !3, line: 26, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !10 = !DILocation(line: 27, column: 10, scope: !9)
+// CHECK:STDOUT: !11 = !DILocation(line: 27, column: 3, scope: !9)

+ 14 - 9
toolchain/lower/testdata/impl/extend_impl.carbon

@@ -33,19 +33,19 @@ fn InstanceAccess(a: A) -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i32 0
+// CHECK:STDOUT:   ret i32 0, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @TypeAccess() !dbg !7 {
+// CHECK:STDOUT: define i32 @TypeAccess() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %F.call = call i32 @F()
-// CHECK:STDOUT:   ret i32 %F.call
+// CHECK:STDOUT:   %F.call = call i32 @F(), !dbg !9
+// CHECK:STDOUT:   ret i32 %F.call, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @InstanceAccess(ptr %a) !dbg !8 {
+// CHECK:STDOUT: define i32 @InstanceAccess(ptr %a) !dbg !11 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %F.call = call i32 @F()
-// CHECK:STDOUT:   ret i32 %F.call
+// CHECK:STDOUT:   %F.call = call i32 @F(), !dbg !12
+// CHECK:STDOUT:   ret i32 %F.call, !dbg !13
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -58,5 +58,10 @@ fn InstanceAccess(a: A) -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "TypeAccess", scope: null, file: !3, line: 23, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "InstanceAccess", scope: null, file: !3, line: 27, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 18, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "TypeAccess", scope: null, file: !3, line: 23, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 24, column: 10, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 24, column: 3, scope: !8)
+// CHECK:STDOUT: !11 = distinct !DISubprogram(name: "InstanceAccess", scope: null, file: !3, line: 27, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !12 = !DILocation(line: 28, column: 10, scope: !11)
+// CHECK:STDOUT: !13 = !DILocation(line: 28, column: 3, scope: !11)

+ 11 - 7
toolchain/lower/testdata/impl/impl.carbon

@@ -31,15 +31,15 @@ fn Call(a: A) -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @F(ptr %self) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc21_16.1.n = getelementptr inbounds nuw { i32 }, ptr %self, i32 0, i32 0
-// CHECK:STDOUT:   %.loc21_16.2 = load i32, ptr %.loc21_16.1.n, align 4
-// CHECK:STDOUT:   ret i32 %.loc21_16.2
+// CHECK:STDOUT:   %.loc21_16.1.n = getelementptr inbounds nuw { i32 }, ptr %self, i32 0, i32 0, !dbg !7
+// CHECK:STDOUT:   %.loc21_16.2 = load i32, ptr %.loc21_16.1.n, align 4, !dbg !7
+// CHECK:STDOUT:   ret i32 %.loc21_16.2, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @Call(ptr %a) !dbg !7 {
+// CHECK:STDOUT: define i32 @Call(ptr %a) !dbg !9 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %F.call = call i32 @F(ptr %a)
-// CHECK:STDOUT:   ret i32 %F.call
+// CHECK:STDOUT:   %F.call = call i32 @F(ptr %a), !dbg !10
+// CHECK:STDOUT:   ret i32 %F.call, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -52,4 +52,8 @@ fn Call(a: A) -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 20, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Call", scope: null, file: !3, line: 25, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 21, column: 12, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 21, column: 5, scope: !4)
+// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "Call", scope: null, file: !3, line: 25, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !10 = !DILocation(line: 26, column: 10, scope: !9)
+// CHECK:STDOUT: !11 = !DILocation(line: 26, column: 3, scope: !9)

+ 8 - 5
toolchain/lower/testdata/impl/instance_method.carbon

@@ -31,13 +31,13 @@ fn Call(a: A*) -> A* {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define ptr @Get(ptr %self) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret ptr %self
+// CHECK:STDOUT:   ret ptr %self, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define ptr @Call(ptr %a) !dbg !7 {
+// CHECK:STDOUT: define ptr @Call(ptr %a) !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %Get.call = call ptr @Get(ptr %a)
-// CHECK:STDOUT:   ret ptr %Get.call
+// CHECK:STDOUT:   %Get.call = call ptr @Get(ptr %a), !dbg !9
+// CHECK:STDOUT:   ret ptr %Get.call, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -50,4 +50,7 @@ fn Call(a: A*) -> A* {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Get", scope: null, file: !3, line: 19, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Call", scope: null, file: !3, line: 25, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 20, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Call", scope: null, file: !3, line: 25, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 26, column: 10, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 26, column: 3, scope: !8)

+ 53 - 37
toolchain/lower/testdata/index/array_element_access.carbon

@@ -26,47 +26,47 @@ fn Run() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @A(ptr sret({ i32, i32 }) %return) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc10_36.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 0
-// CHECK:STDOUT:   %.loc10_36.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 1
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %return, ptr align 4 @tuple.loc10_37, i64 8, i1 false)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %.loc10_36.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 0, !dbg !7
+// CHECK:STDOUT:   %.loc10_36.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 1, !dbg !7
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %return, ptr align 4 @tuple.loc10_37, i64 8, i1 false), !dbg !8
+// CHECK:STDOUT:   ret void, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @B(ptr sret([2 x i32]) %return) !dbg !7 {
+// CHECK:STDOUT: define void @B(ptr sret([2 x i32]) %return) !dbg !9 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc12_34.3.array.index = getelementptr inbounds [2 x i32], ptr %return, i32 0, i32 0
-// CHECK:STDOUT:   %.loc12_34.6.array.index = getelementptr inbounds [2 x i32], ptr %return, i32 0, i32 1
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %return, ptr align 4 @array.loc12_35, i64 8, i1 false)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %.loc12_34.3.array.index = getelementptr inbounds [2 x i32], ptr %return, i32 0, i32 0, !dbg !10
+// CHECK:STDOUT:   %.loc12_34.6.array.index = getelementptr inbounds [2 x i32], ptr %return, i32 0, i32 1, !dbg !10
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %return, ptr align 4 @array.loc12_35, i64 8, i1 false), !dbg !11
+// CHECK:STDOUT:   ret void, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @main() !dbg !8 {
+// CHECK:STDOUT: define void @main() !dbg !12 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %a.var = alloca [2 x i32], align 4
-// CHECK:STDOUT:   %.loc15_22.1.temp = alloca { i32, i32 }, align 8
-// CHECK:STDOUT:   call void @A(ptr %.loc15_22.1.temp)
-// CHECK:STDOUT:   %.loc15_22.3.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc15_22.1.temp, i32 0, i32 0
-// CHECK:STDOUT:   %.loc15_22.4 = load i32, ptr %.loc15_22.3.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc15_22.6.array.index = getelementptr inbounds [2 x i32], ptr %a.var, i32 0, i32 0
-// CHECK:STDOUT:   store i32 %.loc15_22.4, ptr %.loc15_22.6.array.index, align 4
-// CHECK:STDOUT:   %.loc15_22.8.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc15_22.1.temp, i32 0, i32 1
-// CHECK:STDOUT:   %.loc15_22.9 = load i32, ptr %.loc15_22.8.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc15_22.11.array.index = getelementptr inbounds [2 x i32], ptr %a.var, i32 0, i32 1
-// CHECK:STDOUT:   store i32 %.loc15_22.9, ptr %.loc15_22.11.array.index, align 4
-// CHECK:STDOUT:   %b.var = alloca i32, align 4
-// CHECK:STDOUT:   store i32 1, ptr %b.var, align 4
-// CHECK:STDOUT:   %c.var = alloca i32, align 4
-// CHECK:STDOUT:   %.loc17_18 = load i32, ptr %b.var, align 4
-// CHECK:STDOUT:   %.loc17_19.1.array.index = getelementptr inbounds [2 x i32], ptr %a.var, i32 0, i32 %.loc17_18
-// CHECK:STDOUT:   %.loc17_19.2 = load i32, ptr %.loc17_19.1.array.index, align 4
-// CHECK:STDOUT:   store i32 %.loc17_19.2, ptr %c.var, align 4
-// CHECK:STDOUT:   %d.var = alloca i32, align 4
-// CHECK:STDOUT:   %.loc18_17.1.temp = alloca [2 x i32], align 4
-// CHECK:STDOUT:   call void @B(ptr %.loc18_17.1.temp)
-// CHECK:STDOUT:   %.loc18_21.1.array.index = getelementptr inbounds [2 x i32], ptr %.loc18_17.1.temp, i32 0, i32 1
-// CHECK:STDOUT:   %.loc18_21.2 = load i32, ptr %.loc18_21.1.array.index, align 4
-// CHECK:STDOUT:   store i32 %.loc18_21.2, ptr %d.var, align 4
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %a.var = alloca [2 x i32], align 4, !dbg !13
+// CHECK:STDOUT:   %.loc15_22.1.temp = alloca { i32, i32 }, align 8, !dbg !14
+// CHECK:STDOUT:   call void @A(ptr %.loc15_22.1.temp), !dbg !14
+// CHECK:STDOUT:   %.loc15_22.3.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc15_22.1.temp, i32 0, i32 0, !dbg !14
+// CHECK:STDOUT:   %.loc15_22.4 = load i32, ptr %.loc15_22.3.tuple.elem, align 4, !dbg !14
+// CHECK:STDOUT:   %.loc15_22.6.array.index = getelementptr inbounds [2 x i32], ptr %a.var, i32 0, i32 0, !dbg !14
+// CHECK:STDOUT:   store i32 %.loc15_22.4, ptr %.loc15_22.6.array.index, align 4, !dbg !14
+// CHECK:STDOUT:   %.loc15_22.8.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc15_22.1.temp, i32 0, i32 1, !dbg !14
+// CHECK:STDOUT:   %.loc15_22.9 = load i32, ptr %.loc15_22.8.tuple.elem, align 4, !dbg !14
+// CHECK:STDOUT:   %.loc15_22.11.array.index = getelementptr inbounds [2 x i32], ptr %a.var, i32 0, i32 1, !dbg !14
+// CHECK:STDOUT:   store i32 %.loc15_22.9, ptr %.loc15_22.11.array.index, align 4, !dbg !14
+// CHECK:STDOUT:   %b.var = alloca i32, align 4, !dbg !15
+// CHECK:STDOUT:   store i32 1, ptr %b.var, align 4, !dbg !16
+// CHECK:STDOUT:   %c.var = alloca i32, align 4, !dbg !17
+// CHECK:STDOUT:   %.loc17_18 = load i32, ptr %b.var, align 4, !dbg !18
+// CHECK:STDOUT:   %.loc17_19.1.array.index = getelementptr inbounds [2 x i32], ptr %a.var, i32 0, i32 %.loc17_18, !dbg !19
+// CHECK:STDOUT:   %.loc17_19.2 = load i32, ptr %.loc17_19.1.array.index, align 4, !dbg !19
+// CHECK:STDOUT:   store i32 %.loc17_19.2, ptr %c.var, align 4, !dbg !20
+// CHECK:STDOUT:   %d.var = alloca i32, align 4, !dbg !21
+// CHECK:STDOUT:   %.loc18_17.1.temp = alloca [2 x i32], align 4, !dbg !22
+// CHECK:STDOUT:   call void @B(ptr %.loc18_17.1.temp), !dbg !22
+// CHECK:STDOUT:   %.loc18_21.1.array.index = getelementptr inbounds [2 x i32], ptr %.loc18_17.1.temp, i32 0, i32 1, !dbg !22
+// CHECK:STDOUT:   %.loc18_21.2 = load i32, ptr %.loc18_21.1.array.index, align 4, !dbg !22
+// CHECK:STDOUT:   store i32 %.loc18_21.2, ptr %d.var, align 4, !dbg !23
+// CHECK:STDOUT:   ret void, !dbg !24
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -87,5 +87,21 @@ fn Run() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "A", scope: null, file: !3, line: 10, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "B", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 10, column: 31, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 10, column: 24, scope: !4)
+// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "B", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !10 = !DILocation(line: 12, column: 29, scope: !9)
+// CHECK:STDOUT: !11 = !DILocation(line: 12, column: 22, scope: !9)
+// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !13 = !DILocation(line: 15, column: 7, scope: !12)
+// CHECK:STDOUT: !14 = !DILocation(line: 15, column: 21, scope: !12)
+// CHECK:STDOUT: !15 = !DILocation(line: 16, column: 7, scope: !12)
+// CHECK:STDOUT: !16 = !DILocation(line: 16, column: 3, scope: !12)
+// CHECK:STDOUT: !17 = !DILocation(line: 17, column: 7, scope: !12)
+// CHECK:STDOUT: !18 = !DILocation(line: 17, column: 18, scope: !12)
+// CHECK:STDOUT: !19 = !DILocation(line: 17, column: 16, scope: !12)
+// CHECK:STDOUT: !20 = !DILocation(line: 17, column: 3, scope: !12)
+// CHECK:STDOUT: !21 = !DILocation(line: 18, column: 7, scope: !12)
+// CHECK:STDOUT: !22 = !DILocation(line: 18, column: 16, scope: !12)
+// CHECK:STDOUT: !23 = !DILocation(line: 18, column: 3, scope: !12)
+// CHECK:STDOUT: !24 = !DILocation(line: 14, column: 1, scope: !12)

+ 2 - 1
toolchain/lower/testdata/interface/assoc.carbon

@@ -19,7 +19,7 @@ fn F() { I.Assoc; }
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -32,3 +32,4 @@ fn F() { I.Assoc; }
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 15, column: 1, scope: !4)

+ 6 - 4
toolchain/lower/testdata/interface/basic.carbon

@@ -26,12 +26,12 @@ fn G(T: J) {}
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @G() !dbg !7 {
+// CHECK:STDOUT: define void @G() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -44,4 +44,6 @@ fn G(T: J) {}
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 17, column: 19, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 22, column: 1, scope: !8)

+ 2 - 1
toolchain/lower/testdata/let/local.carbon

@@ -19,7 +19,7 @@ fn Run() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i32 1
+// CHECK:STDOUT:   ret i32 1, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -32,3 +32,4 @@ fn Run() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 3, scope: !4)

+ 52 - 41
toolchain/lower/testdata/let/tuple.carbon

@@ -23,47 +23,47 @@ fn F() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %a.var = alloca { i32, i32, i32 }, align 8
-// CHECK:STDOUT:   %.loc12_36.2.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc12_36.4.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 1
-// CHECK:STDOUT:   %.loc12_36.6.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a.var, ptr align 4 @tuple.1.loc12_37, i64 12, i1 false)
-// CHECK:STDOUT:   %b.var = alloca { i32, i32 }, align 8
-// CHECK:STDOUT:   %.loc13_28.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc13_28.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 1
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %b.var, ptr align 4 @tuple.2.loc13_29, i64 8, i1 false)
-// CHECK:STDOUT:   %.loc14_43.1.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc14_43.2 = load i32, ptr %.loc14_43.1.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc14_43.3.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 1
-// CHECK:STDOUT:   %.loc14_43.4 = load i32, ptr %.loc14_43.3.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc14_43.5.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2
-// CHECK:STDOUT:   %.loc14_43.6 = load i32, ptr %.loc14_43.5.tuple.elem, align 4
-// CHECK:STDOUT:   %tuple.loc14_43 = alloca { i32, i32, i32 }, align 8
-// CHECK:STDOUT:   %tuple.loc14_431 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc14_43, i32 0, i32 0
-// CHECK:STDOUT:   store i32 %.loc14_43.2, ptr %tuple.loc14_431, align 4
-// CHECK:STDOUT:   %tuple.loc14_432 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc14_43, i32 0, i32 1
-// CHECK:STDOUT:   store i32 %.loc14_43.4, ptr %tuple.loc14_432, align 4
-// CHECK:STDOUT:   %tuple.loc14_433 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc14_43, i32 0, i32 2
-// CHECK:STDOUT:   store i32 %.loc14_43.6, ptr %tuple.loc14_433, align 4
-// CHECK:STDOUT:   %.loc14_46.1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc14_46.2 = load i32, ptr %.loc14_46.1.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc14_46.3.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 1
-// CHECK:STDOUT:   %.loc14_46.4 = load i32, ptr %.loc14_46.3.tuple.elem, align 4
-// CHECK:STDOUT:   %tuple.loc14_46 = alloca { i32, i32 }, align 8
-// CHECK:STDOUT:   %tuple.loc14_464 = getelementptr inbounds nuw { i32, i32 }, ptr %tuple.loc14_46, i32 0, i32 0
-// CHECK:STDOUT:   store i32 %.loc14_46.2, ptr %tuple.loc14_464, align 4
-// CHECK:STDOUT:   %tuple.loc14_465 = getelementptr inbounds nuw { i32, i32 }, ptr %tuple.loc14_46, i32 0, i32 1
-// CHECK:STDOUT:   store i32 %.loc14_46.4, ptr %tuple.loc14_465, align 4
-// CHECK:STDOUT:   %tuple.loc14_47 = alloca { ptr, ptr }, align 8
-// CHECK:STDOUT:   %tuple.loc14_476 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 0
-// CHECK:STDOUT:   store ptr %tuple.loc14_43, ptr %tuple.loc14_476, align 8
-// CHECK:STDOUT:   %tuple.loc14_477 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 1
-// CHECK:STDOUT:   store ptr %tuple.loc14_46, ptr %tuple.loc14_477, align 8
-// CHECK:STDOUT:   %.loc15_11.tuple.index = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 1
-// CHECK:STDOUT:   %.loc15_11.tuple.index.load = load ptr, ptr %.loc15_11.tuple.index, align 8
-// CHECK:STDOUT:   %.loc15_13.tuple.index = getelementptr inbounds nuw { i32, i32 }, ptr %.loc15_11.tuple.index.load, i32 0, i32 1
-// CHECK:STDOUT:   %.loc15_13.tuple.index.load = load i32, ptr %.loc15_13.tuple.index, align 4
-// CHECK:STDOUT:   ret i32 %.loc15_13.tuple.index.load
+// CHECK:STDOUT:   %a.var = alloca { i32, i32, i32 }, align 8, !dbg !7
+// CHECK:STDOUT:   %.loc12_36.2.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0, !dbg !8
+// CHECK:STDOUT:   %.loc12_36.4.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 1, !dbg !8
+// CHECK:STDOUT:   %.loc12_36.6.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2, !dbg !8
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a.var, ptr align 4 @tuple.1.loc12_37, i64 12, i1 false), !dbg !9
+// CHECK:STDOUT:   %b.var = alloca { i32, i32 }, align 8, !dbg !10
+// CHECK:STDOUT:   %.loc13_28.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 0, !dbg !11
+// CHECK:STDOUT:   %.loc13_28.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 1, !dbg !11
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %b.var, ptr align 4 @tuple.2.loc13_29, i64 8, i1 false), !dbg !12
+// CHECK:STDOUT:   %.loc14_43.1.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0, !dbg !13
+// CHECK:STDOUT:   %.loc14_43.2 = load i32, ptr %.loc14_43.1.tuple.elem, align 4, !dbg !13
+// CHECK:STDOUT:   %.loc14_43.3.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 1, !dbg !13
+// CHECK:STDOUT:   %.loc14_43.4 = load i32, ptr %.loc14_43.3.tuple.elem, align 4, !dbg !13
+// CHECK:STDOUT:   %.loc14_43.5.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2, !dbg !13
+// CHECK:STDOUT:   %.loc14_43.6 = load i32, ptr %.loc14_43.5.tuple.elem, align 4, !dbg !13
+// CHECK:STDOUT:   %tuple.loc14_43 = alloca { i32, i32, i32 }, align 8, !dbg !13
+// CHECK:STDOUT:   %tuple.loc14_431 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc14_43, i32 0, i32 0, !dbg !13
+// CHECK:STDOUT:   store i32 %.loc14_43.2, ptr %tuple.loc14_431, align 4, !dbg !13
+// CHECK:STDOUT:   %tuple.loc14_432 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc14_43, i32 0, i32 1, !dbg !13
+// CHECK:STDOUT:   store i32 %.loc14_43.4, ptr %tuple.loc14_432, align 4, !dbg !13
+// CHECK:STDOUT:   %tuple.loc14_433 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc14_43, i32 0, i32 2, !dbg !13
+// CHECK:STDOUT:   store i32 %.loc14_43.6, ptr %tuple.loc14_433, align 4, !dbg !13
+// CHECK:STDOUT:   %.loc14_46.1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 0, !dbg !14
+// CHECK:STDOUT:   %.loc14_46.2 = load i32, ptr %.loc14_46.1.tuple.elem, align 4, !dbg !14
+// CHECK:STDOUT:   %.loc14_46.3.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 1, !dbg !14
+// CHECK:STDOUT:   %.loc14_46.4 = load i32, ptr %.loc14_46.3.tuple.elem, align 4, !dbg !14
+// CHECK:STDOUT:   %tuple.loc14_46 = alloca { i32, i32 }, align 8, !dbg !14
+// CHECK:STDOUT:   %tuple.loc14_464 = getelementptr inbounds nuw { i32, i32 }, ptr %tuple.loc14_46, i32 0, i32 0, !dbg !14
+// CHECK:STDOUT:   store i32 %.loc14_46.2, ptr %tuple.loc14_464, align 4, !dbg !14
+// CHECK:STDOUT:   %tuple.loc14_465 = getelementptr inbounds nuw { i32, i32 }, ptr %tuple.loc14_46, i32 0, i32 1, !dbg !14
+// CHECK:STDOUT:   store i32 %.loc14_46.4, ptr %tuple.loc14_465, align 4, !dbg !14
+// CHECK:STDOUT:   %tuple.loc14_47 = alloca { ptr, ptr }, align 8, !dbg !15
+// CHECK:STDOUT:   %tuple.loc14_476 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 0, !dbg !15
+// CHECK:STDOUT:   store ptr %tuple.loc14_43, ptr %tuple.loc14_476, align 8, !dbg !15
+// CHECK:STDOUT:   %tuple.loc14_477 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 1, !dbg !15
+// CHECK:STDOUT:   store ptr %tuple.loc14_46, ptr %tuple.loc14_477, align 8, !dbg !15
+// CHECK:STDOUT:   %.loc15_11.tuple.index = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 1, !dbg !16
+// CHECK:STDOUT:   %.loc15_11.tuple.index.load = load ptr, ptr %.loc15_11.tuple.index, align 8, !dbg !16
+// CHECK:STDOUT:   %.loc15_13.tuple.index = getelementptr inbounds nuw { i32, i32 }, ptr %.loc15_11.tuple.index.load, i32 0, i32 1, !dbg !16
+// CHECK:STDOUT:   %.loc15_13.tuple.index.load = load i32, ptr %.loc15_13.tuple.index, align 4, !dbg !16
+// CHECK:STDOUT:   ret i32 %.loc15_13.tuple.index.load, !dbg !17
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -84,3 +84,14 @@ fn F() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 28, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 7, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 23, scope: !4)
+// CHECK:STDOUT: !12 = !DILocation(line: 13, column: 3, scope: !4)
+// CHECK:STDOUT: !13 = !DILocation(line: 14, column: 43, scope: !4)
+// CHECK:STDOUT: !14 = !DILocation(line: 14, column: 46, scope: !4)
+// CHECK:STDOUT: !15 = !DILocation(line: 14, column: 42, scope: !4)
+// CHECK:STDOUT: !16 = !DILocation(line: 15, column: 10, scope: !4)
+// CHECK:STDOUT: !17 = !DILocation(line: 15, column: 3, scope: !4)

+ 12 - 8
toolchain/lower/testdata/namespace/function.carbon

@@ -26,18 +26,18 @@ fn Bar() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Baz() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Baz.1() !dbg !7 {
+// CHECK:STDOUT: define void @Baz.1() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Bar() !dbg !8 {
+// CHECK:STDOUT: define void @Bar() !dbg !10 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @Baz.1()
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @Baz.1(), !dbg !11
+// CHECK:STDOUT:   ret void, !dbg !12
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -50,5 +50,9 @@ fn Bar() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Baz", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Baz.1", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Bar", scope: null, file: !3, line: 20, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Baz.1", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 17, column: 1, scope: !8)
+// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "Bar", scope: null, file: !3, line: 20, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !11 = !DILocation(line: 21, column: 3, scope: !10)
+// CHECK:STDOUT: !12 = !DILocation(line: 20, column: 1, scope: !10)

+ 8 - 5
toolchain/lower/testdata/namespace/nested.carbon

@@ -23,13 +23,13 @@ fn Foo.Bar.Baz() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Wiz() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Baz() !dbg !7 {
+// CHECK:STDOUT: define void @Baz() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @Wiz()
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @Wiz(), !dbg !9
+// CHECK:STDOUT:   ret void, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -42,4 +42,7 @@ fn Foo.Bar.Baz() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Wiz", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Baz", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Baz", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 18, column: 3, scope: !8)
+// CHECK:STDOUT: !10 = !DILocation(line: 17, column: 1, scope: !8)

+ 16 - 11
toolchain/lower/testdata/operators/and.carbon

@@ -20,26 +20,26 @@ fn And() -> bool {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i1 @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i1 true
+// CHECK:STDOUT:   ret i1 true, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @G() !dbg !7 {
+// CHECK:STDOUT: define i1 @G() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i1 true
+// CHECK:STDOUT:   ret i1 true, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @And() !dbg !8 {
+// CHECK:STDOUT: define i1 @And() !dbg !10 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %F.call = call i1 @F()
-// CHECK:STDOUT:   br i1 %F.call, label %and.rhs, label %and.result
+// CHECK:STDOUT:   %F.call = call i1 @F(), !dbg !11
+// CHECK:STDOUT:   br i1 %F.call, label %and.rhs, label %and.result, !dbg !11
 // CHECK:STDOUT:
 // CHECK:STDOUT: and.rhs:                                          ; preds = %entry
-// CHECK:STDOUT:   %G.call = call i1 @G()
-// CHECK:STDOUT:   br label %and.result
+// CHECK:STDOUT:   %G.call = call i1 @G(), !dbg !12
+// CHECK:STDOUT:   br label %and.result, !dbg !11
 // CHECK:STDOUT:
 // CHECK:STDOUT: and.result:                                       ; preds = %and.rhs, %entry
 // CHECK:STDOUT:   %0 = phi i1 [ false, %entry ], [ %G.call, %and.rhs ]
-// CHECK:STDOUT:   ret i1 %0
+// CHECK:STDOUT:   ret i1 %0, !dbg !13
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -52,5 +52,10 @@ fn And() -> bool {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "And", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 18, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 18, scope: !8)
+// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "And", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 10, scope: !10)
+// CHECK:STDOUT: !12 = !DILocation(line: 15, column: 18, scope: !10)
+// CHECK:STDOUT: !13 = !DILocation(line: 15, column: 3, scope: !10)

+ 5 - 3
toolchain/lower/testdata/operators/and_empty_block.carbon

@@ -19,14 +19,14 @@ fn And(b: bool, c: bool) -> bool {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i1 @And(i1 %b, i1 %c) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   br i1 %b, label %and.rhs, label %and.result
+// CHECK:STDOUT:   br i1 %b, label %and.rhs, label %and.result, !dbg !7
 // CHECK:STDOUT:
 // CHECK:STDOUT: and.rhs:                                          ; preds = %entry
-// CHECK:STDOUT:   br label %and.result
+// CHECK:STDOUT:   br label %and.result, !dbg !7
 // CHECK:STDOUT:
 // CHECK:STDOUT: and.result:                                       ; preds = %and.rhs, %entry
 // CHECK:STDOUT:   %0 = phi i1 [ false, %entry ], [ %c, %and.rhs ]
-// CHECK:STDOUT:   ret i1 %0
+// CHECK:STDOUT:   ret i1 %0, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -39,3 +39,5 @@ fn And(b: bool, c: bool) -> bool {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "And", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 10, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 3, scope: !4)

+ 15 - 8
toolchain/lower/testdata/operators/assignment.carbon

@@ -22,14 +22,14 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %a.var = alloca i32, align 4
-// CHECK:STDOUT:   store i32 12, ptr %a.var, align 4
-// CHECK:STDOUT:   store i32 9, ptr %a.var, align 4
-// CHECK:STDOUT:   %b.var = alloca { i32, i32 }, align 8
-// CHECK:STDOUT:   %.loc15_12.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc15_12.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 1
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %b.var, ptr align 4 @tuple.loc15_5, i64 8, i1 false)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %a.var = alloca i32, align 4, !dbg !7
+// CHECK:STDOUT:   store i32 12, ptr %a.var, align 4, !dbg !8
+// CHECK:STDOUT:   store i32 9, ptr %a.var, align 4, !dbg !9
+// CHECK:STDOUT:   %b.var = alloca { i32, i32 }, align 8, !dbg !10
+// CHECK:STDOUT:   %.loc15_12.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 0, !dbg !11
+// CHECK:STDOUT:   %.loc15_12.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 1, !dbg !11
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %b.var, ptr align 4 @tuple.loc15_5, i64 8, i1 false), !dbg !12
+// CHECK:STDOUT:   ret void, !dbg !13
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -47,3 +47,10 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 3, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 7, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 7, scope: !4)
+// CHECK:STDOUT: !12 = !DILocation(line: 15, column: 3, scope: !4)
+// CHECK:STDOUT: !13 = !DILocation(line: 11, column: 1, scope: !4)

+ 4 - 2
toolchain/lower/testdata/operators/not.carbon

@@ -17,8 +17,8 @@ fn Not(b: bool) -> bool {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i1 @Not(i1 %b) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc12 = xor i1 %b, true
-// CHECK:STDOUT:   ret i1 %.loc12
+// CHECK:STDOUT:   %.loc12 = xor i1 %b, true, !dbg !7
+// CHECK:STDOUT:   ret i1 %.loc12, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -31,3 +31,5 @@ fn Not(b: bool) -> bool {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Not", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 10, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4)

+ 17 - 12
toolchain/lower/testdata/operators/or.carbon

@@ -20,27 +20,27 @@ fn Or() -> bool {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i1 @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i1 true
+// CHECK:STDOUT:   ret i1 true, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @G() !dbg !7 {
+// CHECK:STDOUT: define i1 @G() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i1 true
+// CHECK:STDOUT:   ret i1 true, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i1 @Or() !dbg !8 {
+// CHECK:STDOUT: define i1 @Or() !dbg !10 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %F.call = call i1 @F()
-// CHECK:STDOUT:   %.loc15_14.3 = xor i1 %F.call, true
-// CHECK:STDOUT:   br i1 %.loc15_14.3, label %or.rhs, label %or.result
+// CHECK:STDOUT:   %F.call = call i1 @F(), !dbg !11
+// CHECK:STDOUT:   %.loc15_14.3 = xor i1 %F.call, true, !dbg !11
+// CHECK:STDOUT:   br i1 %.loc15_14.3, label %or.rhs, label %or.result, !dbg !11
 // CHECK:STDOUT:
 // CHECK:STDOUT: or.rhs:                                           ; preds = %entry
-// CHECK:STDOUT:   %G.call = call i1 @G()
-// CHECK:STDOUT:   br label %or.result
+// CHECK:STDOUT:   %G.call = call i1 @G(), !dbg !12
+// CHECK:STDOUT:   br label %or.result, !dbg !11
 // CHECK:STDOUT:
 // CHECK:STDOUT: or.result:                                        ; preds = %or.rhs, %entry
 // CHECK:STDOUT:   %0 = phi i1 [ true, %entry ], [ %G.call, %or.rhs ]
-// CHECK:STDOUT:   ret i1 %0
+// CHECK:STDOUT:   ret i1 %0, !dbg !13
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -53,5 +53,10 @@ fn Or() -> bool {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Or", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 18, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 18, scope: !8)
+// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "Or", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 10, scope: !10)
+// CHECK:STDOUT: !12 = !DILocation(line: 15, column: 17, scope: !10)
+// CHECK:STDOUT: !13 = !DILocation(line: 15, column: 3, scope: !10)

+ 6 - 4
toolchain/lower/testdata/operators/or_empty_block.carbon

@@ -19,15 +19,15 @@ fn Or(b: bool, c: bool) -> bool {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i1 @Or(i1 %b, i1 %c) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc14_12.1 = xor i1 %b, true
-// CHECK:STDOUT:   br i1 %.loc14_12.1, label %or.rhs, label %or.result
+// CHECK:STDOUT:   %.loc14_12.1 = xor i1 %b, true, !dbg !7
+// CHECK:STDOUT:   br i1 %.loc14_12.1, label %or.rhs, label %or.result, !dbg !7
 // CHECK:STDOUT:
 // CHECK:STDOUT: or.rhs:                                           ; preds = %entry
-// CHECK:STDOUT:   br label %or.result
+// CHECK:STDOUT:   br label %or.result, !dbg !7
 // CHECK:STDOUT:
 // CHECK:STDOUT: or.result:                                        ; preds = %or.rhs, %entry
 // CHECK:STDOUT:   %0 = phi i1 [ true, %entry ], [ %c, %or.rhs ]
-// CHECK:STDOUT:   ret i1 %0
+// CHECK:STDOUT:   ret i1 %0, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -40,3 +40,5 @@ fn Or(b: bool, c: bool) -> bool {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Or", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 10, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 3, scope: !4)

+ 49 - 34
toolchain/lower/testdata/operators/overloaded.carbon

@@ -33,59 +33,59 @@ fn Calculate(a: Number, b: Number) -> Number {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Op(ptr sret({ i1 }) %return, ptr %self) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc17_36.1.is_positive = getelementptr inbounds nuw { i1 }, ptr %self, i32 0, i32 0
-// CHECK:STDOUT:   %.loc17_36.2 = load i1, ptr %.loc17_36.1.is_positive, align 1
-// CHECK:STDOUT:   %.loc17_28 = xor i1 %.loc17_36.2, true
-// CHECK:STDOUT:   %.loc17_48.2.is_positive = getelementptr inbounds nuw { i1 }, ptr %return, i32 0, i32 0
-// CHECK:STDOUT:   store i1 %.loc17_28, ptr %.loc17_48.2.is_positive, align 1
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %.loc17_36.1.is_positive = getelementptr inbounds nuw { i1 }, ptr %self, i32 0, i32 0, !dbg !7
+// CHECK:STDOUT:   %.loc17_36.2 = load i1, ptr %.loc17_36.1.is_positive, align 1, !dbg !7
+// CHECK:STDOUT:   %.loc17_28 = xor i1 %.loc17_36.2, true, !dbg !8
+// CHECK:STDOUT:   %.loc17_48.2.is_positive = getelementptr inbounds nuw { i1 }, ptr %return, i32 0, i32 0, !dbg !9
+// CHECK:STDOUT:   store i1 %.loc17_28, ptr %.loc17_48.2.is_positive, align 1, !dbg !9
+// CHECK:STDOUT:   ret void, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Op.1(ptr sret({ i1 }) %return, ptr %self, ptr %other) !dbg !7 {
+// CHECK:STDOUT: define void @Op.1(ptr sret({ i1 }) %return, ptr %self, ptr %other) !dbg !11 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc22_33.1.is_positive = getelementptr inbounds nuw { i1 }, ptr %self, i32 0, i32 0
-// CHECK:STDOUT:   %.loc22_33.2 = load i1, ptr %.loc22_33.1.is_positive, align 1
-// CHECK:STDOUT:   br i1 %.loc22_33.2, label %and.rhs.loc22, label %and.result.loc22
+// CHECK:STDOUT:   %.loc22_33.1.is_positive = getelementptr inbounds nuw { i1 }, ptr %self, i32 0, i32 0, !dbg !12
+// CHECK:STDOUT:   %.loc22_33.2 = load i1, ptr %.loc22_33.1.is_positive, align 1, !dbg !12
+// CHECK:STDOUT:   br i1 %.loc22_33.2, label %and.rhs.loc22, label %and.result.loc22, !dbg !12
 // CHECK:STDOUT:
 // CHECK:STDOUT: and.rhs.loc22:                                    ; preds = %entry
-// CHECK:STDOUT:   %.loc22_55.1.is_positive = getelementptr inbounds nuw { i1 }, ptr %other, i32 0, i32 0
-// CHECK:STDOUT:   %.loc22_55.2 = load i1, ptr %.loc22_55.1.is_positive, align 1
-// CHECK:STDOUT:   br label %and.result.loc22
+// CHECK:STDOUT:   %.loc22_55.1.is_positive = getelementptr inbounds nuw { i1 }, ptr %other, i32 0, i32 0, !dbg !13
+// CHECK:STDOUT:   %.loc22_55.2 = load i1, ptr %.loc22_55.1.is_positive, align 1, !dbg !13
+// CHECK:STDOUT:   br label %and.result.loc22, !dbg !12
 // CHECK:STDOUT:
 // CHECK:STDOUT: and.result.loc22:                                 ; preds = %and.rhs.loc22, %entry
 // CHECK:STDOUT:   %0 = phi i1 [ false, %entry ], [ %.loc22_55.2, %and.rhs.loc22 ]
-// CHECK:STDOUT:   %.loc22_69.1 = xor i1 %0, true
-// CHECK:STDOUT:   br i1 %.loc22_69.1, label %or.rhs, label %or.result
+// CHECK:STDOUT:   %.loc22_69.1 = xor i1 %0, true, !dbg !14
+// CHECK:STDOUT:   br i1 %.loc22_69.1, label %or.rhs, label %or.result, !dbg !14
 // CHECK:STDOUT:
 // CHECK:STDOUT: or.rhs:                                           ; preds = %and.result.loc22
-// CHECK:STDOUT:   %.loc23_38.1.is_positive = getelementptr inbounds nuw { i1 }, ptr %self, i32 0, i32 0
-// CHECK:STDOUT:   %.loc23_38.2 = load i1, ptr %.loc23_38.1.is_positive, align 1
-// CHECK:STDOUT:   %.loc23_30 = xor i1 %.loc23_38.2, true
-// CHECK:STDOUT:   br i1 %.loc23_30, label %and.rhs.loc23, label %and.result.loc23
+// CHECK:STDOUT:   %.loc23_38.1.is_positive = getelementptr inbounds nuw { i1 }, ptr %self, i32 0, i32 0, !dbg !15
+// CHECK:STDOUT:   %.loc23_38.2 = load i1, ptr %.loc23_38.1.is_positive, align 1, !dbg !15
+// CHECK:STDOUT:   %.loc23_30 = xor i1 %.loc23_38.2, true, !dbg !16
+// CHECK:STDOUT:   br i1 %.loc23_30, label %and.rhs.loc23, label %and.result.loc23, !dbg !16
 // CHECK:STDOUT:
 // CHECK:STDOUT: and.rhs.loc23:                                    ; preds = %or.rhs
-// CHECK:STDOUT:   %.loc23_64.1.is_positive = getelementptr inbounds nuw { i1 }, ptr %other, i32 0, i32 0
-// CHECK:STDOUT:   %.loc23_64.2 = load i1, ptr %.loc23_64.1.is_positive, align 1
-// CHECK:STDOUT:   %.loc23_55 = xor i1 %.loc23_64.2, true
-// CHECK:STDOUT:   br label %and.result.loc23
+// CHECK:STDOUT:   %.loc23_64.1.is_positive = getelementptr inbounds nuw { i1 }, ptr %other, i32 0, i32 0, !dbg !17
+// CHECK:STDOUT:   %.loc23_64.2 = load i1, ptr %.loc23_64.1.is_positive, align 1, !dbg !17
+// CHECK:STDOUT:   %.loc23_55 = xor i1 %.loc23_64.2, true, !dbg !18
+// CHECK:STDOUT:   br label %and.result.loc23, !dbg !16
 // CHECK:STDOUT:
 // CHECK:STDOUT: and.result.loc23:                                 ; preds = %and.rhs.loc23, %or.rhs
 // CHECK:STDOUT:   %1 = phi i1 [ false, %or.rhs ], [ %.loc23_55, %and.rhs.loc23 ]
-// CHECK:STDOUT:   br label %or.result
+// CHECK:STDOUT:   br label %or.result, !dbg !14
 // CHECK:STDOUT:
 // CHECK:STDOUT: or.result:                                        ; preds = %and.result.loc23, %and.result.loc22
 // CHECK:STDOUT:   %2 = phi i1 [ true, %and.result.loc22 ], [ %1, %and.result.loc23 ]
-// CHECK:STDOUT:   %.loc23_77.2.is_positive = getelementptr inbounds nuw { i1 }, ptr %return, i32 0, i32 0
-// CHECK:STDOUT:   store i1 %2, ptr %.loc23_77.2.is_positive, align 1
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %.loc23_77.2.is_positive = getelementptr inbounds nuw { i1 }, ptr %return, i32 0, i32 0, !dbg !19
+// CHECK:STDOUT:   store i1 %2, ptr %.loc23_77.2.is_positive, align 1, !dbg !19
+// CHECK:STDOUT:   ret void, !dbg !20
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Calculate(ptr sret({ i1 }) %return, ptr %a, ptr %b) !dbg !8 {
+// CHECK:STDOUT: define void @Calculate(ptr sret({ i1 }) %return, ptr %a, ptr %b) !dbg !21 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc28_10.2.temp = alloca { i1 }, align 8
-// CHECK:STDOUT:   call void @Op(ptr %.loc28_10.2.temp, ptr %a)
-// CHECK:STDOUT:   call void @Op.1(ptr %return, ptr %.loc28_10.2.temp, ptr %b)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %.loc28_10.2.temp = alloca { i1 }, align 8, !dbg !22
+// CHECK:STDOUT:   call void @Op(ptr %.loc28_10.2.temp, ptr %a), !dbg !22
+// CHECK:STDOUT:   call void @Op.1(ptr %return, ptr %.loc28_10.2.temp, ptr %b), !dbg !22
+// CHECK:STDOUT:   ret void, !dbg !23
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; uselistorder directives
@@ -101,5 +101,20 @@ fn Calculate(a: Number, b: Number) -> Number {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Op", scope: null, file: !3, line: 16, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Op.1", scope: null, file: !3, line: 21, type: !5, spFlags: DISPFlagDefinition, unit: !2)
-// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Calculate", scope: null, file: !3, line: 27, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 17, column: 32, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 17, column: 28, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 17, column: 12, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 17, column: 5, scope: !4)
+// CHECK:STDOUT: !11 = distinct !DISubprogram(name: "Op.1", scope: null, file: !3, line: 21, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !12 = !DILocation(line: 22, column: 29, scope: !11)
+// CHECK:STDOUT: !13 = !DILocation(line: 22, column: 50, scope: !11)
+// CHECK:STDOUT: !14 = !DILocation(line: 22, column: 28, scope: !11)
+// CHECK:STDOUT: !15 = !DILocation(line: 23, column: 34, scope: !11)
+// CHECK:STDOUT: !16 = !DILocation(line: 23, column: 30, scope: !11)
+// CHECK:STDOUT: !17 = !DILocation(line: 23, column: 59, scope: !11)
+// CHECK:STDOUT: !18 = !DILocation(line: 23, column: 55, scope: !11)
+// CHECK:STDOUT: !19 = !DILocation(line: 22, column: 12, scope: !11)
+// CHECK:STDOUT: !20 = !DILocation(line: 22, column: 5, scope: !11)
+// CHECK:STDOUT: !21 = distinct !DISubprogram(name: "Calculate", scope: null, file: !3, line: 27, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !22 = !DILocation(line: 28, column: 10, scope: !21)
+// CHECK:STDOUT: !23 = !DILocation(line: 28, column: 3, scope: !21)

+ 6 - 3
toolchain/lower/testdata/packages/cross_package_call.carbon

@@ -25,7 +25,7 @@ fn G() { A.F(); }
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -38,13 +38,14 @@ fn G() { A.F(); }
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 4, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 4, column: 1, scope: !4)
 // CHECK:STDOUT: ; ModuleID = 'b.carbon'
 // CHECK:STDOUT: source_filename = "b.carbon"
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @G() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   call void @F()
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   call void @F(), !dbg !7
+// CHECK:STDOUT:   ret void, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: declare void @F()
@@ -59,3 +60,5 @@ fn G() { A.F(); }
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 4, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 4, column: 10, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 4, column: 1, scope: !4)

+ 13 - 7
toolchain/lower/testdata/pointer/address_of_field.carbon

@@ -24,13 +24,13 @@ fn F() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %s.var = alloca { i32, i32 }, align 8
-// CHECK:STDOUT:   %.loc14_46.2.a = getelementptr inbounds nuw { i32, i32 }, ptr %s.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc14_46.4.b = getelementptr inbounds nuw { i32, i32 }, ptr %s.var, i32 0, i32 1
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %s.var, ptr align 4 @struct.loc14_47, i64 8, i1 false)
-// CHECK:STDOUT:   %.loc15_7.b = getelementptr inbounds nuw { i32, i32 }, ptr %s.var, i32 0, i32 1
-// CHECK:STDOUT:   call void @G(ptr %.loc15_7.b)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %s.var = alloca { i32, i32 }, align 8, !dbg !7
+// CHECK:STDOUT:   %.loc14_46.2.a = getelementptr inbounds nuw { i32, i32 }, ptr %s.var, i32 0, i32 0, !dbg !8
+// CHECK:STDOUT:   %.loc14_46.4.b = getelementptr inbounds nuw { i32, i32 }, ptr %s.var, i32 0, i32 1, !dbg !8
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %s.var, ptr align 4 @struct.loc14_47, i64 8, i1 false), !dbg !9
+// CHECK:STDOUT:   %.loc15_7.b = getelementptr inbounds nuw { i32, i32 }, ptr %s.var, i32 0, i32 1, !dbg !10
+// CHECK:STDOUT:   call void @G(ptr %.loc15_7.b), !dbg !11
+// CHECK:STDOUT:   ret void, !dbg !12
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -48,3 +48,9 @@ fn F() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 31, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 6, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 3, scope: !4)
+// CHECK:STDOUT: !12 = !DILocation(line: 13, column: 1, scope: !4)

+ 6 - 3
toolchain/lower/testdata/pointer/address_of_unused.carbon

@@ -18,9 +18,9 @@ fn F() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %n.var = alloca i32, align 4
-// CHECK:STDOUT:   store i32 0, ptr %n.var, align 4
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %n.var = alloca i32, align 4, !dbg !7
+// CHECK:STDOUT:   store i32 0, ptr %n.var, align 4, !dbg !8
+// CHECK:STDOUT:   ret void, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -33,3 +33,6 @@ fn F() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 11, column: 1, scope: !4)

+ 14 - 8
toolchain/lower/testdata/pointer/basic.carbon

@@ -22,16 +22,16 @@ fn F() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @G(ptr %p) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc12_10.2 = load i32, ptr %p, align 4
-// CHECK:STDOUT:   ret i32 %.loc12_10.2
+// CHECK:STDOUT:   %.loc12_10.2 = load i32, ptr %p, align 4, !dbg !7
+// CHECK:STDOUT:   ret i32 %.loc12_10.2, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define i32 @F() !dbg !7 {
+// CHECK:STDOUT: define i32 @F() !dbg !9 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %n.var = alloca i32, align 4
-// CHECK:STDOUT:   store i32 0, ptr %n.var, align 4
-// CHECK:STDOUT:   %G.call = call i32 @G(ptr %n.var)
-// CHECK:STDOUT:   ret i32 %G.call
+// CHECK:STDOUT:   %n.var = alloca i32, align 4, !dbg !10
+// CHECK:STDOUT:   store i32 0, ptr %n.var, align 4, !dbg !11
+// CHECK:STDOUT:   %G.call = call i32 @G(ptr %n.var), !dbg !12
+// CHECK:STDOUT:   ret i32 %G.call, !dbg !13
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -44,4 +44,10 @@ fn F() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 10, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !10 = !DILocation(line: 16, column: 7, scope: !9)
+// CHECK:STDOUT: !11 = !DILocation(line: 16, column: 3, scope: !9)
+// CHECK:STDOUT: !12 = !DILocation(line: 17, column: 10, scope: !9)
+// CHECK:STDOUT: !13 = !DILocation(line: 17, column: 3, scope: !9)

+ 22 - 11
toolchain/lower/testdata/pointer/pointer_to_pointer.carbon

@@ -20,17 +20,17 @@ fn F(p: i32**) -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @F(ptr %p) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %a.var = alloca ptr, align 8
-// CHECK:STDOUT:   store ptr %p, ptr %a.var, align 8
-// CHECK:STDOUT:   %b.var = alloca ptr, align 8
-// CHECK:STDOUT:   %.loc13_17.2 = load ptr, ptr %p, align 8
-// CHECK:STDOUT:   store ptr %.loc13_17.2, ptr %b.var, align 8
-// CHECK:STDOUT:   %c.var = alloca ptr, align 8
-// CHECK:STDOUT:   store ptr %b.var, ptr %c.var, align 8
-// CHECK:STDOUT:   %.loc15_12 = load ptr, ptr %c.var, align 8
-// CHECK:STDOUT:   %.loc15_11.2 = load ptr, ptr %.loc15_12, align 8
-// CHECK:STDOUT:   %.loc15_10.2 = load i32, ptr %.loc15_11.2, align 4
-// CHECK:STDOUT:   ret i32 %.loc15_10.2
+// CHECK:STDOUT:   %a.var = alloca ptr, align 8, !dbg !7
+// CHECK:STDOUT:   store ptr %p, ptr %a.var, align 8, !dbg !8
+// CHECK:STDOUT:   %b.var = alloca ptr, align 8, !dbg !9
+// CHECK:STDOUT:   %.loc13_17.2 = load ptr, ptr %p, align 8, !dbg !10
+// CHECK:STDOUT:   store ptr %.loc13_17.2, ptr %b.var, align 8, !dbg !11
+// CHECK:STDOUT:   %c.var = alloca ptr, align 8, !dbg !12
+// CHECK:STDOUT:   store ptr %b.var, ptr %c.var, align 8, !dbg !13
+// CHECK:STDOUT:   %.loc15_12 = load ptr, ptr %c.var, align 8, !dbg !14
+// CHECK:STDOUT:   %.loc15_11.2 = load ptr, ptr %.loc15_12, align 8, !dbg !15
+// CHECK:STDOUT:   %.loc15_10.2 = load i32, ptr %.loc15_11.2, align 4, !dbg !16
+// CHECK:STDOUT:   ret i32 %.loc15_10.2, !dbg !17
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -43,3 +43,14 @@ fn F(p: i32**) -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 7, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 17, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 3, scope: !4)
+// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 7, scope: !4)
+// CHECK:STDOUT: !13 = !DILocation(line: 14, column: 3, scope: !4)
+// CHECK:STDOUT: !14 = !DILocation(line: 15, column: 12, scope: !4)
+// CHECK:STDOUT: !15 = !DILocation(line: 15, column: 11, scope: !4)
+// CHECK:STDOUT: !16 = !DILocation(line: 15, column: 10, scope: !4)
+// CHECK:STDOUT: !17 = !DILocation(line: 15, column: 3, scope: !4)

+ 6 - 4
toolchain/lower/testdata/return/code_after_return.carbon

@@ -20,12 +20,12 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @Main() !dbg !7 {
+// CHECK:STDOUT: define void @Main() !dbg !8 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -38,4 +38,6 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4)
+// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !8)

+ 2 - 1
toolchain/lower/testdata/return/no_value.carbon

@@ -17,7 +17,7 @@ fn Main() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   ret void, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -30,3 +30,4 @@ fn Main() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4)

+ 6 - 4
toolchain/lower/testdata/return/return_var.carbon

@@ -24,10 +24,10 @@ fn Make() -> C {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Make(ptr sret({ i32, ptr }) %return) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc18_30.2.data = getelementptr inbounds nuw { i32, ptr }, ptr %return, i32 0, i32 0
-// CHECK:STDOUT:   %.loc18_30.4.next = getelementptr inbounds nuw { i32, ptr }, ptr %return, i32 0, i32 1
-// CHECK:STDOUT:   store ptr %return, ptr %.loc18_30.4.next, align 8
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %.loc18_30.2.data = getelementptr inbounds nuw { i32, ptr }, ptr %return, i32 0, i32 0, !dbg !7
+// CHECK:STDOUT:   %.loc18_30.4.next = getelementptr inbounds nuw { i32, ptr }, ptr %return, i32 0, i32 1, !dbg !7
+// CHECK:STDOUT:   store ptr %return, ptr %.loc18_30.4.next, align 8, !dbg !7
+// CHECK:STDOUT:   ret void, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -40,3 +40,5 @@ fn Make() -> C {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Make", scope: null, file: !3, line: 16, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 18, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 19, column: 3, scope: !4)

+ 7 - 4
toolchain/lower/testdata/return/return_var_byval.carbon

@@ -18,10 +18,10 @@ fn Main() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @Main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %x.var = alloca i32, align 4
-// CHECK:STDOUT:   store i32 0, ptr %x.var, align 4
-// CHECK:STDOUT:   %.loc12_16 = load i32, ptr %x.var, align 4
-// CHECK:STDOUT:   ret i32 %.loc12_16
+// CHECK:STDOUT:   %x.var = alloca i32, align 4, !dbg !7
+// CHECK:STDOUT:   store i32 0, ptr %x.var, align 4, !dbg !8
+// CHECK:STDOUT:   %.loc12_16 = load i32, ptr %x.var, align 4, !dbg !7
+// CHECK:STDOUT:   ret i32 %.loc12_16, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -34,3 +34,6 @@ fn Main() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 16, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 3, scope: !4)

+ 2 - 1
toolchain/lower/testdata/return/value.carbon

@@ -17,7 +17,7 @@ fn Main() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @Main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i32 0
+// CHECK:STDOUT:   ret i32 0, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -30,3 +30,4 @@ fn Main() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4)

+ 8 - 4
toolchain/lower/testdata/return/var.carbon

@@ -18,10 +18,10 @@ fn Main() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @Main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %x.var = alloca i32, align 4
-// CHECK:STDOUT:   store i32 0, ptr %x.var, align 4
-// CHECK:STDOUT:   %.loc13 = load i32, ptr %x.var, align 4
-// CHECK:STDOUT:   ret i32 %.loc13
+// CHECK:STDOUT:   %x.var = alloca i32, align 4, !dbg !7
+// CHECK:STDOUT:   store i32 0, ptr %x.var, align 4, !dbg !8
+// CHECK:STDOUT:   %.loc13 = load i32, ptr %x.var, align 4, !dbg !9
+// CHECK:STDOUT:   ret i32 %.loc13, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -34,3 +34,7 @@ fn Main() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 10, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 3, scope: !4)

+ 6 - 3
toolchain/lower/testdata/struct/empty.carbon

@@ -19,9 +19,9 @@ fn Run() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %x.var = alloca {}, align 8
-// CHECK:STDOUT:   %y.var = alloca {}, align 8
-// CHECK:STDOUT:   ret i32 0
+// CHECK:STDOUT:   %x.var = alloca {}, align 8, !dbg !7
+// CHECK:STDOUT:   %y.var = alloca {}, align 8, !dbg !8
+// CHECK:STDOUT:   ret i32 0, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -34,3 +34,6 @@ fn Run() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 13, column: 7, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !4)

+ 22 - 12
toolchain/lower/testdata/struct/member_access.carbon

@@ -22,18 +22,18 @@ fn Run() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %x.var = alloca { double, i32 }, align 8
-// CHECK:STDOUT:   %.loc12_48.2.a = getelementptr inbounds nuw { double, i32 }, ptr %x.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc12_48.4.b = getelementptr inbounds nuw { double, i32 }, ptr %x.var, i32 0, i32 1
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 8 %x.var, ptr align 8 @struct.loc12_49, i64 16, i1 false)
-// CHECK:STDOUT:   %y.var = alloca i32, align 4
-// CHECK:STDOUT:   %.loc13_17.1.b = getelementptr inbounds nuw { double, i32 }, ptr %x.var, i32 0, i32 1
-// CHECK:STDOUT:   %.loc13_17.2 = load i32, ptr %.loc13_17.1.b, align 4
-// CHECK:STDOUT:   store i32 %.loc13_17.2, ptr %y.var, align 4
-// CHECK:STDOUT:   %z.var = alloca i32, align 4
-// CHECK:STDOUT:   %.loc14_16 = load i32, ptr %y.var, align 4
-// CHECK:STDOUT:   store i32 %.loc14_16, ptr %z.var, align 4
-// CHECK:STDOUT:   ret i32 0
+// CHECK:STDOUT:   %x.var = alloca { double, i32 }, align 8, !dbg !7
+// CHECK:STDOUT:   %.loc12_48.2.a = getelementptr inbounds nuw { double, i32 }, ptr %x.var, i32 0, i32 0, !dbg !8
+// CHECK:STDOUT:   %.loc12_48.4.b = getelementptr inbounds nuw { double, i32 }, ptr %x.var, i32 0, i32 1, !dbg !8
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 8 %x.var, ptr align 8 @struct.loc12_49, i64 16, i1 false), !dbg !9
+// CHECK:STDOUT:   %y.var = alloca i32, align 4, !dbg !10
+// CHECK:STDOUT:   %.loc13_17.1.b = getelementptr inbounds nuw { double, i32 }, ptr %x.var, i32 0, i32 1, !dbg !11
+// CHECK:STDOUT:   %.loc13_17.2 = load i32, ptr %.loc13_17.1.b, align 4, !dbg !11
+// CHECK:STDOUT:   store i32 %.loc13_17.2, ptr %y.var, align 4, !dbg !12
+// CHECK:STDOUT:   %z.var = alloca i32, align 4, !dbg !13
+// CHECK:STDOUT:   %.loc14_16 = load i32, ptr %y.var, align 4, !dbg !14
+// CHECK:STDOUT:   store i32 %.loc14_16, ptr %z.var, align 4, !dbg !15
+// CHECK:STDOUT:   ret i32 0, !dbg !16
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -51,3 +51,13 @@ fn Run() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 31, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 7, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 16, scope: !4)
+// CHECK:STDOUT: !12 = !DILocation(line: 13, column: 3, scope: !4)
+// CHECK:STDOUT: !13 = !DILocation(line: 14, column: 7, scope: !4)
+// CHECK:STDOUT: !14 = !DILocation(line: 14, column: 16, scope: !4)
+// CHECK:STDOUT: !15 = !DILocation(line: 14, column: 3, scope: !4)
+// CHECK:STDOUT: !16 = !DILocation(line: 15, column: 3, scope: !4)

+ 2 - 1
toolchain/lower/testdata/struct/nested_struct.carbon

@@ -18,7 +18,7 @@ fn Run() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i32 0
+// CHECK:STDOUT:   ret i32 0, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -31,3 +31,4 @@ fn Run() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 13, column: 3, scope: !4)

+ 11 - 6
toolchain/lower/testdata/struct/nested_struct_in_place.carbon

@@ -21,12 +21,12 @@ fn G() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @G() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %v.var = alloca { { i32, i32, i32 }, { i32, i32, i32 } }, align 8
-// CHECK:STDOUT:   %.loc14_74.1.a = getelementptr inbounds nuw { { i32, i32, i32 }, { i32, i32, i32 } }, ptr %v.var, i32 0, i32 0
-// CHECK:STDOUT:   call void @F(ptr %.loc14_74.1.a)
-// CHECK:STDOUT:   %.loc14_74.2.b = getelementptr inbounds nuw { { i32, i32, i32 }, { i32, i32, i32 } }, ptr %v.var, i32 0, i32 1
-// CHECK:STDOUT:   call void @F(ptr %.loc14_74.2.b)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %v.var = alloca { { i32, i32, i32 }, { i32, i32, i32 } }, align 8, !dbg !7
+// CHECK:STDOUT:   %.loc14_74.1.a = getelementptr inbounds nuw { { i32, i32, i32 }, { i32, i32, i32 } }, ptr %v.var, i32 0, i32 0, !dbg !8
+// CHECK:STDOUT:   call void @F(ptr %.loc14_74.1.a), !dbg !9
+// CHECK:STDOUT:   %.loc14_74.2.b = getelementptr inbounds nuw { { i32, i32, i32 }, { i32, i32, i32 } }, ptr %v.var, i32 0, i32 1, !dbg !8
+// CHECK:STDOUT:   call void @F(ptr %.loc14_74.2.b), !dbg !10
+// CHECK:STDOUT:   ret void, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -39,3 +39,8 @@ fn G() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 55, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 61, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 71, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 1, scope: !4)

+ 14 - 8
toolchain/lower/testdata/struct/one_entry.carbon

@@ -19,14 +19,14 @@ fn Run() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %x.var = alloca { i32 }, align 8
-// CHECK:STDOUT:   store { i32 } { i32 4 }, ptr %x.var, align 4
-// CHECK:STDOUT:   %y.var = alloca { i32 }, align 8
-// CHECK:STDOUT:   %.loc13_22.1.a = getelementptr inbounds nuw { i32 }, ptr %x.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc13_22.2 = load i32, ptr %.loc13_22.1.a, align 4
-// CHECK:STDOUT:   %.loc13_22.3.struct.init = insertvalue { i32 } poison, i32 %.loc13_22.2, 0
-// CHECK:STDOUT:   store { i32 } %.loc13_22.3.struct.init, ptr %y.var, align 4
-// CHECK:STDOUT:   ret i32 0
+// CHECK:STDOUT:   %x.var = alloca { i32 }, align 8, !dbg !7
+// CHECK:STDOUT:   store { i32 } { i32 4 }, ptr %x.var, align 4, !dbg !8
+// CHECK:STDOUT:   %y.var = alloca { i32 }, align 8, !dbg !9
+// CHECK:STDOUT:   %.loc13_22.1.a = getelementptr inbounds nuw { i32 }, ptr %x.var, i32 0, i32 0, !dbg !10
+// CHECK:STDOUT:   %.loc13_22.2 = load i32, ptr %.loc13_22.1.a, align 4, !dbg !10
+// CHECK:STDOUT:   %.loc13_22.3.struct.init = insertvalue { i32 } poison, i32 %.loc13_22.2, 0, !dbg !10
+// CHECK:STDOUT:   store { i32 } %.loc13_22.3.struct.init, ptr %y.var, align 4, !dbg !11
+// CHECK:STDOUT:   ret i32 0, !dbg !12
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -39,3 +39,9 @@ fn Run() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 7, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 22, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 3, scope: !4)
+// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 3, scope: !4)

+ 20 - 14
toolchain/lower/testdata/struct/two_entries.carbon

@@ -21,20 +21,20 @@ fn Run() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %x.var = alloca { i32, i32 }, align 8
-// CHECK:STDOUT:   %.loc12_46.2.a = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc12_46.4.b = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 1
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %x.var, ptr align 4 @struct.loc12_47, i64 8, i1 false)
-// CHECK:STDOUT:   %y.var = alloca { i32, i32 }, align 8
-// CHECK:STDOUT:   %.loc13_31.1.a = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc13_31.2 = load i32, ptr %.loc13_31.1.a, align 4
-// CHECK:STDOUT:   %.loc13_31.3.a = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 0
-// CHECK:STDOUT:   store i32 %.loc13_31.2, ptr %.loc13_31.3.a, align 4
-// CHECK:STDOUT:   %.loc13_31.5.b = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 1
-// CHECK:STDOUT:   %.loc13_31.6 = load i32, ptr %.loc13_31.5.b, align 4
-// CHECK:STDOUT:   %.loc13_31.7.b = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 1
-// CHECK:STDOUT:   store i32 %.loc13_31.6, ptr %.loc13_31.7.b, align 4
-// CHECK:STDOUT:   ret i32 0
+// CHECK:STDOUT:   %x.var = alloca { i32, i32 }, align 8, !dbg !7
+// CHECK:STDOUT:   %.loc12_46.2.a = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 0, !dbg !8
+// CHECK:STDOUT:   %.loc12_46.4.b = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 1, !dbg !8
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %x.var, ptr align 4 @struct.loc12_47, i64 8, i1 false), !dbg !9
+// CHECK:STDOUT:   %y.var = alloca { i32, i32 }, align 8, !dbg !10
+// CHECK:STDOUT:   %.loc13_31.1.a = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 0, !dbg !11
+// CHECK:STDOUT:   %.loc13_31.2 = load i32, ptr %.loc13_31.1.a, align 4, !dbg !11
+// CHECK:STDOUT:   %.loc13_31.3.a = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 0, !dbg !11
+// CHECK:STDOUT:   store i32 %.loc13_31.2, ptr %.loc13_31.3.a, align 4, !dbg !11
+// CHECK:STDOUT:   %.loc13_31.5.b = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 1, !dbg !11
+// CHECK:STDOUT:   %.loc13_31.6 = load i32, ptr %.loc13_31.5.b, align 4, !dbg !11
+// CHECK:STDOUT:   %.loc13_31.7.b = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 1, !dbg !11
+// CHECK:STDOUT:   store i32 %.loc13_31.6, ptr %.loc13_31.7.b, align 4, !dbg !11
+// CHECK:STDOUT:   ret i32 0, !dbg !12
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -52,3 +52,9 @@ fn Run() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 31, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 7, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 31, scope: !4)
+// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 3, scope: !4)

+ 24 - 14
toolchain/lower/testdata/tuple/access/element_access.carbon

@@ -22,20 +22,20 @@ fn Run() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %a.var = alloca { i32, i32, i32 }, align 8
-// CHECK:STDOUT:   %.loc12_36.2.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc12_36.4.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 1
-// CHECK:STDOUT:   %.loc12_36.6.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a.var, ptr align 4 @tuple.loc12_37, i64 12, i1 false)
-// CHECK:STDOUT:   %b.var = alloca i32, align 4
-// CHECK:STDOUT:   %.loc13_17.1.tuple.index = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc13_17.2 = load i32, ptr %.loc13_17.1.tuple.index, align 4
-// CHECK:STDOUT:   store i32 %.loc13_17.2, ptr %b.var, align 4
-// CHECK:STDOUT:   %c.var = alloca i32, align 4
-// CHECK:STDOUT:   %.loc14_17.1.tuple.index = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2
-// CHECK:STDOUT:   %.loc14_17.2 = load i32, ptr %.loc14_17.1.tuple.index, align 4
-// CHECK:STDOUT:   store i32 %.loc14_17.2, ptr %c.var, align 4
-// CHECK:STDOUT:   ret i32 0
+// CHECK:STDOUT:   %a.var = alloca { i32, i32, i32 }, align 8, !dbg !7
+// CHECK:STDOUT:   %.loc12_36.2.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0, !dbg !8
+// CHECK:STDOUT:   %.loc12_36.4.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 1, !dbg !8
+// CHECK:STDOUT:   %.loc12_36.6.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2, !dbg !8
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a.var, ptr align 4 @tuple.loc12_37, i64 12, i1 false), !dbg !9
+// CHECK:STDOUT:   %b.var = alloca i32, align 4, !dbg !10
+// CHECK:STDOUT:   %.loc13_17.1.tuple.index = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0, !dbg !11
+// CHECK:STDOUT:   %.loc13_17.2 = load i32, ptr %.loc13_17.1.tuple.index, align 4, !dbg !11
+// CHECK:STDOUT:   store i32 %.loc13_17.2, ptr %b.var, align 4, !dbg !12
+// CHECK:STDOUT:   %c.var = alloca i32, align 4, !dbg !13
+// CHECK:STDOUT:   %.loc14_17.1.tuple.index = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2, !dbg !14
+// CHECK:STDOUT:   %.loc14_17.2 = load i32, ptr %.loc14_17.1.tuple.index, align 4, !dbg !14
+// CHECK:STDOUT:   store i32 %.loc14_17.2, ptr %c.var, align 4, !dbg !15
+// CHECK:STDOUT:   ret i32 0, !dbg !16
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -53,3 +53,13 @@ fn Run() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 28, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 7, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 16, scope: !4)
+// CHECK:STDOUT: !12 = !DILocation(line: 13, column: 3, scope: !4)
+// CHECK:STDOUT: !13 = !DILocation(line: 14, column: 7, scope: !4)
+// CHECK:STDOUT: !14 = !DILocation(line: 14, column: 16, scope: !4)
+// CHECK:STDOUT: !15 = !DILocation(line: 14, column: 3, scope: !4)
+// CHECK:STDOUT: !16 = !DILocation(line: 15, column: 3, scope: !4)

+ 19 - 13
toolchain/lower/testdata/tuple/access/return_value_access.carbon

@@ -21,21 +21,21 @@ fn Run() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F(ptr sret({ i32, i32 }) %return) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc11_38.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 0
-// CHECK:STDOUT:   %.loc11_38.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 1
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %return, ptr align 4 @tuple.loc11_39, i64 8, i1 false)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %.loc11_38.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 0, !dbg !7
+// CHECK:STDOUT:   %.loc11_38.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %return, i32 0, i32 1, !dbg !7
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %return, ptr align 4 @tuple.loc11_39, i64 8, i1 false), !dbg !8
+// CHECK:STDOUT:   ret void, !dbg !8
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: define void @main() !dbg !7 {
+// CHECK:STDOUT: define void @main() !dbg !9 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %t.var = alloca i32, align 4
-// CHECK:STDOUT:   %.loc14_17.1.temp = alloca { i32, i32 }, align 8
-// CHECK:STDOUT:   call void @F(ptr %.loc14_17.1.temp)
-// CHECK:STDOUT:   %.loc14_19.1.tuple.index = getelementptr inbounds nuw { i32, i32 }, ptr %.loc14_17.1.temp, i32 0, i32 1
-// CHECK:STDOUT:   %.loc14_19.2 = load i32, ptr %.loc14_19.1.tuple.index, align 4
-// CHECK:STDOUT:   store i32 %.loc14_19.2, ptr %t.var, align 4
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %t.var = alloca i32, align 4, !dbg !10
+// CHECK:STDOUT:   %.loc14_17.1.temp = alloca { i32, i32 }, align 8, !dbg !11
+// CHECK:STDOUT:   call void @F(ptr %.loc14_17.1.temp), !dbg !11
+// CHECK:STDOUT:   %.loc14_19.1.tuple.index = getelementptr inbounds nuw { i32, i32 }, ptr %.loc14_17.1.temp, i32 0, i32 1, !dbg !11
+// CHECK:STDOUT:   %.loc14_19.2 = load i32, ptr %.loc14_19.1.tuple.index, align 4, !dbg !11
+// CHECK:STDOUT:   store i32 %.loc14_19.2, ptr %t.var, align 4, !dbg !12
+// CHECK:STDOUT:   ret void, !dbg !13
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -53,4 +53,10 @@ fn Run() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
-// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 31, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 11, column: 24, scope: !4)
+// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
+// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 7, scope: !9)
+// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 16, scope: !9)
+// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 3, scope: !9)
+// CHECK:STDOUT: !13 = !DILocation(line: 13, column: 1, scope: !9)

+ 6 - 3
toolchain/lower/testdata/tuple/empty.carbon

@@ -19,9 +19,9 @@ fn Run() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %x.var = alloca {}, align 8
-// CHECK:STDOUT:   %y.var = alloca {}, align 8
-// CHECK:STDOUT:   ret i32 0
+// CHECK:STDOUT:   %x.var = alloca {}, align 8, !dbg !7
+// CHECK:STDOUT:   %y.var = alloca {}, align 8, !dbg !8
+// CHECK:STDOUT:   ret i32 0, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -34,3 +34,6 @@ fn Run() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 13, column: 7, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !4)

+ 2 - 1
toolchain/lower/testdata/tuple/nested_tuple.carbon

@@ -18,7 +18,7 @@ fn Run() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   ret i32 0
+// CHECK:STDOUT:   ret i32 0, !dbg !7
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -31,3 +31,4 @@ fn Run() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 13, column: 3, scope: !4)

+ 11 - 6
toolchain/lower/testdata/tuple/nested_tuple_in_place.carbon

@@ -21,12 +21,12 @@ fn G() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @G() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %v.var = alloca { { i32, i32, i32 }, { i32, i32, i32 } }, align 8
-// CHECK:STDOUT:   %.loc14_56.1.tuple.elem = getelementptr inbounds nuw { { i32, i32, i32 }, { i32, i32, i32 } }, ptr %v.var, i32 0, i32 0
-// CHECK:STDOUT:   call void @F(ptr %.loc14_56.1.tuple.elem)
-// CHECK:STDOUT:   %.loc14_56.2.tuple.elem = getelementptr inbounds nuw { { i32, i32, i32 }, { i32, i32, i32 } }, ptr %v.var, i32 0, i32 1
-// CHECK:STDOUT:   call void @F(ptr %.loc14_56.2.tuple.elem)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %v.var = alloca { { i32, i32, i32 }, { i32, i32, i32 } }, align 8, !dbg !7
+// CHECK:STDOUT:   %.loc14_56.1.tuple.elem = getelementptr inbounds nuw { { i32, i32, i32 }, { i32, i32, i32 } }, ptr %v.var, i32 0, i32 0, !dbg !8
+// CHECK:STDOUT:   call void @F(ptr %.loc14_56.1.tuple.elem), !dbg !9
+// CHECK:STDOUT:   %.loc14_56.2.tuple.elem = getelementptr inbounds nuw { { i32, i32, i32 }, { i32, i32, i32 } }, ptr %v.var, i32 0, i32 1, !dbg !8
+// CHECK:STDOUT:   call void @F(ptr %.loc14_56.2.tuple.elem), !dbg !10
+// CHECK:STDOUT:   ret void, !dbg !11
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -39,3 +39,8 @@ fn G() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 47, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 48, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 53, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 1, scope: !4)

+ 14 - 8
toolchain/lower/testdata/tuple/one_entry.carbon

@@ -19,14 +19,14 @@ fn Run() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %x.var = alloca { i32 }, align 8
-// CHECK:STDOUT:   store { i32 } { i32 1 }, ptr %x.var, align 4
-// CHECK:STDOUT:   %y.var = alloca { i32 }, align 8
-// CHECK:STDOUT:   %.loc13_20.1.tuple.elem = getelementptr inbounds nuw { i32 }, ptr %x.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc13_20.2 = load i32, ptr %.loc13_20.1.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc13_20.3.tuple.init = insertvalue { i32 } poison, i32 %.loc13_20.2, 0
-// CHECK:STDOUT:   store { i32 } %.loc13_20.3.tuple.init, ptr %y.var, align 4
-// CHECK:STDOUT:   ret i32 0
+// CHECK:STDOUT:   %x.var = alloca { i32 }, align 8, !dbg !7
+// CHECK:STDOUT:   store { i32 } { i32 1 }, ptr %x.var, align 4, !dbg !8
+// CHECK:STDOUT:   %y.var = alloca { i32 }, align 8, !dbg !9
+// CHECK:STDOUT:   %.loc13_20.1.tuple.elem = getelementptr inbounds nuw { i32 }, ptr %x.var, i32 0, i32 0, !dbg !10
+// CHECK:STDOUT:   %.loc13_20.2 = load i32, ptr %.loc13_20.1.tuple.elem, align 4, !dbg !10
+// CHECK:STDOUT:   %.loc13_20.3.tuple.init = insertvalue { i32 } poison, i32 %.loc13_20.2, 0, !dbg !10
+// CHECK:STDOUT:   store { i32 } %.loc13_20.3.tuple.init, ptr %y.var, align 4, !dbg !11
+// CHECK:STDOUT:   ret i32 0, !dbg !12
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; uselistorder directives
@@ -42,3 +42,9 @@ fn Run() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 7, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 20, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 3, scope: !4)
+// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 3, scope: !4)

+ 20 - 14
toolchain/lower/testdata/tuple/two_entries.carbon

@@ -21,20 +21,20 @@ fn Run() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %x.var = alloca { i32, i32 }, align 8
-// CHECK:STDOUT:   %.loc12_29.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc12_29.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 1
-// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %x.var, ptr align 4 @tuple.loc12_30, i64 8, i1 false)
-// CHECK:STDOUT:   %y.var = alloca { i32, i32 }, align 8
-// CHECK:STDOUT:   %.loc13_23.1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc13_23.2 = load i32, ptr %.loc13_23.1.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc13_23.3.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 0
-// CHECK:STDOUT:   store i32 %.loc13_23.2, ptr %.loc13_23.3.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc13_23.5.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 1
-// CHECK:STDOUT:   %.loc13_23.6 = load i32, ptr %.loc13_23.5.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc13_23.7.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 1
-// CHECK:STDOUT:   store i32 %.loc13_23.6, ptr %.loc13_23.7.tuple.elem, align 4
-// CHECK:STDOUT:   ret i32 0
+// CHECK:STDOUT:   %x.var = alloca { i32, i32 }, align 8, !dbg !7
+// CHECK:STDOUT:   %.loc12_29.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 0, !dbg !8
+// CHECK:STDOUT:   %.loc12_29.4.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 1, !dbg !8
+// CHECK:STDOUT:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %x.var, ptr align 4 @tuple.loc12_30, i64 8, i1 false), !dbg !9
+// CHECK:STDOUT:   %y.var = alloca { i32, i32 }, align 8, !dbg !10
+// CHECK:STDOUT:   %.loc13_23.1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 0, !dbg !11
+// CHECK:STDOUT:   %.loc13_23.2 = load i32, ptr %.loc13_23.1.tuple.elem, align 4, !dbg !11
+// CHECK:STDOUT:   %.loc13_23.3.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 0, !dbg !11
+// CHECK:STDOUT:   store i32 %.loc13_23.2, ptr %.loc13_23.3.tuple.elem, align 4, !dbg !11
+// CHECK:STDOUT:   %.loc13_23.5.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 1, !dbg !11
+// CHECK:STDOUT:   %.loc13_23.6 = load i32, ptr %.loc13_23.5.tuple.elem, align 4, !dbg !11
+// CHECK:STDOUT:   %.loc13_23.7.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 1, !dbg !11
+// CHECK:STDOUT:   store i32 %.loc13_23.6, ptr %.loc13_23.7.tuple.elem, align 4, !dbg !11
+// CHECK:STDOUT:   ret i32 0, !dbg !12
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
@@ -52,3 +52,9 @@ fn Run() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 23, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 7, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 23, scope: !4)
+// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 3, scope: !4)

+ 42 - 35
toolchain/lower/testdata/tuple/value_formation.carbon

@@ -23,41 +23,41 @@ fn F() {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %a.var = alloca { i32, i32, i32 }, align 8
-// CHECK:STDOUT:   %b.var = alloca { i32, i32, i32 }, align 8
-// CHECK:STDOUT:   %.loc16_6.1.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc16_6.2 = load i32, ptr %.loc16_6.1.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc16_6.3.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 1
-// CHECK:STDOUT:   %.loc16_6.4 = load i32, ptr %.loc16_6.3.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc16_6.5.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2
-// CHECK:STDOUT:   %.loc16_6.6 = load i32, ptr %.loc16_6.5.tuple.elem, align 4
-// CHECK:STDOUT:   %tuple.loc16_6 = alloca { i32, i32, i32 }, align 8
-// CHECK:STDOUT:   %tuple.loc16_61 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc16_6, i32 0, i32 0
-// CHECK:STDOUT:   store i32 %.loc16_6.2, ptr %tuple.loc16_61, align 4
-// CHECK:STDOUT:   %tuple.loc16_62 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc16_6, i32 0, i32 1
-// CHECK:STDOUT:   store i32 %.loc16_6.4, ptr %tuple.loc16_62, align 4
-// CHECK:STDOUT:   %tuple.loc16_63 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc16_6, i32 0, i32 2
-// CHECK:STDOUT:   store i32 %.loc16_6.6, ptr %tuple.loc16_63, align 4
-// CHECK:STDOUT:   %.loc16_9.1.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %b.var, i32 0, i32 0
-// CHECK:STDOUT:   %.loc16_9.2 = load i32, ptr %.loc16_9.1.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc16_9.3.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %b.var, i32 0, i32 1
-// CHECK:STDOUT:   %.loc16_9.4 = load i32, ptr %.loc16_9.3.tuple.elem, align 4
-// CHECK:STDOUT:   %.loc16_9.5.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %b.var, i32 0, i32 2
-// CHECK:STDOUT:   %.loc16_9.6 = load i32, ptr %.loc16_9.5.tuple.elem, align 4
-// CHECK:STDOUT:   %tuple.loc16_9 = alloca { i32, i32, i32 }, align 8
-// CHECK:STDOUT:   %tuple.loc16_94 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc16_9, i32 0, i32 0
-// CHECK:STDOUT:   store i32 %.loc16_9.2, ptr %tuple.loc16_94, align 4
-// CHECK:STDOUT:   %tuple.loc16_95 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc16_9, i32 0, i32 1
-// CHECK:STDOUT:   store i32 %.loc16_9.4, ptr %tuple.loc16_95, align 4
-// CHECK:STDOUT:   %tuple.loc16_96 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc16_9, i32 0, i32 2
-// CHECK:STDOUT:   store i32 %.loc16_9.6, ptr %tuple.loc16_96, align 4
-// CHECK:STDOUT:   %tuple.loc16_10 = alloca { ptr, ptr }, align 8
-// CHECK:STDOUT:   %tuple.loc16_107 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc16_10, i32 0, i32 0
-// CHECK:STDOUT:   store ptr %tuple.loc16_6, ptr %tuple.loc16_107, align 8
-// CHECK:STDOUT:   %tuple.loc16_108 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc16_10, i32 0, i32 1
-// CHECK:STDOUT:   store ptr %tuple.loc16_9, ptr %tuple.loc16_108, align 8
-// CHECK:STDOUT:   call void @G(ptr %tuple.loc16_10)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %a.var = alloca { i32, i32, i32 }, align 8, !dbg !7
+// CHECK:STDOUT:   %b.var = alloca { i32, i32, i32 }, align 8, !dbg !8
+// CHECK:STDOUT:   %.loc16_6.1.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0, !dbg !9
+// CHECK:STDOUT:   %.loc16_6.2 = load i32, ptr %.loc16_6.1.tuple.elem, align 4, !dbg !9
+// CHECK:STDOUT:   %.loc16_6.3.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 1, !dbg !9
+// CHECK:STDOUT:   %.loc16_6.4 = load i32, ptr %.loc16_6.3.tuple.elem, align 4, !dbg !9
+// CHECK:STDOUT:   %.loc16_6.5.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2, !dbg !9
+// CHECK:STDOUT:   %.loc16_6.6 = load i32, ptr %.loc16_6.5.tuple.elem, align 4, !dbg !9
+// CHECK:STDOUT:   %tuple.loc16_6 = alloca { i32, i32, i32 }, align 8, !dbg !9
+// CHECK:STDOUT:   %tuple.loc16_61 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc16_6, i32 0, i32 0, !dbg !9
+// CHECK:STDOUT:   store i32 %.loc16_6.2, ptr %tuple.loc16_61, align 4, !dbg !9
+// CHECK:STDOUT:   %tuple.loc16_62 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc16_6, i32 0, i32 1, !dbg !9
+// CHECK:STDOUT:   store i32 %.loc16_6.4, ptr %tuple.loc16_62, align 4, !dbg !9
+// CHECK:STDOUT:   %tuple.loc16_63 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc16_6, i32 0, i32 2, !dbg !9
+// CHECK:STDOUT:   store i32 %.loc16_6.6, ptr %tuple.loc16_63, align 4, !dbg !9
+// CHECK:STDOUT:   %.loc16_9.1.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %b.var, i32 0, i32 0, !dbg !10
+// CHECK:STDOUT:   %.loc16_9.2 = load i32, ptr %.loc16_9.1.tuple.elem, align 4, !dbg !10
+// CHECK:STDOUT:   %.loc16_9.3.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %b.var, i32 0, i32 1, !dbg !10
+// CHECK:STDOUT:   %.loc16_9.4 = load i32, ptr %.loc16_9.3.tuple.elem, align 4, !dbg !10
+// CHECK:STDOUT:   %.loc16_9.5.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %b.var, i32 0, i32 2, !dbg !10
+// CHECK:STDOUT:   %.loc16_9.6 = load i32, ptr %.loc16_9.5.tuple.elem, align 4, !dbg !10
+// CHECK:STDOUT:   %tuple.loc16_9 = alloca { i32, i32, i32 }, align 8, !dbg !10
+// CHECK:STDOUT:   %tuple.loc16_94 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc16_9, i32 0, i32 0, !dbg !10
+// CHECK:STDOUT:   store i32 %.loc16_9.2, ptr %tuple.loc16_94, align 4, !dbg !10
+// CHECK:STDOUT:   %tuple.loc16_95 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc16_9, i32 0, i32 1, !dbg !10
+// CHECK:STDOUT:   store i32 %.loc16_9.4, ptr %tuple.loc16_95, align 4, !dbg !10
+// CHECK:STDOUT:   %tuple.loc16_96 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc16_9, i32 0, i32 2, !dbg !10
+// CHECK:STDOUT:   store i32 %.loc16_9.6, ptr %tuple.loc16_96, align 4, !dbg !10
+// CHECK:STDOUT:   %tuple.loc16_10 = alloca { ptr, ptr }, align 8, !dbg !11
+// CHECK:STDOUT:   %tuple.loc16_107 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc16_10, i32 0, i32 0, !dbg !11
+// CHECK:STDOUT:   store ptr %tuple.loc16_6, ptr %tuple.loc16_107, align 8, !dbg !11
+// CHECK:STDOUT:   %tuple.loc16_108 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc16_10, i32 0, i32 1, !dbg !11
+// CHECK:STDOUT:   store ptr %tuple.loc16_9, ptr %tuple.loc16_108, align 8, !dbg !11
+// CHECK:STDOUT:   call void @G(ptr %tuple.loc16_10), !dbg !12
+// CHECK:STDOUT:   ret void, !dbg !13
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -70,3 +70,10 @@ fn F() {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 15, column: 7, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 6, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 16, column: 9, scope: !4)
+// CHECK:STDOUT: !11 = !DILocation(line: 16, column: 5, scope: !4)
+// CHECK:STDOUT: !12 = !DILocation(line: 16, column: 3, scope: !4)
+// CHECK:STDOUT: !13 = !DILocation(line: 13, column: 1, scope: !4)

+ 10 - 7
toolchain/lower/testdata/tuple/value_forwarding.carbon

@@ -21,13 +21,13 @@ fn F(a: (i32, i32, i32), b: (i32, i32, i32)) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @F(ptr %a, ptr %b) !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %tuple = alloca { ptr, ptr }, align 8
-// CHECK:STDOUT:   %tuple1 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple, i32 0, i32 0
-// CHECK:STDOUT:   store ptr %a, ptr %tuple1, align 8
-// CHECK:STDOUT:   %tuple2 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple, i32 0, i32 1
-// CHECK:STDOUT:   store ptr %b, ptr %tuple2, align 8
-// CHECK:STDOUT:   call void @G(ptr %tuple)
-// CHECK:STDOUT:   ret void
+// CHECK:STDOUT:   %tuple = alloca { ptr, ptr }, align 8, !dbg !7
+// CHECK:STDOUT:   %tuple1 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple, i32 0, i32 0, !dbg !7
+// CHECK:STDOUT:   store ptr %a, ptr %tuple1, align 8, !dbg !7
+// CHECK:STDOUT:   %tuple2 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple, i32 0, i32 1, !dbg !7
+// CHECK:STDOUT:   store ptr %b, ptr %tuple2, align 8, !dbg !7
+// CHECK:STDOUT:   call void @G(ptr %tuple), !dbg !8
+// CHECK:STDOUT:   ret void, !dbg !9
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -40,3 +40,6 @@ fn F(a: (i32, i32, i32), b: (i32, i32, i32)) {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 5, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 1, scope: !4)

+ 8 - 4
toolchain/lower/testdata/var/local.carbon

@@ -18,10 +18,10 @@ fn Run() -> i32 {
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @main() !dbg !4 {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %x.var = alloca i32, align 4
-// CHECK:STDOUT:   store i32 1, ptr %x.var, align 4
-// CHECK:STDOUT:   %.loc13 = load i32, ptr %x.var, align 4
-// CHECK:STDOUT:   ret i32 %.loc13
+// CHECK:STDOUT:   %x.var = alloca i32, align 4, !dbg !7
+// CHECK:STDOUT:   store i32 1, ptr %x.var, align 4, !dbg !8
+// CHECK:STDOUT:   %.loc13 = load i32, ptr %x.var, align 4, !dbg !9
+// CHECK:STDOUT:   ret i32 %.loc13, !dbg !10
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
@@ -34,3 +34,7 @@ fn Run() -> i32 {
 // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
 // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
 // CHECK:STDOUT: !6 = !{}
+// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4)
+// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4)
+// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 10, scope: !4)
+// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 3, scope: !4)

Некоторые файлы не были показаны из-за большого количества измененных файлов