mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
LLVM 15 compatibility fixes (#465)
More variant code. Fixes to typekind. Fixes to macro with failable returns. Remove use of LLVMConstInsert etc. Version 0.2.8
This commit is contained in:
committed by
GitHub
parent
bb28f6e61c
commit
c8a614e43f
@@ -76,27 +76,27 @@ entry:
|
||||
%5 = bitcast [3 x i32]* %literal to i32*
|
||||
%6 = insertvalue %"int[]" undef, i32* %5, 0
|
||||
%7 = insertvalue %"int[]" %6, i64 3, 1
|
||||
%len = extractvalue %"int[]" %7, 1
|
||||
%not = icmp eq i64 %len, 0
|
||||
%8 = zext i1 %not to i8
|
||||
store i8 %8, i8* %x, align 1
|
||||
%9 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 0
|
||||
store i32 0, i32* %9, align 4
|
||||
%10 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 1
|
||||
%8 = extractvalue %"int[]" %7, 1
|
||||
%not = icmp eq i64 %8, 0
|
||||
%9 = zext i1 %not to i8
|
||||
store i8 %9, i8* %x, align 1
|
||||
%10 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 0
|
||||
store i32 0, i32* %10, align 4
|
||||
%11 = bitcast %Baz* %z to i8*
|
||||
call void @llvm.memset.p0i8.i64(i8* align 8 %11, i8 0, i64 8, i1 false)
|
||||
%11 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 1
|
||||
store i32 0, i32* %11, align 4
|
||||
%12 = bitcast %Baz* %z to i8*
|
||||
call void @llvm.memset.p0i8.i64(i8* align 8 %12, i8 0, i64 8, i1 false)
|
||||
store [0 x i32] zeroinitializer, [0 x i32]* %literal1, align 4
|
||||
%12 = bitcast [0 x i32]* %literal1 to i32*
|
||||
%13 = insertvalue %"int[]" undef, i32* %12, 0
|
||||
%14 = insertvalue %"int[]" %13, i64 0, 1
|
||||
store %"int[]" %14, %"int[]"* %sub, align 8
|
||||
%13 = bitcast [0 x i32]* %literal1 to i32*
|
||||
%14 = insertvalue %"int[]" undef, i32* %13, 0
|
||||
%15 = insertvalue %"int[]" %14, i64 0, 1
|
||||
store %"int[]" %15, %"int[]"* %sub, align 8
|
||||
store [0 x %Bar] zeroinitializer, [0 x %Bar]* %literal2, align 4
|
||||
%15 = bitcast [0 x %Bar]* %literal2 to %Bar*
|
||||
%16 = insertvalue %"Bar[]" undef, %Bar* %15, 0
|
||||
%17 = insertvalue %"Bar[]" %16, i64 0, 1
|
||||
store %"Bar[]" %17, %"Bar[]"* %foo, align 8
|
||||
%18 = bitcast [3 x %Baz]* %baz to i8*
|
||||
call void @llvm.memset.p0i8.i64(i8* align 16 %18, i8 0, i64 24, i1 false)
|
||||
%16 = bitcast [0 x %Bar]* %literal2 to %Bar*
|
||||
%17 = insertvalue %"Bar[]" undef, %Bar* %16, 0
|
||||
%18 = insertvalue %"Bar[]" %17, i64 0, 1
|
||||
store %"Bar[]" %18, %"Bar[]"* %foo, align 8
|
||||
%19 = bitcast [3 x %Baz]* %baz to i8*
|
||||
call void @llvm.memset.p0i8.i64(i8* align 16 %19, i8 0, i64 24, i1 false)
|
||||
ret i32 1
|
||||
}
|
||||
@@ -144,37 +144,37 @@ entry:
|
||||
%34 = bitcast [3 x i32]* %literal6 to i32*
|
||||
%35 = insertvalue %"int[]" undef, i32* %34, 0
|
||||
%36 = insertvalue %"int[]" %35, i64 3, 1
|
||||
%len = extractvalue %"int[]" %36, 1
|
||||
%not = icmp eq i64 %len, 0
|
||||
%37 = zext i1 %not to i8
|
||||
store i8 %37, i8* %xy, align 1
|
||||
%38 = load i8, i8* %xy, align 1
|
||||
%39 = trunc i8 %38 to i1
|
||||
%not7 = xor i1 %39, true
|
||||
%37 = extractvalue %"int[]" %36, 1
|
||||
%not = icmp eq i64 %37, 0
|
||||
%38 = zext i1 %not to i8
|
||||
store i8 %38, i8* %xy, align 1
|
||||
%39 = load i8, i8* %xy, align 1
|
||||
%40 = trunc i8 %39 to i1
|
||||
%not7 = xor i1 %40, true
|
||||
br i1 %not7, label %if.then, label %if.exit
|
||||
|
||||
if.then: ; preds = %entry
|
||||
%40 = call i32 @"std::io.println"(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0)) #3
|
||||
%41 = call i32 @"std::io.println"(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0)) #3
|
||||
br label %if.exit
|
||||
|
||||
if.exit: ; preds = %if.then, %entry
|
||||
%41 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 0
|
||||
store i32 0, i32* %41, align 4
|
||||
%42 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 1
|
||||
%42 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 0
|
||||
store i32 0, i32* %42, align 4
|
||||
%43 = bitcast %Baz* %z to i8*
|
||||
call void @llvm.memset.p0i8.i64(i8* align 8 %43, i8 0, i64 8, i1 false)
|
||||
%43 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 1
|
||||
store i32 0, i32* %43, align 4
|
||||
%44 = bitcast %Baz* %z to i8*
|
||||
call void @llvm.memset.p0i8.i64(i8* align 8 %44, i8 0, i64 8, i1 false)
|
||||
store [0 x i32] zeroinitializer, [0 x i32]* %literal8, align 4
|
||||
%44 = bitcast [0 x i32]* %literal8 to i32*
|
||||
%45 = insertvalue %"int[]" undef, i32* %44, 0
|
||||
%46 = insertvalue %"int[]" %45, i64 0, 1
|
||||
store %"int[]" %46, %"int[]"* %sub, align 8
|
||||
%45 = bitcast [0 x i32]* %literal8 to i32*
|
||||
%46 = insertvalue %"int[]" undef, i32* %45, 0
|
||||
%47 = insertvalue %"int[]" %46, i64 0, 1
|
||||
store %"int[]" %47, %"int[]"* %sub, align 8
|
||||
store [0 x %Bar] zeroinitializer, [0 x %Bar]* %literal9, align 4
|
||||
%47 = bitcast [0 x %Bar]* %literal9 to %Bar*
|
||||
%48 = insertvalue %"Bar[]" undef, %Bar* %47, 0
|
||||
%49 = insertvalue %"Bar[]" %48, i64 0, 1
|
||||
store %"Bar[]" %49, %"Bar[]"* %foo, align 8
|
||||
%50 = bitcast [3 x %Baz]* %baz to i8*
|
||||
call void @llvm.memset.p0i8.i64(i8* align 16 %50, i8 0, i64 24, i1 false)
|
||||
%48 = bitcast [0 x %Bar]* %literal9 to %Bar*
|
||||
%49 = insertvalue %"Bar[]" undef, %Bar* %48, 0
|
||||
%50 = insertvalue %"Bar[]" %49, i64 0, 1
|
||||
store %"Bar[]" %50, %"Bar[]"* %foo, align 8
|
||||
%51 = bitcast [3 x %Baz]* %baz to i8*
|
||||
call void @llvm.memset.p0i8.i64(i8* align 16 %51, i8 0, i64 24, i1 false)
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
49
test/test_suite/macros/macro_failable_return_rethrow.c3t
Normal file
49
test/test_suite/macros/macro_failable_return_rethrow.c3t
Normal file
@@ -0,0 +1,49 @@
|
||||
// #target: macos-x64
|
||||
module test;
|
||||
fn int! xy()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
macro int! foo()
|
||||
{
|
||||
xy()?;
|
||||
return 1;
|
||||
}
|
||||
fn void main()
|
||||
{
|
||||
foo()!!;
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
define void @test.main() #0 {
|
||||
entry:
|
||||
%error_var = alloca i64, align 8
|
||||
%blockret = alloca i32, align 4
|
||||
%error_var1 = alloca i64, align 8
|
||||
%retparam = alloca i32, align 4
|
||||
%0 = call i64 @test.xy(i32* %retparam)
|
||||
%not_err = icmp eq i64 %0, 0
|
||||
br i1 %not_err, label %after.errcheck, label %error
|
||||
|
||||
error: ; preds = %entry
|
||||
store i64 %0, i64* %error_var1, align 8
|
||||
br label %guard_block
|
||||
|
||||
after.errcheck: ; preds = %entry
|
||||
br label %noerr_block
|
||||
|
||||
guard_block: ; preds = %error
|
||||
ret void
|
||||
|
||||
noerr_block: ; preds = %after.errcheck
|
||||
store i32 1, i32* %blockret, align 4
|
||||
br label %expr_block.exit
|
||||
|
||||
expr_block.exit: ; preds = %noerr_block
|
||||
%1 = load i32, i32* %blockret, align 4
|
||||
br label %noerr_block2
|
||||
|
||||
noerr_block2: ; preds = %expr_block.exit
|
||||
ret void
|
||||
}
|
||||
@@ -70,7 +70,7 @@ fn void main()
|
||||
@.typeid.int = linkonce constant { i8, i16 } { i8 2, i16 32 }, align 2
|
||||
@.typeid.double = linkonce constant { i8, i16 } { i8 4, i16 64 }, align 2
|
||||
@.typeid.variant = linkonce constant { i8 } { i8 7 }, align 1
|
||||
@".typeid.int*" = linkonce constant { i8, i64 } { i8 15, i64 ptrtoint ({ i8, i16 }* @.typeid.int to i64) }, align 8
|
||||
@".typeid.int*" = linkonce constant { i8, i64 } { i8 19, i64 ptrtoint ({ i8, i16 }* @.typeid.int to i64) }, align 8
|
||||
@.typeid.bool = linkonce constant { i8 } { i8 1 }, align 1
|
||||
|
||||
define void @foo.test(i64 %0, i8* %1) #0 {
|
||||
|
||||
@@ -74,23 +74,23 @@ entry:
|
||||
store i32 3, ptr %3, align 4
|
||||
%4 = insertvalue %"int[]" undef, ptr %literal, 0
|
||||
%5 = insertvalue %"int[]" %4, i64 3, 1
|
||||
%len = extractvalue %"int[]" %5, 1
|
||||
%not = icmp eq i64 %len, 0
|
||||
%6 = zext i1 %not to i8
|
||||
store i8 %6, ptr %x, align 1
|
||||
%7 = getelementptr inbounds %Bar, ptr %b, i32 0, i32 0
|
||||
store i32 0, ptr %7, align 4
|
||||
%8 = getelementptr inbounds %Bar, ptr %b, i32 0, i32 1
|
||||
%6 = extractvalue %"int[]" %5, 1
|
||||
%not = icmp eq i64 %6, 0
|
||||
%7 = zext i1 %not to i8
|
||||
store i8 %7, ptr %x, align 1
|
||||
%8 = getelementptr inbounds %Bar, ptr %b, i32 0, i32 0
|
||||
store i32 0, ptr %8, align 4
|
||||
%9 = getelementptr inbounds %Bar, ptr %b, i32 0, i32 1
|
||||
store i32 0, ptr %9, align 4
|
||||
call void @llvm.memset.p0.i64(ptr align 8 %z, i8 0, i64 8, i1 false)
|
||||
store [0 x i32] zeroinitializer, ptr %literal1, align 4
|
||||
%9 = insertvalue %"int[]" undef, ptr %literal1, 0
|
||||
%10 = insertvalue %"int[]" %9, i64 0, 1
|
||||
store %"int[]" %10, ptr %sub, align 8
|
||||
%10 = insertvalue %"int[]" undef, ptr %literal1, 0
|
||||
%11 = insertvalue %"int[]" %10, i64 0, 1
|
||||
store %"int[]" %11, ptr %sub, align 8
|
||||
store [0 x %Bar] zeroinitializer, ptr %literal2, align 4
|
||||
%11 = insertvalue %"Bar[]" undef, ptr %literal2, 0
|
||||
%12 = insertvalue %"Bar[]" %11, i64 0, 1
|
||||
store %"Bar[]" %12, ptr %foo, align 8
|
||||
%12 = insertvalue %"Bar[]" undef, ptr %literal2, 0
|
||||
%13 = insertvalue %"Bar[]" %12, i64 0, 1
|
||||
store %"Bar[]" %13, ptr %foo, align 8
|
||||
call void @llvm.memset.p0.i64(ptr align 16 %baz, i8 0, i64 24, i1 false)
|
||||
ret i32 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,33 +138,33 @@ entry:
|
||||
store i32 3, ptr %29, align 4
|
||||
%30 = insertvalue %"int[]" undef, ptr %literal6, 0
|
||||
%31 = insertvalue %"int[]" %30, i64 3, 1
|
||||
%len = extractvalue %"int[]" %31, 1
|
||||
%not = icmp eq i64 %len, 0
|
||||
%32 = zext i1 %not to i8
|
||||
store i8 %32, ptr %xy, align 1
|
||||
%33 = load i8, ptr %xy, align 1
|
||||
%34 = trunc i8 %33 to i1
|
||||
%not7 = xor i1 %34, true
|
||||
%32 = extractvalue %"int[]" %31, 1
|
||||
%not = icmp eq i64 %32, 0
|
||||
%33 = zext i1 %not to i8
|
||||
store i8 %33, ptr %xy, align 1
|
||||
%34 = load i8, ptr %xy, align 1
|
||||
%35 = trunc i8 %34 to i1
|
||||
%not7 = xor i1 %35, true
|
||||
br i1 %not7, label %if.then, label %if.exit
|
||||
|
||||
if.then: ; preds = %entry
|
||||
%35 = call i32 @"std::io.println"(ptr @.str.9) #3
|
||||
%36 = call i32 @"std::io.println"(ptr @.str.9) #3
|
||||
br label %if.exit
|
||||
|
||||
if.exit: ; preds = %if.then, %entry
|
||||
%36 = getelementptr inbounds %Bar, ptr %b, i32 0, i32 0
|
||||
store i32 0, ptr %36, align 4
|
||||
%37 = getelementptr inbounds %Bar, ptr %b, i32 0, i32 1
|
||||
%37 = getelementptr inbounds %Bar, ptr %b, i32 0, i32 0
|
||||
store i32 0, ptr %37, align 4
|
||||
%38 = getelementptr inbounds %Bar, ptr %b, i32 0, i32 1
|
||||
store i32 0, ptr %38, align 4
|
||||
call void @llvm.memset.p0.i64(ptr align 8 %z, i8 0, i64 8, i1 false)
|
||||
store [0 x i32] zeroinitializer, ptr %literal8, align 4
|
||||
%38 = insertvalue %"int[]" undef, ptr %literal8, 0
|
||||
%39 = insertvalue %"int[]" %38, i64 0, 1
|
||||
store %"int[]" %39, ptr %sub, align 8
|
||||
%39 = insertvalue %"int[]" undef, ptr %literal8, 0
|
||||
%40 = insertvalue %"int[]" %39, i64 0, 1
|
||||
store %"int[]" %40, ptr %sub, align 8
|
||||
store [0 x %Bar] zeroinitializer, ptr %literal9, align 4
|
||||
%40 = insertvalue %"Bar[]" undef, ptr %literal9, 0
|
||||
%41 = insertvalue %"Bar[]" %40, i64 0, 1
|
||||
store %"Bar[]" %41, ptr %foo, align 8
|
||||
%41 = insertvalue %"Bar[]" undef, ptr %literal9, 0
|
||||
%42 = insertvalue %"Bar[]" %41, i64 0, 1
|
||||
store %"Bar[]" %42, ptr %foo, align 8
|
||||
call void @llvm.memset.p0.i64(ptr align 16 %baz, i8 0, i64 24, i1 false)
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
49
test/test_suite2/macros/macro_failable_return_rethrow.c3t
Normal file
49
test/test_suite2/macros/macro_failable_return_rethrow.c3t
Normal file
@@ -0,0 +1,49 @@
|
||||
// #target: macos-x64
|
||||
module test;
|
||||
fn int! xy()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
macro int! foo()
|
||||
{
|
||||
xy()?;
|
||||
return 1;
|
||||
}
|
||||
fn void main()
|
||||
{
|
||||
foo()!!;
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
define void @test.main() #0 {
|
||||
entry:
|
||||
%error_var = alloca i64, align 8
|
||||
%blockret = alloca i32, align 4
|
||||
%error_var1 = alloca i64, align 8
|
||||
%retparam = alloca i32, align 4
|
||||
%0 = call i64 @test.xy(ptr %retparam)
|
||||
%not_err = icmp eq i64 %0, 0
|
||||
br i1 %not_err, label %after.errcheck, label %error
|
||||
|
||||
error: ; preds = %entry
|
||||
store i64 %0, ptr %error_var1, align 8
|
||||
br label %guard_block
|
||||
|
||||
after.errcheck: ; preds = %entry
|
||||
br label %noerr_block
|
||||
|
||||
guard_block: ; preds = %error
|
||||
ret void
|
||||
|
||||
noerr_block: ; preds = %after.errcheck
|
||||
store i32 1, ptr %blockret, align 4
|
||||
br label %expr_block.exit
|
||||
|
||||
expr_block.exit: ; preds = %noerr_block
|
||||
%1 = load i32, ptr %blockret, align 4
|
||||
br label %noerr_block2
|
||||
|
||||
noerr_block2: ; preds = %expr_block.exit
|
||||
ret void
|
||||
}
|
||||
@@ -70,7 +70,7 @@ fn void main()
|
||||
@.typeid.int = linkonce constant { i8, i16 } { i8 2, i16 32 }, align 2
|
||||
@.typeid.double = linkonce constant { i8, i16 } { i8 4, i16 64 }, align 2
|
||||
@.typeid.variant = linkonce constant { i8 } { i8 7 }, align 1
|
||||
@".typeid.int*" = linkonce constant { i8, i64 } { i8 15, i64 ptrtoint (ptr @.typeid.int to i64) }, align 8
|
||||
@".typeid.int*" = linkonce constant { i8, i64 } { i8 19, i64 ptrtoint (ptr @.typeid.int to i64) }, align 8
|
||||
@.typeid.bool = linkonce constant { i8 } { i8 1 }, align 1
|
||||
|
||||
define void @foo.test(i64 %0, ptr %1) #0 {
|
||||
|
||||
Reference in New Issue
Block a user