0.6.0: init_new/init_temp removed. LinkedList API rewritten. List "pop" and "remove" function now return Optionals. RingBuffer API rewritten. Allocator interface changed. Deprecated Allocator, DString and mem functions removed. "identity" functions are now constants for Matrix and Complex numbers. @default implementations for interfaces removed. any* => any, same for interfaces. Emit local/private globals as "private" in LLVM, following C "static". Updated enum syntax. Add support [rgba] properties in vectors. Improved checks of aliased "void". Subarray -> slice. Fix of llvm codegen enum check. Improved alignment handling. Add --output-dir #1155. Removed List/Object append. GenericList renamed AnyList. Remove unused "unwrap". Fixes to cond. Optimize output in dead branches. Better checking of operator methods. Disallow any from implementing dynamic methods. Check for operator mismatch. Remove unnecessary bitfield. Remove numbering in --list* commands Old style enum declaration for params/type, but now the type is optional. Add note on #1086. Allow making distinct types out of "void", "typeid", "anyfault" and faults. Remove system linker build options. "Try" expressions must be simple expressions. Add optimized build to Mac tests. Register int. assert(false) only allowed in unused branches or in tests. Compile time failed asserts is a compile time error. Remove current_block_is_target. Bug when assigning an optional from an optional. Remove unused emit_zstring. Simplify phi code. Remove unnecessary unreachable blocks and remove unnecessary current_block NULL assignments. Proper handling of '.' and Win32 '//server' paths. Add "no discard" to expression blocks with a return value. Detect "unsigned >= 0" as errors. Fix issue with distinct void as a member #1147. Improve callstack debug information #1184. Fix issue with absolute output-dir paths. Lambdas were not type checked thoroughly #1185. Fix compilation warning #1187. Request jump table using @jump for switches. Path normalization - fix possible null terminator out of bounds. Improved error messages on inlined macros.

Upgrade of mingw in CI. Fix problems using reflection on interface types #1203. Improved debug information on defer. $foreach doesn't create an implicit syntactic scope.
Error if `@if` depends on `@if`. Updated Linux stacktrace. Fix of default argument stacktrace. Allow linking libraries directly by file path. Improve inlining warning messages. Added `index_of_char_from`. Compiler crash using enum nameof from different module #1205. Removed unused fields in find_msvc. Use vswhere to find msvc. Update tests for LLVM 19
This commit is contained in:
Christoffer Lerno
2024-02-23 00:18:43 +01:00
parent 321c5ec756
commit e293c435af
271 changed files with 7608 additions and 6181 deletions

View File

@@ -8,15 +8,15 @@ interface Def
fn void! test()
{
any* x;
Abc* d = x; // #error: cannot implicitly be converted to 'Abc*'
any x;
Abc d = x; // #error: cannot implicitly be converted to 'Abc'
}
fn void! test2()
{
Abc* x;
any* d = x;
Def* e = x;
Abc x;
any d = x;
Def e = x;
x = e; // #error: is not a parent interface of 'Def'
}

View File

