Variable in if-try / if-catch cannot be a reused variable name.

This commit is contained in:
Christoffer Lerno
2024-08-05 18:43:04 +02:00
parent 67a2734777
commit 746016996c
6 changed files with 106 additions and 193 deletions

View File

@@ -6,7 +6,6 @@ fn void main()
{
int a;
defer { if (catch e = test()) {} }
anyfault b;
defer { if (catch b = test()) {} }
if (a > 0) return;
}
@@ -16,74 +15,92 @@ entry:
%a = alloca i32, align 4
%b = alloca i64, align 8
%e = alloca i64, align 8
%e13 = alloca i64, align 8
%b7 = alloca i64, align 8
%e14 = alloca i64, align 8
store i32 0, ptr %a, align 4
store i64 0, ptr %b, align 8
%0 = load i32, ptr %a, align 4
%gt = icmp sgt i32 %0, 0
br i1 %gt, label %if.then, label %if.exit
if.then: ; preds = %entry
br label %testblock
testblock: ; preds = %if.then
%1 = call i64 @test.test()
%not_err = icmp eq i64 %1, 0
%2 = call i1 @llvm.expect.i1(i1 %not_err, i1 true)
br i1 %2, label %after_check, label %assign_optional
assign_optional: ; preds = %testblock
store i64 %1, ptr %b, align 8
br label %end_block
after_check: ; preds = %testblock
store i64 0, ptr %b, align 8
br label %end_block
end_block: ; preds = %after_check, %assign_optional
%3 = load i64, ptr %b, align 8
%neq = icmp ne i64 %3, 0
br label %testblock1
testblock1: ; preds = %end_block
%4 = call i64 @test.test()
%not_err2 = icmp eq i64 %4, 0
%5 = call i1 @llvm.expect.i1(i1 %not_err2, i1 true)
br i1 %5, label %after_check4, label %assign_optional3
assign_optional3: ; preds = %testblock1
store i64 %4, ptr %e, align 8
br label %end_block5
after_check4: ; preds = %testblock1
store i64 0, ptr %e, align 8
br label %end_block5
end_block5: ; preds = %after_check4, %assign_optional3
%6 = load i64, ptr %e, align 8
%neq6 = icmp ne i64 %6, 0
ret void
if.exit: ; preds = %entry
br label %testblock7
testblock7: ; preds = %if.exit
br label %testblock8
testblock8: ; preds = %if.exit
%7 = call i64 @test.test()
%not_err8 = icmp eq i64 %7, 0
%8 = call i1 @llvm.expect.i1(i1 %not_err8, i1 true)
br i1 %8, label %after_check10, label %assign_optional9
assign_optional9: ; preds = %testblock7
store i64 %7, ptr %b, align 8
br label %end_block11
after_check10: ; preds = %testblock7
store i64 0, ptr %b, align 8
br label %end_block11
end_block11: ; preds = %after_check10, %assign_optional9
%9 = load i64, ptr %b, align 8
%neq12 = icmp ne i64 %9, 0
br label %testblock14
testblock14: ; preds = %end_block11
%not_err9 = icmp eq i64 %7, 0
%8 = call i1 @llvm.expect.i1(i1 %not_err9, i1 true)
br i1 %8, label %after_check11, label %assign_optional10
assign_optional10: ; preds = %testblock8
store i64 %7, ptr %b7, align 8
br label %end_block12
after_check11: ; preds = %testblock8
store i64 0, ptr %b7, align 8
br label %end_block12
end_block12: ; preds = %after_check11, %assign_optional10
%9 = load i64, ptr %b7, align 8
%neq13 = icmp ne i64 %9, 0
br label %testblock15
testblock15: ; preds = %end_block12
%10 = call i64 @test.test()
%not_err15 = icmp eq i64 %10, 0
%11 = call i1 @llvm.expect.i1(i1 %not_err15, i1 true)
br i1 %11, label %after_check17, label %assign_optional16
assign_optional16: ; preds = %testblock14
store i64 %10, ptr %e13, align 8
br label %end_block18
after_check17: ; preds = %testblock14
store i64 0, ptr %e13, align 8
br label %end_block18
end_block18: ; preds = %after_check17, %assign_optional16
%12 = load i64, ptr %e13, align 8
%neq19 = icmp ne i64 %12, 0
%not_err16 = icmp eq i64 %10, 0
%11 = call i1 @llvm.expect.i1(i1 %not_err16, i1 true)
br i1 %11, label %after_check18, label %assign_optional17
assign_optional17: ; preds = %testblock15
store i64 %10, ptr %e14, align 8
br label %end_block19
after_check18: ; preds = %testblock15
store i64 0, ptr %e14, align 8
br label %end_block19
end_block19: ; preds = %after_check18, %assign_optional17
%12 = load i64, ptr %e14, align 8
%neq20 = icmp ne i64 %12, 0
ret void
}
}

View File

@@ -18,7 +18,6 @@ fn void main()
{
printf("Test\n");
}
anyfault e;
if (catch e = z)
{
printf("Oh noes!\n");
@@ -27,7 +26,6 @@ fn void main()
/* #expect: try_assign.ll
define void @try_assign.main() #0 {
entry:
%x = alloca i32, align 4
@@ -125,7 +123,6 @@ if.then17: ; preds = %phi_try_catch15
br label %if.exit18
if.exit18: ; preds = %if.then17, %phi_try_catch15
store i64 0, ptr %e, align 8
br label %testblock
testblock: ; preds = %if.exit18

View File

@@ -87,7 +87,6 @@ fn void test9()
{
int! z = 234;
int! w = 123;
anyfault e;
if (catch e = z)
{
}