Skip to content

Commit

Permalink
fix: union type scope bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Chronostasys committed Dec 18, 2024
1 parent 3f2861c commit 1ac1b1b
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 18 deletions.
55 changes: 43 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ thread = ["threadpool"]
members = ["internal_macro", "vm", "pl_linker", "immix", "kagari"]

[profile.release]
lto = "thin"
lto = "fat"
opt-level = 3
debug = "line-tables-only"
# debug = "line-tables-only"

[profile.bench]
opt-level = 3
Expand All @@ -127,3 +127,8 @@ vergen = { version = "8.3.1", features = [
"rustc",
"si",
] }


[profile.dev]
overflow-checks = false
debug-assertions = false
13 changes: 11 additions & 2 deletions alloc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ declare noalias void @DioGC__safepoint_ex(

define noalias void @DioGC__safepoint(
i64 %rsp) {
call void @DioGC__safepoint_ex(i64 %rsp, ptr @gc_handle)
%collector_ptr = load ptr, ptr @gc_handle, align 8, !invariant.load !0
call void @DioGC__safepoint_ex(i64 %rsp, ptr %collector_ptr)
ret void
}


declare noalias void @gc_set_handle(ptr %handle)

define void @gc_thread_init() {
call void @gc_set_handle(ptr @gc_handle)
ret void
}

declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1) nounwind


Expand All @@ -43,7 +51,7 @@ entry:
br i1 %size_gt_7936, label %call_slowpath, label %check_collector
check_collector:
; Load collector from gc_handle
%collector_ptr = load ptr, ptr @gc_handle, align 8
%collector_ptr = load ptr, ptr @gc_handle, align 8, !invariant.load !0

; Check if collector_ptr is null
%is_null = icmp eq ptr %collector_ptr, null
Expand Down Expand Up @@ -158,3 +166,4 @@ finish_fast_path_2:


attributes #0 = { nounwind allockind("alloc") "gc-leaf-function" }
!0 = !{}
4 changes: 3 additions & 1 deletion src/ast/ctx/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ impl<'a, 'ctx> Ctx<'a> {
if let PLType::Union(u) = &*target_pltype.borrow() {
let mut union_members = vec![];
for tp in &u.sum_types {
let tp = tp.get_type(self, builder, true)?;
let tp = self.run_in_type_mod(u, |ctx,u|{
tp.get_type(ctx, builder, true)
})?;
union_members.push(tp);
}
for (i, tp) in union_members.iter().enumerate() {
Expand Down

0 comments on commit 1ac1b1b

Please sign in to comment.