-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #232 from baszalmstra/fix/issue_225
fix: fixes issues #225
- Loading branch information
Showing
8 changed files
with
286 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
crates/mun_codegen/src/snapshots/mun_codegen__test__issue_225.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
source: crates/mun_codegen/src/test.rs | ||
expression: "struct Num {\n value: i64,\n}\n\npub fn foo(b: i64) {\n Num { value: b }.value;\n}\n\npub fn bar(b: i64) {\n { let a = Num { value: b }; a}.value;\n}" | ||
--- | ||
; == FILE IR ===================================== | ||
; ModuleID = 'main.mun' | ||
source_filename = "main.mun" | ||
|
||
%DispatchTable = type { i8** (i8*, i8*)* } | ||
%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } | ||
%Num = type { i64 } | ||
|
||
@allocatorHandle = external global i8* | ||
@dispatchTable = external global %DispatchTable | ||
@global_type_table = external global [5 x %struct.MunTypeInfo*] | ||
|
||
define void @foo(i64) { | ||
body: | ||
%init = insertvalue %Num undef, i64 %0, 0 | ||
%new_ptr = load i8** (i8*, i8*)*, i8** (i8*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) | ||
%Num_ptr = load %struct.MunTypeInfo*, %struct.MunTypeInfo** getelementptr inbounds ([5 x %struct.MunTypeInfo*], [5 x %struct.MunTypeInfo*]* @global_type_table, i32 0, i32 2) | ||
%type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo* %Num_ptr to i8* | ||
%allocator_handle = load i8*, i8** @allocatorHandle | ||
%new = call i8** %new_ptr(i8* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) | ||
%Num_ptr_ptr = bitcast i8** %new to %Num** | ||
%Num_mem_ptr = load %Num*, %Num** %Num_ptr_ptr | ||
store %Num %init, %Num* %Num_mem_ptr | ||
%mem_ptr = load %Num*, %Num** %Num_ptr_ptr | ||
%deref = load %Num, %Num* %mem_ptr | ||
ret void | ||
} | ||
|
||
define void @bar(i64) { | ||
body: | ||
%init = insertvalue %Num undef, i64 %0, 0 | ||
%new_ptr = load i8** (i8*, i8*)*, i8** (i8*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0) | ||
%Num_ptr = load %struct.MunTypeInfo*, %struct.MunTypeInfo** getelementptr inbounds ([5 x %struct.MunTypeInfo*], [5 x %struct.MunTypeInfo*]* @global_type_table, i32 0, i32 2) | ||
%type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo* %Num_ptr to i8* | ||
%allocator_handle = load i8*, i8** @allocatorHandle | ||
%new = call i8** %new_ptr(i8* %type_info_ptr_to_i8_ptr, i8* %allocator_handle) | ||
%Num_ptr_ptr = bitcast i8** %new to %Num** | ||
%Num_mem_ptr = load %Num*, %Num** %Num_ptr_ptr | ||
store %Num %init, %Num* %Num_mem_ptr | ||
%mem_ptr = load %Num*, %Num** %Num_ptr_ptr | ||
%deref = load %Num, %Num* %mem_ptr | ||
ret void | ||
} | ||
|
||
|
||
; == GROUP IR ==================================== | ||
; ModuleID = 'group_name' | ||
source_filename = "group_name" | ||
|
||
%DispatchTable = type { i8** (i8*, i8*)* } | ||
%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 } | ||
%struct.MunStructInfo = type { i8**, %struct.MunTypeInfo**, i16*, i16, i8 } | ||
|
||
@dispatchTable = global %DispatchTable zeroinitializer | ||
@"type_info::<*const TypeInfo>::name" = private unnamed_addr constant [16 x i8] c"*const TypeInfo\00" | ||
@"type_info::<*const TypeInfo>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"=\A1-\1F\C2\A7\88`d\90\F4\B5\BEE}x", [16 x i8]* @"type_info::<*const TypeInfo>::name", i32 64, i8 8, i8 0 } | ||
@"type_info::<core::i64>::name" = private unnamed_addr constant [10 x i8] c"core::i64\00" | ||
@"type_info::<core::i64>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"G\13;t\97j8\18\D7M\83`\1D\C8\19%", [10 x i8]* @"type_info::<core::i64>::name", i32 64, i8 8, i8 0 } | ||
@"type_info::<Num>::name" = private unnamed_addr constant [4 x i8] c"Num\00" | ||
@"struct_info::<Num>::field_names.0" = private unnamed_addr constant [6 x i8] c"value\00" | ||
@"struct_info::<Num>::field_names" = private unnamed_addr constant [1 x i8*] [i8* @"struct_info::<Num>::field_names.0"] | ||
@"struct_info::<Num>::field_types" = private unnamed_addr constant [1 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::<core::i64>"] | ||
@"struct_info::<Num>::field_offsets" = private unnamed_addr constant [1 x i16] zeroinitializer | ||
@"type_info::<Num>" = private unnamed_addr constant { %struct.MunTypeInfo, %struct.MunStructInfo } { %struct.MunTypeInfo { [16 x i8] c"\A92\E2p\B0\98\B2\C4\0C\A2\F5=x\904\00", [4 x i8]* @"type_info::<Num>::name", i32 64, i8 8, i8 1 }, %struct.MunStructInfo { [1 x i8*]* @"struct_info::<Num>::field_names", [1 x %struct.MunTypeInfo*]* @"struct_info::<Num>::field_types", [1 x i16]* @"struct_info::<Num>::field_offsets", i16 1, i8 0 } } | ||
@"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 %struct.MunTypeInfo { [16 x i8] c"\C5fO\BD\84\DF\06\BFd+\B1\9Abv\CE\00", [23 x i8]* @"type_info::<*const *mut core::void>::name", i32 64, i8 8, i8 0 } | ||
@"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 %struct.MunTypeInfo { [16 x i8] c"\F0Y\22\FC\95\9E\7F\CE\08T\B1\A2\CD\A7\FAz", [16 x i8]* @"type_info::<*mut core::void>::name", i32 64, i8 8, i8 0 } | ||
@global_type_table = constant [5 x %struct.MunTypeInfo*] [%struct.MunTypeInfo* @"type_info::<*const TypeInfo>", %struct.MunTypeInfo* @"type_info::<core::i64>", %struct.MunTypeInfo* @"type_info::<Num>", %struct.MunTypeInfo* @"type_info::<*const *mut core::void>", %struct.MunTypeInfo* @"type_info::<*mut core::void>"] | ||
@allocatorHandle = unnamed_addr global i8* null | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.