@@ -1,131 +0,0 @@
// #target: macos-x64
module test;
interface Abc
{
fn int[<2>] test() @optional;
fn int bye();
}
fn int[<2>] Abc.test(&self) @default
{
return { 5, 7 };
}
struct Hello (Abc)
{
int y;
}
fn int[<2>] Hello.test(&self) @dynamic { return { 5, 10 }; }
fn int Hello.bye(&self) @dynamic { return 7; }
fn void main()
{
Hello z = { 32 };
Abc* x = &z;
int[<2>] z2 = x.test();
int w = x.bye();
}
/* #expect: test.ll
define double @test.Abc.test(i64 %0, ptr %1) #0 {
define double @test.Hello.test(ptr %0) #0 {
define i32 @test.Hello.bye(ptr %0) #0 {
; Function Attrs:
define void @test.main() #0 {
entry:
%z = alloca %Hello, align 4
%x = alloca %"any*", align 8
%z2 = alloca <2 x i32>, align 8
%.inlinecache = alloca ptr, align 8
%.cachedtype = alloca ptr, align 8
%result = alloca <2 x i32>, align 8
%result3 = alloca <2 x i32>, align 8
%w = alloca i32, align 4
%.inlinecache6 = alloca ptr, align 8
%.cachedtype7 = alloca ptr, align 8
store ptr null, ptr %.cachedtype7, align 8
store ptr null, ptr %.cachedtype, align 8
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %z, ptr align 4 @.__const, i32 4, i1 false)
%0 = insertvalue %"any*" undef, ptr %z, 0
%1 = insertvalue %"any*" %0, i64 ptrtoint (ptr @"$ct.test.Hello" to i64), 1
store %"any*" %1, ptr %x, align 8
%ptradd = getelementptr inbounds i8, ptr %x, i64 8
%2 = load i64, ptr %ptradd, align 8
%3 = inttoptr i64 %2 to ptr
%type = load ptr, ptr %.cachedtype, align 8
%4 = icmp eq ptr %3, %type
br i1 %4, label %cache_hit, label %cache_miss
cache_miss: ; preds = %entry
%ptradd1 = getelementptr inbounds i8, ptr %3, i64 16
%5 = load ptr, ptr %ptradd1, align 8
%6 = call ptr @.dyn_search(ptr %5, ptr @"$sel.test")
store ptr %6, ptr %.inlinecache, align 8
store ptr %3, ptr %.cachedtype, align 8
br label %7
cache_hit: ; preds = %entry
%cache_hit_fn = load ptr, ptr %.inlinecache, align 8
br label %7
7: ; preds = %cache_hit, %cache_miss
%fn_phi = phi ptr [ %cache_hit_fn, %cache_hit ], [ %6, %cache_miss ]
%8 = icmp eq ptr %fn_phi, null
br i1 %8, label %missing_function, label %match
missing_function: ; preds = %7
%lo = load i64, ptr %x, align 8
%ptradd2 = getelementptr inbounds i8, ptr %x, i64 8
%hi = load ptr, ptr %ptradd2, align 8
%9 = call double @test.Abc.test(i64 %lo, ptr %hi)
store double %9, ptr %result, align 8
%10 = load <2 x i32>, ptr %result, align 8
br label %after_call
match: ; preds = %7
%11 = load ptr, ptr %x, align 8
%12 = call double %fn_phi(ptr %11)
store double %12, ptr %result3, align 8
%13 = load <2 x i32>, ptr %result3, align 8
br label %after_call
after_call: ; preds = %match, %missing_function
%result4 = phi <2 x i32> [ %10, %missing_function ], [ %13, %match ]
store <2 x i32> %result4, ptr %z2, align 8
%ptradd5 = getelementptr inbounds i8, ptr %x, i64 8
%14 = load i64, ptr %ptradd5, align 8
%15 = inttoptr i64 %14 to ptr
%type8 = load ptr, ptr %.cachedtype7, align 8
%16 = icmp eq ptr %15, %type8
br i1 %16, label %cache_hit11, label %cache_miss9
cache_miss9: ; preds = %after_call
%ptradd10 = getelementptr inbounds i8, ptr %15, i64 16
%17 = load ptr, ptr %ptradd10, align 8
%18 = call ptr @.dyn_search(ptr %17, ptr @"$sel.bye")
store ptr %18, ptr %.inlinecache6, align 8
store ptr %15, ptr %.cachedtype7, align 8
br label %19
cache_hit11: ; preds = %after_call
%cache_hit_fn12 = load ptr, ptr %.inlinecache6, align 8
br label %19
19: ; preds = %cache_hit11, %cache_miss9
%fn_phi13 = phi ptr [ %cache_hit_fn12, %cache_hit11 ], [ %18, %cache_miss9 ]
%20 = icmp eq ptr %fn_phi13, null
br i1 %20, label %missing_function14, label %match15
missing_function14: ; preds = %19
%21 = load ptr, ptr @std.core.builtin.panic, align 8
call void %21(ptr @.panic_msg, i64 40, ptr @.file, i64 23, ptr @.func, i64 4, i32 26)
unreachable
match15: ; preds = %19
%22 = load ptr, ptr %x, align 8
%23 = call i32 %fn_phi13(ptr %22)
store i32 %23, ptr %w, align 4
ret void
}

View File

@@ -31,16 +31,16 @@ struct Test (TestProto, TestProto2)
fn void main()
{
TestProto* z = mem::alloc(Test);
TestProto z = mem::alloc(Test);
z.tesT();
Base* w = z;
Base w = z;
w.tesT();
}
/* #expect: inherit.ll
%.introspect = type { i8, i64, ptr, i64, i64, i64, [0 x i64] }
%"any*" = type { ptr, i64 }
%any = type { ptr, i64 }
$.dyn_search = comdat any
$"$ct.inherit.Test" = comdat any
$"$sel.tesT" = comdat any
@@ -70,18 +70,18 @@ entry:
; Function Attrs:
define void @inherit.main() #0 {
entry:
%z = alloca %"any*", align 8
%z = alloca %any, align 8
%.inlinecache = alloca ptr, align 8
%.cachedtype = alloca ptr, align 8
%w = alloca %"any*", align 8
%w = alloca %any, align 8
%.inlinecache3 = alloca ptr, align 8
%.cachedtype4 = alloca ptr, align 8
store ptr null, ptr %.cachedtype4, align 8
store ptr null, ptr %.cachedtype, align 8
%0 = call ptr @std.core.mem.malloc(i64 8) #1
%1 = insertvalue %"any*" undef, ptr %0, 0
%2 = insertvalue %"any*" %1, i64 ptrtoint (ptr @"$ct.inherit.Test" to i64), 1
store %"any*" %2, ptr %z, align 8
%1 = insertvalue %any undef, ptr %0, 0
%2 = insertvalue %any %1, i64 ptrtoint (ptr @"$ct.inherit.Test" to i64), 1
store %any %2, ptr %z, align 8
%ptradd = getelementptr inbounds i8, ptr %z, i64 8
%3 = load i64, ptr %ptradd, align 8
%4 = inttoptr i64 %3 to ptr
@@ -109,8 +109,8 @@ missing_function: ; preds = %8
match: ; preds = %8
%11 = load ptr, ptr %z, align 8
call void %fn_phi(ptr %11)
%12 = load %"any*", ptr %z, align 8
store %"any*" %12, ptr %w, align 8
%12 = load %any, ptr %z, align 8
store %any %12, ptr %w, align 8
%ptradd2 = getelementptr inbounds i8, ptr %w, i64 8
%13 = load i64, ptr %ptradd2, align 8
%14 = inttoptr i64 %13 to ptr

View File

@@ -31,16 +31,16 @@ struct Test (TestProto, TestProto2)
fn void main()
{
TestProto* z = mem::alloc(Test);
TestProto z = mem::alloc(Test);
z.tesT();
Base* w = z;
Base w = z;
w.tesT();
}
/* #expect: inherit.ll
%.introspect = type { i8, i64, ptr, i64, i64, i64, [0 x i64] }
%"any*" = type { ptr, i64 }
%any = type { ptr, i64 }
@"$ct.inherit.Test" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 8, i64 0, i64 1, [0 x i64] zeroinitializer }, align 8
@"$sel.tesT" = linkonce_odr constant [5 x i8] c"tesT\00", align 1
@.panic_msg = internal constant [42 x i8] c"No method 'tesT' could be found on target\00", align 1
@@ -64,18 +64,18 @@ entry:
; Function Attrs:
define void @inherit.main() #0 {
entry:
%z = alloca %"any*", align 8
%z = alloca %any, align 8
%.inlinecache = alloca ptr, align 8
%.cachedtype = alloca ptr, align 8
%w = alloca %"any*", align 8
%w = alloca %any, align 8
%.inlinecache3 = alloca ptr, align 8
%.cachedtype4 = alloca ptr, align 8
store ptr null, ptr %.cachedtype4, align 8
store ptr null, ptr %.cachedtype, align 8
%0 = call ptr @std.core.mem.malloc(i64 8) #1
%1 = insertvalue %"any*" undef, ptr %0, 0
%2 = insertvalue %"any*" %1, i64 ptrtoint (ptr @"$ct.inherit.Test" to i64), 1
store %"any*" %2, ptr %z, align 8
%1 = insertvalue %any undef, ptr %0, 0
%2 = insertvalue %any %1, i64 ptrtoint (ptr @"$ct.inherit.Test" to i64), 1
store %any %2, ptr %z, align 8
%ptradd = getelementptr inbounds i8, ptr %z, i64 8
%3 = load i64, ptr %ptradd, align 8
%4 = inttoptr i64 %3 to ptr
@@ -103,8 +103,8 @@ missing_function: ; preds = %8
match: ; preds = %8
%11 = load ptr, ptr %z, align 8
call void %fn_phi(ptr %11)
%12 = load %"any*", ptr %z, align 8
store %"any*" %12, ptr %w, align 8
%12 = load %any, ptr %z, align 8
store %any %12, ptr %w, align 8
%ptradd2 = getelementptr inbounds i8, ptr %w, i64 8
%13 = load i64, ptr %ptradd2, align 8
%14 = inttoptr i64 %13 to ptr

View File

@@ -5,31 +5,31 @@ interface Test {}
fn void main()
{
Test* a;
Test a;
bool x = a == null;
a = null;
any* z = a;
any z = a;
z = null;
}
/* #expect: test.ll
%"any*" = type { ptr, i64 }
%any = type { ptr, i64 }
@"$ct.void" = linkonce global %.introspect { i8 0, i64 0, ptr null, i64 1, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8
define void @test.main() #0 {
entry:
%a = alloca %"any*", align 8
%a = alloca %any, align 8
%x = alloca i8, align 1
%z = alloca %"any*", align 8
store %"any*" zeroinitializer, ptr %a, align 8
%z = alloca %any, align 8
store %any zeroinitializer, ptr %a, align 8
%0 = load ptr, ptr %a, align 8
%eq = icmp eq ptr %0, null
%1 = zext i1 %eq to i8
store i8 %1, ptr %x, align 1
store %"any*" { ptr null, i64 ptrtoint (ptr @"$ct.void" to i64) }, ptr %a, align 8
%2 = load %"any*", ptr %a, align 8
store %"any*" %2, ptr %z, align 8
store %"any*" { ptr null, i64 ptrtoint (ptr @"$ct.void" to i64) }, ptr %z, align 8
store %any { ptr null, i64 ptrtoint (ptr @"$ct.void" to i64) }, ptr %a, align 8
%2 = load %any, ptr %a, align 8
store %any %2, ptr %z, align 8
store %any { ptr null, i64 ptrtoint (ptr @"$ct.void" to i64) }, ptr %z, align 8
ret void
}

View File

@@ -25,16 +25,16 @@ struct Test (TestProto, TestProto2)
fn void main()
{
TestProto* z = mem::alloc(Test);
TestProto z = mem::alloc(Test);
z.tesT();
TestProto2* w = (TestProto2*)z;
TestProto2 w = (TestProto2)z;
w.tesT();
}
/* #expect: overlap.ll
%.introspect = type { i8, i64, ptr, i64, i64, i64, [0 x i64] }
%"any*" = type { ptr, i64 }
%any = type { ptr, i64 }
@"$ct.overlap.Test" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 8, i64 0, i64 1, [0 x i64] zeroinitializer }, comdat, align 8
@"$sel.tesT" = linkonce_odr constant [5 x i8] c"tesT\00", comdat, align 1
@.panic_msg = internal constant [42 x i8] c"No method 'tesT' could be found on target\00", align 1
@@ -60,18 +60,18 @@ entry:
; Function Attrs:
define void @overlap.main() #0 {
entry:
%z = alloca %"any*", align 8
%z = alloca %any, align 8
%.inlinecache = alloca ptr, align 8
%.cachedtype = alloca ptr, align 8
%w = alloca %"any*", align 8
%w = alloca %any, align 8
%.inlinecache3 = alloca ptr, align 8
%.cachedtype4 = alloca ptr, align 8
store ptr null, ptr %.cachedtype4, align 8
store ptr null, ptr %.cachedtype, align 8
%0 = call ptr @std.core.mem.malloc(i64 8) #1
%1 = insertvalue %"any*" undef, ptr %0, 0
%2 = insertvalue %"any*" %1, i64 ptrtoint (ptr @"$ct.overlap.Test" to i64), 1
store %"any*" %2, ptr %z, align 8
%1 = insertvalue %any undef, ptr %0, 0
%2 = insertvalue %any %1, i64 ptrtoint (ptr @"$ct.overlap.Test" to i64), 1
store %any %2, ptr %z, align 8
%ptradd = getelementptr inbounds i8, ptr %z, i64 8
%3 = load i64, ptr %ptradd, align 8
%4 = inttoptr i64 %3 to ptr
@@ -99,8 +99,8 @@ missing_function: ; preds = %8
match: ; preds = %8
%11 = load ptr, ptr %z, align 8
call void %fn_phi(ptr %11)
%12 = load %"any*", ptr %z, align 8
store %"any*" %12, ptr %w, align 8
%12 = load %any, ptr %z, align 8
store %any %12, ptr %w, align 8
%ptradd2 = getelementptr inbounds i8, ptr %w, i64 8
%13 = load i64, ptr %ptradd2, align 8
%14 = inttoptr i64 %13 to ptr

View File

@@ -25,15 +25,15 @@ struct Test (TestProto, TestProto2)
fn void main()
{
TestProto* z = mem::alloc(Test);
TestProto z = mem::alloc(Test);
z.tesT();
TestProto2* w = (TestProto2*)z;
TestProto2 w = (TestProto2)z;
w.tesT();
}
/* #expect: overlap.ll
%.introspect = type { i8, i64, ptr, i64, i64, i64, [0 x i64] }
%"any*" = type { ptr, i64 }
%any = type { ptr, i64 }
@"$ct.overlap.Test" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 8, i64 0, i64 1, [0 x i64] zeroinitializer }, align 8
@"$sel.tesT" = linkonce_odr constant [5 x i8] c"tesT\00", align 1
@@ -59,18 +59,18 @@ entry:
; Function Attrs:
define void @overlap.main() #0 {
entry:
%z = alloca %"any*", align 8
%z = alloca %any, align 8
%.inlinecache = alloca ptr, align 8
%.cachedtype = alloca ptr, align 8
%w = alloca %"any*", align 8
%w = alloca %any, align 8
%.inlinecache3 = alloca ptr, align 8
%.cachedtype4 = alloca ptr, align 8
store ptr null, ptr %.cachedtype4, align 8
store ptr null, ptr %.cachedtype, align 8
%0 = call ptr @std.core.mem.malloc(i64 8) #1
%1 = insertvalue %"any*" undef, ptr %0, 0
%2 = insertvalue %"any*" %1, i64 ptrtoint (ptr @"$ct.overlap.Test" to i64), 1
store %"any*" %2, ptr %z, align 8
%1 = insertvalue %any undef, ptr %0, 0
%2 = insertvalue %any %1, i64 ptrtoint (ptr @"$ct.overlap.Test" to i64), 1
store %any %2, ptr %z, align 8
%ptradd = getelementptr inbounds i8, ptr %z, i64 8
%3 = load i64, ptr %ptradd, align 8
%4 = inttoptr i64 %3 to ptr
@@ -103,8 +103,8 @@ missing_function: ; preds = %8
match: ; preds = %8
%11 = load ptr, ptr %z, align 8
call void %fn_phi(ptr %11)
%12 = load %"any*", ptr %z, align 8
store %"any*" %12, ptr %w, align 8
%12 = load %any, ptr %z, align 8
store %any %12, ptr %w, align 8
%ptradd2 = getelementptr inbounds i8, ptr %w, i64 8
%13 = load i64, ptr %ptradd2, align 8
%14 = inttoptr i64 %13 to ptr