---
source: crates/mun_codegen/src/test.rs
expression: "\n struct(gc) Foo { a: i32, b: i32 };\n\n pub fn foo() {\n let a = Foo { a: 3, b: 4 };\n a.b += 3;\n let b = a;\n }\n "
---
; == FILE IR (mod) =====================================
; ModuleID = 'mod'
source_filename = "mod"
%DispatchTable = type { i8** (i8*, i8*)* }
%"mun_codegen::ir::types::TypeInfo" = type <{ [0 x i64], [16 x i8], [0 x i64], i8*, [0 x i64], i32, [0 x i64], i8, [3 x i8], %"mun_codegen::ir::types::TypeInfoData", [0 x i64] }>
%"mun_codegen::ir::types::TypeInfoData" = type <{ [0 x i8], i8, [39 x i8] }>
%Foo = type { i32, i32 }
@allocatorHandle = external global i8*
@dispatchTable = external global %DispatchTable
@global_type_table = external global [5 x %"mun_codegen::ir::types::TypeInfo"*]
define void @foo() {
body:
%b = alloca %Foo**, align 8
%a = alloca %Foo**, align 8
%new_ptr = load i8** (i8*, i8*)*, i8** (i8*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0), align 8
%Foo_ptr = load %"mun_codegen::ir::types::TypeInfo"*, %"mun_codegen::ir::types::TypeInfo"** getelementptr inbounds ([5 x %"mun_codegen::ir::types::TypeInfo"*], [5 x %"mun_codegen::ir::types::TypeInfo"*]* @global_type_table, i64 0, i64 0), align 8
%type_info_ptr_to_i8_ptr = bitcast %"mun_codegen::ir::types::TypeInfo"* %Foo_ptr to i8*
%allocator_handle = load i8*, i8** @allocatorHandle, align 8
%new = call i8** %new_ptr(i8* %type_info_ptr_to_i8_ptr, i8* %allocator_handle)
%Foo_ptr_ptr = bitcast i8** %new to %Foo**
%Foo_mem_ptr = load %Foo*, %Foo** %Foo_ptr_ptr, align 8
store %Foo { i32 3, i32 4 }, %Foo* %Foo_mem_ptr, align 4
store %Foo** %Foo_ptr_ptr, %Foo*** %a, align 8
%mem_ptr = load %Foo**, %Foo*** %a, align 8
%deref = load %Foo*, %Foo** %mem_ptr, align 8
%Foo.b_ptr = getelementptr inbounds %Foo, %Foo* %deref, i32 0, i32 1
%Foo.b = load i32, i32* %Foo.b_ptr, align 4
%add = add i32 %Foo.b, 3
%mem_ptr1 = load %Foo**, %Foo*** %a, align 8
%deref2 = load %Foo*, %Foo** %mem_ptr1, align 8
%Foo.b_ptr3 = getelementptr inbounds %Foo, %Foo* %deref2, i32 0, i32 1
store i32 %add, i32* %Foo.b_ptr3, align 4
%a4 = load %Foo**, %Foo*** %a, align 8
store %Foo** %a4, %Foo*** %b, align 8
ret void
}
; == GROUP IR (mod) ====================================
; ModuleID = 'group_name'
source_filename = "group_name"
%DispatchTable = type { i8** (i8*, i8*)* }
%"mun_codegen::ir::types::TypeInfo" = type <{ [0 x i64], [16 x i8], [0 x i64], i8*, [0 x i64], i32, [0 x i64], i8, [3 x i8], %"mun_codegen::ir::types::TypeInfoData", [0 x i64] }>
%"mun_codegen::ir::types::TypeInfoData" = type <{ [0 x i8], i8, [39 x i8] }>
@dispatchTable = global %DispatchTable zeroinitializer
@"type_info::<Foo>::name" = private unnamed_addr constant [4 x i8] c"Foo\00"
@"struct_info::<Foo>::field_names.0" = private unnamed_addr constant [2 x i8] c"a\00"
@"struct_info::<Foo>::field_names.1" = private unnamed_addr constant [2 x i8] c"b\00"
@"struct_info::<Foo>::field_names" = private unnamed_addr constant [2 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @"struct_info::<Foo>::field_names.0", i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @"struct_info::<Foo>::field_names.1", i32 0, i32 0)]
@"type_info::<core::i32>::name" = private unnamed_addr constant [10 x i8] c"core::i32\00"
@"type_info::<core::i32>" = private unnamed_addr constant <{ [16 x i8], i8*, [48 x i8] }> <{ [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", i8* getelementptr inbounds ([10 x i8], [10 x i8]* @"type_info::<core::i32>::name", i32 0, i32 0), [48 x i8] c" \00\00\00\04\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" }>
@"struct_info::<Foo>::field_types" = private unnamed_addr constant [2 x %"mun_codegen::ir::types::TypeInfo"*] [%"mun_codegen::ir::types::TypeInfo"* @"type_info::<core::i32>", %"mun_codegen::ir::types::TypeInfo"* @"type_info::<core::i32>"]
@"struct_info::<Foo>::field_offsets" = private unnamed_addr constant [2 x i16] [i16 0, i16 4]
@"type_info::<Foo>" = private unnamed_addr constant <{ [16 x i8], i8*, [16 x i8], i8**, [0 x i8], %"mun_codegen::ir::types::TypeInfo"**, [0 x i8], i16*, [8 x i8] }> <{ [16 x i8] c"\03\FC\D1_\DB\DB\0AJ1r,\F0m\CBQ\D0", i8* getelementptr inbounds ([4 x i8], [4 x i8]* @"type_info::<Foo>::name", i32 0, i32 0), [16 x i8] c"@\00\00\00\04\00\00\00\01\00\00\00\00\00\00\00", i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @"struct_info::<Foo>::field_names", i32 0, i32 0), [0 x i8] zeroinitializer, %"mun_codegen::ir::types::TypeInfo"** getelementptr inbounds ([2 x %"mun_codegen::ir::types::TypeInfo"*], [2 x %"mun_codegen::ir::types::TypeInfo"*]* @"struct_info::<Foo>::field_types", i32 0, i32 0), [0 x i8] zeroinitializer, i16* getelementptr inbounds ([2 x i16], [2 x i16]* @"struct_info::<Foo>::field_offsets", i32 0, i32 0), [8 x i8] c"\02\00\00\00\00\00\00\00" }>
@"type_info::<*const TypeInfo>::name" = private unnamed_addr constant [16 x i8] c"*const TypeInfo\00"
@"type_info::<*const TypeInfo>" = private unnamed_addr constant <{ [16 x i8], i8*, [48 x i8] }> <{ [16 x i8] c"=\A1-\1F\C2\A7\88`d\90\F4\B5\BEE}x", i8* getelementptr inbounds ([16 x i8], [16 x i8]* @"type_info::<*const TypeInfo>::name", i32 0, i32 0), [48 x i8] c"@\00\00\00\08\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" }>
@"type_info::<*const *mut core::void>::name" = private unnamed_addr constant [23 x i8] c"*const *mut core::void\00"
@"type_info::<*const *mut core::void>" = private unnamed_addr constant <{ [16 x i8], i8*, [48 x i8] }> <{ [16 x i8] c"\C5fO\BD\84\DF\06\BFd+\B1\9Abv\CE\00", i8* getelementptr inbounds ([23 x i8], [23 x i8]* @"type_info::<*const *mut core::void>::name", i32 0, i32 0), [48 x i8] c"@\00\00\00\08\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" }>
@"type_info::<*mut core::void>::name" = private unnamed_addr constant [16 x i8] c"*mut core::void\00"
@"type_info::<*mut core::void>" = private unnamed_addr constant <{ [16 x i8], i8*, [48 x i8] }> <{ [16 x i8] c"\F0Y\22\FC\95\9E\7F\CE\08T\B1\A2\CD\A7\FAz", i8* getelementptr inbounds ([16 x i8], [16 x i8]* @"type_info::<*mut core::void>::name", i32 0, i32 0), [48 x i8] c"@\00\00\00\08\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" }>
@global_type_table = constant [5 x %"mun_codegen::ir::types::TypeInfo"*] [%"mun_codegen::ir::types::TypeInfo"* @"type_info::<Foo>", %"mun_codegen::ir::types::TypeInfo"* @"type_info::<core::i32>", %"mun_codegen::ir::types::TypeInfo"* @"type_info::<*const TypeInfo>", %"mun_codegen::ir::types::TypeInfo"* @"type_info::<*const *mut core::void>", %"mun_codegen::ir::types::TypeInfo"* @"type_info::<*mut core::void>"]
@allocatorHandle = unnamed_addr global i8* null