Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add line-level debug info #4247

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions toolchain/lower/file_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 changes: 4 additions & 0 deletions toolchain/lower/file_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 10 additions & 1 deletion toolchain/lower/function_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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* {
Expand Down Expand Up @@ -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_));
Comment on lines +101 to +103
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure, this is assuming the locations are valid and in the current file. Should that be checked? For example, loc.line_number <= 0 or loc.column_number <= 0 would indicate unknown. You can see some of this in FormatSnippet

Doing something on the file could just be a TODO.

Not sure how much we test multi-file lowering today, but might still be worth adding some resilience and/or todos.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm - 0 is an OK value for the debug info (it means "we can't assign this instruction to any particular source line") and I think we use 0 for invalid column number too. Is it just 0 for invalid, or are really <= 0? (carrying some extra information about kinds of invalidity or something in this?)

What causes invalid values but successful code generation? (happy to add some test coverage)

The multi-file issue is due to the unimpleented/trivially implemented context callback passed to the ConvertLoc call?

Copy link
Contributor

@jonmeow jonmeow Aug 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm - 0 is an OK value for the debug info (it means "we can't assign this instruction to any particular source line") and I think we use 0 for invalid column number too. Is it just 0 for invalid, or are really <= 0? (carrying some extra information about kinds of invalidity or something in this?)

What causes invalid values but successful code generation? (happy to add some test coverage)

-1 is used for "unknown", it's the default value for both (https://github.com/carbon-language/carbon-lang/blob/trunk/toolchain/diagnostics/diagnostic.h#L61-L64).

The default value is sometimes used, for example here:
https://github.com/carbon-language/carbon-lang/blob/trunk/toolchain/parse/tree_node_diagnostic_converter.h#L48-L51

I know this comes up in check:
https://github.com/search?q=repo%3Acarbon-language%2Fcarbon-lang+path%3Atestdata%2F+%22.carbon%3A+%22&type=code

I'm not sure what test coverage would look like. However, it might still be good to handle it since it's allowed by the API call.

The multi-file issue is due to the unimpleented/trivially implemented context callback passed to the ConvertLoc call?

No, this is just what the location converter is up to. A location can be either a node_id or a import_ir_id. In the latter case, it's referencing an imported instruction. Again, not sure it'll happen right now. OTOH, probably will start coming up as complexity increases, e.g. for template expansions or maybe inlining code.

Not sure why you're looking at the context though... To be sure, the DiagnosticLoc has a field "filename" for this. You'd need to ensure that everything you're using is a Parse::Node in order to be guaranteed it's in the file. e.g., something like:

auto loc_id = insts().GetLocId(inst_id);
if (loc_id.is_valid() && loc_id.is_node_id()) {
   // This is in the current file.
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, an option is to just leave a guardrail, e.g.:

CARBON_CHECK(loc.filename == sem_ir.filename() && loc.line_number >= 1 && loc.column_number >= 1) << "We currently only support lowering instructions in the current file";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, you could also look at changing line_number to be 0-defaulted, to help DebugInfo. I think I'd chosen -1 in order to avoid accidents with 0 versus 1 as the first correct value: although comments don't specify, I think 1 is where it starts, but a bug could lead to 0 and it'd stick out a little more.

But if you change that, do add comments specifying why the values are chosen that way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, line: 4294967295 does appear in the .carbon testdata files as a result of this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out, I hadn't been looking the right way to notice that.


CARBON_KIND_SWITCH(inst) {
#define CARBON_SEM_IR_INST_KIND(Name) \
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions toolchain/lower/function_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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_;

Expand Down
12 changes: 8 additions & 4 deletions toolchain/lower/testdata/alias/local.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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)
17 changes: 11 additions & 6 deletions toolchain/lower/testdata/array/array_in_place.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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)
41 changes: 23 additions & 18 deletions toolchain/lower/testdata/array/assign_return_value.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
81 changes: 48 additions & 33 deletions toolchain/lower/testdata/array/base.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Loading
Loading