mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Deprecate `fn void! main() type main functions.
This commit is contained in:
@@ -20,7 +20,7 @@ fn void test(void* tptr){
|
||||
iop = tptr; // #error: Casting a 'void*' to 'IOp' is not permitted
|
||||
iop.op();
|
||||
}
|
||||
fn void! main(String[] args) {
|
||||
fn void main(String[] args) {
|
||||
Op(<int>)* t = mem::new(Op(<int>), {.data = 1});
|
||||
test(&t);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ struct Foo
|
||||
int x;
|
||||
}
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
for (usz i = 0; i < 20; i++)
|
||||
{
|
||||
@@ -24,6 +24,7 @@ loop.cond: ; preds = %checkok, %entry
|
||||
%0 = load i64, ptr %i, align 8
|
||||
%gt = icmp ugt i64 20, %0
|
||||
br i1 %gt, label %loop.body, label %loop.exit
|
||||
|
||||
loop.body: ; preds = %loop.cond
|
||||
%1 = load i64, ptr %i, align 8
|
||||
%ge = icmp uge i64 %1, 2
|
||||
@@ -40,7 +41,7 @@ checkok: ; preds = %loop.body
|
||||
br label %loop.cond
|
||||
|
||||
loop.exit: ; preds = %loop.cond
|
||||
ret i64 0
|
||||
ret void
|
||||
|
||||
panic: ; preds = %loop.body
|
||||
store i64 2, ptr %taddr, align 8
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module testing;
|
||||
import std::io;
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
String[] s1;
|
||||
String[] s2;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// #safe: yes
|
||||
module main;
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
for (usz i = 0; i < 100000000; i++)
|
||||
{
|
||||
@@ -12,8 +12,6 @@ fn void! main()
|
||||
|
||||
/* #expect: main.ll
|
||||
|
||||
define i64 @main.main() #0 {
|
||||
entry:
|
||||
%i = alloca i64, align 8
|
||||
%taddr = alloca i64, align 8
|
||||
%varargslots = alloca [2 x %any], align 16
|
||||
@@ -50,6 +48,4 @@ assert_ok: ; preds = %loop.body
|
||||
store i64 %add, ptr %i, align 8
|
||||
br label %loop.cond
|
||||
loop.exit: ; preds = %loop.cond
|
||||
ret i64 0
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,15 @@ bitstruct StructFieldKind : char
|
||||
bool is_union : 1;
|
||||
}
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
StructFieldKind[] xx = { { .is_union = true } };
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
define i64 @test.main() #0 {
|
||||
|
||||
define void @test.main() #0 {
|
||||
entry:
|
||||
%xx = alloca %"char[]", align 8
|
||||
%literal = alloca [1 x i8], align 1
|
||||
@@ -21,5 +22,5 @@ entry:
|
||||
%0 = insertvalue %"char[]" undef, ptr %literal, 0
|
||||
%1 = insertvalue %"char[]" %0, i64 1, 1
|
||||
store %"char[]" %1, ptr %xx, align 8
|
||||
ret i64 0
|
||||
ret void
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// #target: macos-x64
|
||||
module test;
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
Enum e = ENUM1;
|
||||
ushort x = (ushort)Foo{ .x = e };
|
||||
@@ -32,5 +32,3 @@ bitstruct Foo : ushort
|
||||
%zext1 = zext i8 %2 to i16
|
||||
%3 = and i16 %zext1, 255
|
||||
store i16 %3, ptr %z, align 2
|
||||
ret i64 0
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// #target: macos-x64
|
||||
module abc;
|
||||
def UInt8 = char;
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
UInt8 x = 17;
|
||||
UInt8 y = 5;
|
||||
@@ -9,7 +9,6 @@ fn void! main()
|
||||
}
|
||||
/* #expect: abc.ll
|
||||
|
||||
define i64 @abc.main() #0 {
|
||||
entry:
|
||||
%x = alloca i8, align 1
|
||||
%y = alloca i8, align 1
|
||||
@@ -25,5 +24,3 @@ entry:
|
||||
%and = and i32 %2, 1
|
||||
%trunc = trunc i32 %and to i8
|
||||
store i8 %trunc, ptr %z, align 1
|
||||
ret i64 0
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
module testing;
|
||||
import std::io;
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
String[] s1;
|
||||
String[] s2;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
module testing;
|
||||
import std::io;
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
Bits b1;
|
||||
Bits b2;
|
||||
@@ -22,7 +22,6 @@ fn bool Bits.equals(a, Bits b)
|
||||
|
||||
/* #expect: testing.ll
|
||||
|
||||
define i64 @testing.main() #0 {
|
||||
entry:
|
||||
%b1 = alloca i8, align 1
|
||||
%b2 = alloca i8, align 1
|
||||
@@ -39,5 +38,3 @@ entry:
|
||||
%3 = load i8, ptr %b, align 1
|
||||
%4 = call i8 @testing.Bits.equals(i8 zeroext %2, i8 zeroext %3)
|
||||
store i8 %4, ptr %x, align 1
|
||||
ret i64 0
|
||||
}
|
||||
@@ -12,7 +12,7 @@ struct Bcd
|
||||
|
||||
const Abc FOO = { 2 };
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
Bcd a = { FOO };
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ macro check(int a)
|
||||
if (a < 0) return -1; // #error: @ensure
|
||||
return 100;
|
||||
}
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
check(43);
|
||||
}
|
||||
@@ -12,7 +12,7 @@ fn char[]! fileReader(String filename, char[] buffer)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
char[] !buffer = mem::new_array(char, 12);
|
||||
buffer = fileReader("not_found.txt", buffer);
|
||||
@@ -232,7 +232,7 @@ voiderr76: ; preds = %noerr_block74, %gua
|
||||
ret i64 0
|
||||
}
|
||||
; Function Attrs: nounwind uwtable(sync)
|
||||
define i64 @test.main() #0 {
|
||||
define void @test.main() #0 {
|
||||
entry:
|
||||
%buffer = alloca %"char[]", align 8
|
||||
%buffer.f = alloca i64, align 8
|
||||
@@ -254,7 +254,6 @@ entry:
|
||||
%taddr10 = alloca %"any[]", align 8
|
||||
%retparam14 = alloca %"char[]", align 8
|
||||
%taddr15 = alloca %"char[]", align 8
|
||||
%reterr = alloca i64, align 8
|
||||
store ptr null, ptr %.cachedtype, align 8
|
||||
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %allocator, ptr align 8 @std.core.mem.allocator.thread_allocator, i32 16, i1 false)
|
||||
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %allocator1, ptr align 8 %allocator, i32 16, i1 false)
|
||||
@@ -349,36 +348,11 @@ after_check18: ; preds = %after_check13
|
||||
store i64 0, ptr %buffer.f, align 8
|
||||
br label %after_assign
|
||||
after_assign: ; preds = %after_check18, %assign_optional17, %assign_optional12
|
||||
ret i64 0
|
||||
ret void
|
||||
}
|
||||
; Function Attrs: nounwind uwtable(sync)
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) #0 {
|
||||
entry:
|
||||
%blockret = alloca i32, align 4
|
||||
%temp_err = alloca i64, align 8
|
||||
br label %testblock
|
||||
testblock: ; preds = %entry
|
||||
%2 = call i64 @test.main()
|
||||
%not_err = icmp eq i64 %2, 0
|
||||
%3 = call i1 @llvm.expect.i1(i1 %not_err, i1 true)
|
||||
br i1 %3, label %after_check, label %assign_optional
|
||||
assign_optional: ; preds = %testblock
|
||||
store i64 %2, ptr %temp_err, align 8
|
||||
br label %end_block
|
||||
after_check: ; preds = %testblock
|
||||
store i64 0, ptr %temp_err, align 8
|
||||
br label %end_block
|
||||
end_block: ; preds = %after_check, %assign_optional
|
||||
%4 = load i64, ptr %temp_err, align 8
|
||||
%i2b = icmp ne i64 %4, 0
|
||||
br i1 %i2b, label %if.then, label %if.exit
|
||||
if.then: ; preds = %end_block
|
||||
store i32 1, ptr %blockret, align 4
|
||||
br label %expr_block.exit
|
||||
if.exit: ; preds = %end_block
|
||||
store i32 0, ptr %blockret, align 4
|
||||
br label %expr_block.exit
|
||||
expr_block.exit: ; preds = %if.exit, %if.then
|
||||
%5 = load i32, ptr %blockret, align 4
|
||||
ret i32 %5
|
||||
call void @test.main()
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ interface Abc
|
||||
fn void abc();
|
||||
fn void abc(); // #error: Duplicate definition
|
||||
}
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
Abc* g;
|
||||
g.abc();
|
||||
|
||||
@@ -6,7 +6,7 @@ enum Boom: int (String a) {
|
||||
|
||||
module app;
|
||||
import std::io, boom;
|
||||
fn void! main(String[] args) {
|
||||
fn void main(String[] args) {
|
||||
io::printn(Boom.BOOM);
|
||||
}
|
||||
/* #expect: boom.ll
|
||||
|
||||
@@ -2,7 +2,7 @@ module foo;
|
||||
|
||||
struct Foo { int a; }
|
||||
struct Bar { int b; Foo f; }
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
Bar { .f = Foo { foo() } }; // #error: not be discarded
|
||||
}
|
||||
|
||||
@@ -4,20 +4,19 @@ import std;
|
||||
|
||||
def Abc = HashMap(<int, int>);
|
||||
Abc m;
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
m[3] = 100;
|
||||
int! x = m[3]--;
|
||||
assert(m[3]! == 99);
|
||||
assert(x! == 100);
|
||||
assert(m[3]!! == 99);
|
||||
assert(x!! == 100);
|
||||
x = ++m[3];
|
||||
assert(m[3]! == 100);
|
||||
assert(x! == 100);
|
||||
assert(m[3]!! == 100);
|
||||
assert(x!! == 100);
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
define i64 @test.main() #0 {
|
||||
entry:
|
||||
%x = alloca i32, align 4
|
||||
%x.f = alloca i64, align 8
|
||||
@@ -176,44 +175,5 @@ after_check43: ; preds = %after_check39
|
||||
br label %after_assign44
|
||||
|
||||
after_assign44: ; preds = %after_check43, %assign_optional42, %assign_optional38, %optional_assign_jump33, %optional_assign_jump24
|
||||
ret i64 0
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @main(i32 %0, ptr %1) #0 {
|
||||
entry:
|
||||
%blockret = alloca i32, align 4
|
||||
%temp_err = alloca i64, align 8
|
||||
br label %testblock
|
||||
|
||||
testblock: ; preds = %entry
|
||||
%2 = call i64 @test.main()
|
||||
%not_err = icmp eq i64 %2, 0
|
||||
%3 = call i1 @llvm.expect.i1(i1 %not_err, i1 true)
|
||||
br i1 %3, label %after_check, label %assign_optional
|
||||
|
||||
assign_optional: ; preds = %testblock
|
||||
store i64 %2, ptr %temp_err, align 8
|
||||
br label %end_block
|
||||
|
||||
after_check: ; preds = %testblock
|
||||
store i64 0, ptr %temp_err, align 8
|
||||
br label %end_block
|
||||
|
||||
end_block: ; preds = %after_check, %assign_optional
|
||||
%4 = load i64, ptr %temp_err, align 8
|
||||
%i2b = icmp ne i64 %4, 0
|
||||
br i1 %i2b, label %if.then, label %if.exit
|
||||
|
||||
if.then: ; preds = %end_block
|
||||
store i32 1, ptr %blockret, align 4
|
||||
br label %expr_block.exit
|
||||
|
||||
if.exit: ; preds = %end_block
|
||||
store i32 0, ptr %blockret, align 4
|
||||
br label %expr_block.exit
|
||||
|
||||
expr_block.exit: ; preds = %if.exit, %if.then
|
||||
%5 = load i32, ptr %blockret, align 4
|
||||
ret i32 %5
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
module testing;
|
||||
import std::io;
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
bool ok;
|
||||
if (ok && !foo()) io::printfn("nok"); // #error: The expression may not be an optional
|
||||
|
||||
@@ -24,7 +24,7 @@ fn void Foo.add_fn_b(&self, FnB f) => self.bFuncs.push(f);
|
||||
fn void a_func(Foo* foo) {}
|
||||
fn void b_func(Foo* foo) {}
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
Foo foo;
|
||||
defer foo.deinit()!!;
|
||||
@@ -34,7 +34,8 @@ fn void! main()
|
||||
|
||||
/* #expect: repro.ll
|
||||
|
||||
define i64 @repro.main() #0 {
|
||||
|
||||
define void @repro.main() #0 {
|
||||
entry:
|
||||
%foo = alloca %Foo, align 8
|
||||
%error_var = alloca i64, align 8
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module oups;
|
||||
import std::collections::map;
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ fn int iadd(int a, int b) @builtin =>
|
||||
module main;
|
||||
import std::io, add, iadd;
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
io::printfn("%s", iadd(1,2)); // Fine
|
||||
io::printfn("%s", add(<int>)(1,2)); // Error
|
||||
|
||||
@@ -154,12 +154,12 @@ struct Bar
|
||||
String bar;
|
||||
}
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
|
||||
String foo_tmpl = "<<{{foo}} | {{bar}}>>";
|
||||
FooTmpl ft;
|
||||
ft.init(foo_tmpl, using: allocator::temp())!;
|
||||
ft.init(foo_tmpl, using: allocator::temp())!!;
|
||||
defer ft.free()!!;
|
||||
|
||||
|
||||
@@ -167,18 +167,18 @@ fn void! main()
|
||||
|
||||
/* #expect: text_test.ll
|
||||
|
||||
|
||||
|
||||
define i64 @text_test.main() #0 {
|
||||
define void @text_test.main() #0 {
|
||||
entry:
|
||||
%foo_tmpl = alloca %"char[]", align 8
|
||||
%ft = alloca %TextTemplate, align 8
|
||||
%error_var = alloca i64, align 8
|
||||
%indirectarg = alloca %"char[]", align 8
|
||||
%indirectarg1 = alloca %any, align 8
|
||||
%error_var2 = alloca i64, align 8
|
||||
%varargslots = alloca [1 x %any], align 16
|
||||
%indirectarg6 = alloca %"any[]", align 8
|
||||
%indirectarg2 = alloca %"any[]", align 8
|
||||
%error_var3 = alloca i64, align 8
|
||||
%varargslots8 = alloca [1 x %any], align 16
|
||||
%indirectarg10 = alloca %"any[]", align 8
|
||||
store %"char[]" { ptr @.str, i64 21 }, ptr %foo_tmpl, align 8
|
||||
call void @llvm.memset.p0.i64(ptr align 8 %ft, i8 0, i64 72, i1 false)
|
||||
%0 = load ptr, ptr @std.core.mem.allocator.thread_temp_allocator, align 8
|
||||
@@ -205,38 +205,44 @@ if.exit: ; preds = %if.then, %entry
|
||||
|
||||
assign_optional: ; preds = %if.exit
|
||||
store i64 %4, ptr %error_var, align 8
|
||||
br label %guard_block
|
||||
br label %panic_block
|
||||
|
||||
after_check: ; preds = %if.exit
|
||||
br label %noerr_block
|
||||
|
||||
guard_block: ; preds = %assign_optional
|
||||
%6 = load i64, ptr %error_var, align 8
|
||||
ret i64 %6
|
||||
|
||||
noerr_block: ; preds = %after_check
|
||||
%7 = call i64 @"abc$text_test.Foo$.TextTemplate.free"(ptr %ft)
|
||||
%not_err3 = icmp eq i64 %7, 0
|
||||
%8 = call i1 @llvm.expect.i1(i1 %not_err3, i1 true)
|
||||
br i1 %8, label %after_check5, label %assign_optional4
|
||||
|
||||
assign_optional4: ; preds = %noerr_block
|
||||
store i64 %7, ptr %error_var2, align 8
|
||||
br label %panic_block
|
||||
|
||||
after_check5: ; preds = %noerr_block
|
||||
br label %noerr_block7
|
||||
|
||||
panic_block: ; preds = %assign_optional4
|
||||
%9 = insertvalue %any undef, ptr %error_var2, 0
|
||||
%10 = insertvalue %any %9, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
|
||||
store %any %10, ptr %varargslots, align 16
|
||||
%11 = insertvalue %"any[]" undef, ptr %varargslots, 0
|
||||
%"$$temp" = insertvalue %"any[]" %11, i64 1, 1
|
||||
store %"any[]" %"$$temp", ptr %indirectarg6, align 8
|
||||
call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 25
|
||||
panic_block: ; preds = %assign_optional
|
||||
%6 = insertvalue %any undef, ptr %error_var, 0
|
||||
%7 = insertvalue %any %6, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
|
||||
store %any %7, ptr %varargslots, align 16
|
||||
%8 = insertvalue %"any[]" undef, ptr %varargslots, 0
|
||||
%"$$temp" = insertvalue %"any[]" %8, i64 1, 1
|
||||
store %"any[]" %"$$temp", ptr %indirectarg2, align 8
|
||||
call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 25, ptr @.func, i64 4, i32 161, ptr byval(%"any[]") align 8 %indirectarg2)
|
||||
unreachable
|
||||
|
||||
noerr_block7: ; preds = %after_check5
|
||||
ret i64 0
|
||||
noerr_block: ; preds = %after_check
|
||||
%9 = call i64 @"abc$text_test.Foo$.TextTemplate.free"(ptr %ft)
|
||||
%not_err4 = icmp eq i64 %9, 0
|
||||
%10 = call i1 @llvm.expect.i1(i1 %not_err4, i1 true)
|
||||
br i1 %10, label %after_check6, label %assign_optional5
|
||||
|
||||
assign_optional5: ; preds = %noerr_block
|
||||
store i64 %9, ptr %error_var3, align 8
|
||||
br label %panic_block7
|
||||
|
||||
after_check6: ; preds = %noerr_block
|
||||
br label %noerr_block11
|
||||
|
||||
panic_block7: ; preds = %assign_optional5
|
||||
%11 = insertvalue %any undef, ptr %error_var3, 0
|
||||
%12 = insertvalue %any %11, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
|
||||
store %any %12, ptr %varargslots8, align 16
|
||||
%13 = insertvalue %"any[]" undef, ptr %varargslots8, 0
|
||||
%"$$temp9" = insertvalue %"any[]" %13, i64 1, 1
|
||||
store %"any[]" %"$$temp9", ptr %indirectarg10, align 8
|
||||
call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 25, ptr @.func, i64 4, i32 162, ptr byval(%"any[]") align 8 %indirectarg10)
|
||||
unreachable
|
||||
|
||||
noerr_block11: ; preds = %after_check6
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ module foo;
|
||||
import std::io;
|
||||
import std::io; // #error: imported more than
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
io::printn("Hello world");
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
module test;
|
||||
import std::io;
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
int x = run()!; // #error: You cannot cast
|
||||
int x = run()!!; // #error: You cannot cast
|
||||
io::printfn("x=%d", x);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ macro foo_defer()
|
||||
printf("B\n");
|
||||
defer printf("C\n");
|
||||
}
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
foo_defer();
|
||||
@foo_test(34) {
|
||||
@@ -54,10 +54,8 @@ entry:
|
||||
store i32 1, ptr %0, align 4
|
||||
ret i64 0
|
||||
}
|
||||
|
||||
define i64 @foo.main() #0 {
|
||||
define void @foo.main() #0 {
|
||||
entry:
|
||||
%reterr = alloca i64, align 8
|
||||
call void (ptr, ...) @printf(ptr @.str)
|
||||
call void (ptr, ...) @printf(ptr @.str.1)
|
||||
call void (ptr, ...) @printf(ptr @.str.2)
|
||||
@@ -65,61 +63,25 @@ entry:
|
||||
call void (ptr, ...) @printf(ptr @.str.4, i32 34)
|
||||
call void (ptr, ...) @printf(ptr @.str.5, i32 34)
|
||||
br label %loop.body
|
||||
|
||||
loop.body: ; preds = %entry
|
||||
call void (ptr, ...) @printf(ptr @.str.6)
|
||||
call void (ptr, ...) @printf(ptr @.str.7)
|
||||
call void (ptr, ...) @printf(ptr @.str.8, i32 3)
|
||||
call void (ptr, ...) @printf(ptr @.str.9)
|
||||
br label %loop.exit
|
||||
|
||||
loop.exit: ; preds = %loop.body
|
||||
br label %loop.body1
|
||||
|
||||
loop.body1: ; preds = %loop.exit
|
||||
call void (ptr, ...) @printf(ptr @.str.10)
|
||||
call void (ptr, ...) @printf(ptr @.str.11)
|
||||
call void (ptr, ...) @printf(ptr @.str.12)
|
||||
call void (ptr, ...) @printf(ptr @.str.13, i32 3)
|
||||
call void (ptr, ...) @printf(ptr @.str.14)
|
||||
ret i64 0
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) #0 {
|
||||
entry:
|
||||
%blockret = alloca i32, align 4
|
||||
%temp_err = alloca i64, align 8
|
||||
br label %testblock
|
||||
|
||||
testblock: ; preds = %entry
|
||||
%2 = call i64 @foo.main()
|
||||
%not_err = icmp eq i64 %2, 0
|
||||
%3 = call i1 @llvm.expect.i1(i1 %not_err, i1 true)
|
||||
br i1 %3, label %after_check, label %assign_optional
|
||||
|
||||
assign_optional: ; preds = %testblock
|
||||
store i64 %2, ptr %temp_err, align 8
|
||||
br label %end_block
|
||||
|
||||
after_check: ; preds = %testblock
|
||||
store i64 0, ptr %temp_err, align 8
|
||||
br label %end_block
|
||||
|
||||
end_block: ; preds = %after_check, %assign_optional
|
||||
%4 = load i64, ptr %temp_err, align 8
|
||||
%i2b = icmp ne i64 %4, 0
|
||||
br i1 %i2b, label %if.then, label %if.exit
|
||||
|
||||
if.then: ; preds = %end_block
|
||||
store i32 1, ptr %blockret, align 4
|
||||
br label %expr_block.exit
|
||||
|
||||
if.exit: ; preds = %end_block
|
||||
store i32 0, ptr %blockret, align 4
|
||||
br label %expr_block.exit
|
||||
|
||||
expr_block.exit: ; preds = %if.exit, %if.then
|
||||
%5 = load i32, ptr %blockret, align 4
|
||||
ret i32 %5
|
||||
call void @foo.main()
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
module oups;
|
||||
import std::io;
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
ByteReader r;
|
||||
InStream s = &r;
|
||||
s.foo()!;
|
||||
s.foo()!!;
|
||||
}
|
||||
|
||||
macro InStream.foo(&self)
|
||||
@@ -22,8 +22,7 @@ macro InStream.foo(&self)
|
||||
|
||||
/* #expect: oups.ll
|
||||
|
||||
|
||||
define i64 @oups.main() #0 {
|
||||
define void @oups.main() #0 {
|
||||
entry:
|
||||
%r = alloca %ByteReader, align 8
|
||||
%s = alloca %any, align 8
|
||||
@@ -34,6 +33,8 @@ entry:
|
||||
%.cachedtype = alloca ptr, align 8
|
||||
%retparam = alloca i8, align 1
|
||||
%err = alloca i64, align 8
|
||||
%varargslots = alloca [1 x %any], align 16
|
||||
%indirectarg = alloca %"any[]", align 8
|
||||
store ptr null, ptr %.cachedtype, align 8
|
||||
call void @llvm.memset.p0.i64(ptr align 8 %r, i8 0, i64 24, i1 false)
|
||||
%0 = insertvalue %any undef, ptr %r, 0
|
||||
@@ -97,12 +98,18 @@ end_block: ; preds = %after_check4, %assi
|
||||
if.then: ; preds = %end_block
|
||||
%16 = load i64, ptr %err, align 8
|
||||
store i64 %16, ptr %error_var, align 8
|
||||
br label %guard_block
|
||||
br label %panic_block
|
||||
if.exit: ; preds = %end_block
|
||||
br label %noerr_block
|
||||
guard_block: ; preds = %if.then
|
||||
%17 = load i64, ptr %error_var, align 8
|
||||
ret i64 %17
|
||||
panic_block: ; preds = %if.then
|
||||
%17 = insertvalue %any undef, ptr %error_var, 0
|
||||
%18 = insertvalue %any %17, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1
|
||||
store %any %18, ptr %varargslots, align 16
|
||||
%19 = insertvalue %"any[]" undef, ptr %varargslots, 0
|
||||
%"$$temp" = insertvalue %"any[]" %19, i64 1, 1
|
||||
store %"any[]" %"$$temp", ptr %indirectarg, align 8
|
||||
call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 36, ptr @.file, i64 25, ptr @.func, i64 4, i32 8, ptr byval(%"any[]") align 8 %indirectarg)
|
||||
unreachable
|
||||
noerr_block: ; preds = %if.exit
|
||||
ret i64 0
|
||||
ret void
|
||||
}
|
||||
@@ -10,7 +10,7 @@ fn void Data.not_working(self) {
|
||||
fn void Data.working(self) {
|
||||
self.data[:self.data.len];
|
||||
}
|
||||
fn void! main(String[] args) {
|
||||
fn void main(String[] args) {
|
||||
Data d;
|
||||
d.not_working();
|
||||
d.working();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// #target: macos-x64
|
||||
module test;
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
int a;
|
||||
switch (a)
|
||||
@@ -17,7 +17,6 @@ fn void! main()
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
define i64 @test.main() #0 {
|
||||
entry:
|
||||
%a = alloca i32, align 4
|
||||
%switch = alloca i32, align 4
|
||||
@@ -51,5 +50,3 @@ switch.default: ; preds = %next_if4
|
||||
store i32 %sub, ptr %a, align 4
|
||||
br label %switch.exit
|
||||
switch.exit: ; preds = %switch.default
|
||||
ret i64 0
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
module test;
|
||||
import std::io;
|
||||
|
||||
fn void! main()
|
||||
fn void main()
|
||||
{
|
||||
int a;
|
||||
switch (a)
|
||||
|
||||
Reference in New Issue
Block a user