diff --git a/src/compiler/llvm_codegen.c b/src/compiler/llvm_codegen.c index a06cac113..df412872b 100644 --- a/src/compiler/llvm_codegen.c +++ b/src/compiler/llvm_codegen.c @@ -486,8 +486,11 @@ void llvm_emit_global_variable_init(GenContext *c, Decl *decl) } decl->backend_ref = global_ref; - LLVMReplaceAllUsesWith(old, global_ref); - LLVMDeleteGlobal(old); + if (old) + { + LLVMReplaceAllUsesWith(old, global_ref); + LLVMDeleteGlobal(old); + } // Should we set linkage here? if (llvm_use_debug(c)) diff --git a/src/compiler/llvm_codegen_stmt.c b/src/compiler/llvm_codegen_stmt.c index 85dcfa9ec..a977f6518 100644 --- a/src/compiler/llvm_codegen_stmt.c +++ b/src/compiler/llvm_codegen_stmt.c @@ -30,7 +30,7 @@ void llvm_emit_compound_stmt(GenContext *c, Ast *ast) void llvm_emit_local_decl(GenContext *c, Decl *decl, BEValue *value) { // 1. Get the declaration and the LLVM type. - Type *var_type = type_lowering(type_no_optional(decl->type)); + Type *var_type = type_lowering(decl->type); LLVMTypeRef alloc_type = llvm_get_type(c, var_type); // 2. In the case we have a static variable, @@ -45,12 +45,12 @@ void llvm_emit_local_decl(GenContext *c, Decl *decl, BEValue *value) } void *builder = c->builder; c->builder = c->global_builder; - decl->backend_ref = llvm_add_global(c, "tempglobal", var_type, decl->alignment); + decl->backend_ref = llvm_add_global(c, "temp", var_type, decl->alignment); if (IS_OPTIONAL(decl)) { scratch_buffer_clear(); - scratch_buffer_append(decl->extname); - scratch_buffer_append("$f"); + scratch_buffer_append(decl_get_extname(decl)); + scratch_buffer_append(".f"); decl->var.optional_ref = llvm_add_global(c, scratch_buffer_to_string(), type_anyfault, 0); } llvm_emit_global_variable_init(c, decl); diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index 4bd572753..c4bf40ec1 100644 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -2900,7 +2900,7 @@ bool sema_analyse_var_decl(SemaContext *context, Decl *decl, bool local) { scratch_buffer_clear(); scratch_buffer_append(context->call_env.kind == CALL_ENV_FUNCTION ? context->call_env.current_function->name : ".global"); - scratch_buffer_append_char('$'); + scratch_buffer_append_char('.'); scratch_buffer_append(decl->name); decl->extname = scratch_buffer_copy(); } diff --git a/src/version.h b/src/version.h index e73daa72b..e3c1c0d7a 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.549" \ No newline at end of file +#define COMPILER_VERSION "0.4.550" \ No newline at end of file diff --git a/test/test_suite/arrays/global_init.c3t b/test/test_suite/arrays/global_init.c3t index 7bfe9f313..28f0e067e 100644 --- a/test/test_suite/arrays/global_init.c3t +++ b/test/test_suite/arrays/global_init.c3t @@ -33,7 +33,7 @@ fn void main() { @.taddr.9 = private global i32 42, align 4 @.taddr.10 = private global i8 99, align 1 @.taddr.11 = private global %"char[]" { ptr @.str, i64 3 }, align 8 -@"main$x" = internal unnamed_addr global [3 x %any] [%any { ptr @.taddr.9, i64 ptrtoint (ptr @"$ct.int" to i64) }, %any { ptr @.taddr.10, i64 ptrtoint (ptr @"$ct.char" to i64) }, %any { ptr @.taddr.11, i64 ptrtoint (ptr @"$ct.String" to i64) }], align 16 +@main.x = internal unnamed_addr global [3 x %any] [%any { ptr @.taddr.9, i64 ptrtoint (ptr @"$ct.int" to i64) }, %any { ptr @.taddr.10, i64 ptrtoint (ptr @"$ct.char" to i64) }, %any { ptr @.taddr.11, i64 ptrtoint (ptr @"$ct.String" to i64) }], align 16 define void @test.main() #0 { entry: diff --git a/test/test_suite/clang/2002-07.c3t b/test/test_suite/clang/2002-07.c3t index 491063a19..cd1e20a66 100644 --- a/test/test_suite/clang/2002-07.c3t +++ b/test/test_suite/clang/2002-07.c3t @@ -306,7 +306,7 @@ fn int strcmp(char *s1, char *s2) { @foo.remaining = protected unnamed_addr global i32 0, align 4 @foo.ext = local_unnamed_addr global ptr null, align 8 @foo.globalQuad = local_unnamed_addr global %Quad { i32 4, %SubStruct { i16 1, i16 2 }, ptr null, i8 3, i32 156 }, align 8 -@"foo$foo" = internal unnamed_addr global i32 0, align 4 +@foo.foo.10 = internal unnamed_addr global i32 0, align 4 define ptr @foo.passThroughList(ptr %0) #0 { entry: @@ -315,9 +315,9 @@ entry: define void @foo.foo() #0 { entry: - %0 = load i32, ptr @"foo$foo", align 4 + %0 = load i32, ptr @foo.foo.10, align 4 %add = add i32 %0, 1 - store i32 %add, ptr @"foo$foo", align 4 + store i32 %add, ptr @foo.foo.10, align 4 %1 = call ptr @malloc(i32 12) store ptr %1, ptr @foo.data, align 8 ret void @@ -381,8 +381,6 @@ if.exit2: ; preds = %if.exit ret ptr %6 } - - define void @foo.doListStuff() #0 { entry: %myList = alloca ptr, align 8 @@ -444,7 +442,6 @@ or.phi: ; preds = %or.rhs, %entry ret i32 %boolsi } - define ptr @foo.memset_impl(ptr %0, i32 %1, i32 %2) #0 { entry: %len = alloca i32, align 4 @@ -525,7 +522,6 @@ entry: ret double %fadd2 } - define void @foo.__bb_exit_func() #0 { entry: %0 = load ptr, ptr @foo.ext, align 8 @@ -798,7 +794,7 @@ loop.exit: ; preds = %loop.cond define i32 @main(i32 %0, ptr %1) #0 { entry: %i = alloca i32, align 4 - %2 = call i32 @puts(ptr @.str.10) + %2 = call i32 @puts(ptr @.str.11) %trunc = trunc i32 %0 to i16 %3 = call i32 @externFunc(i64 -1, ptr null, i16 signext %trunc, i8 zeroext 2) store i32 0, ptr %i, align 4 diff --git a/test/test_suite/compile_time/compile_time_array_ref.c3t b/test/test_suite/compile_time/compile_time_array_ref.c3t index b6c5341ab..ad4618d9e 100644 --- a/test/test_suite/compile_time/compile_time_array_ref.c3t +++ b/test/test_suite/compile_time/compile_time_array_ref.c3t @@ -14,5 +14,5 @@ fn void test() @foo.stack = local_unnamed_addr global [8192 x i8] zeroinitializer, align 16 @foo.x = local_unnamed_addr global ptr getelementptr (i8, ptr @foo.stack, i64 1000), align 8 -@"test$y" = internal unnamed_addr global [2 x i8] zeroinitializer, align 1 -@"test$z" = internal unnamed_addr global ptr getelementptr inbounds ([2 x i8], ptr @"test$y", i64 0, i64 1), align 8 \ No newline at end of file +@test.y = internal unnamed_addr global [2 x i8] zeroinitializer, align 1 +@test.z = internal unnamed_addr global ptr getelementptr inbounds ([2 x i8], ptr @test.y, i64 0, i64 1), align 8 \ No newline at end of file diff --git a/test/test_suite/defer/defer_static_var.c3t b/test/test_suite/defer/defer_static_var.c3t index 60197edc9..8328429da 100644 --- a/test/test_suite/defer/defer_static_var.c3t +++ b/test/test_suite/defer/defer_static_var.c3t @@ -42,10 +42,10 @@ fn void main() /* #expect: foo.ll -@"foo$y" = internal unnamed_addr global i32 0, align 4 -@"main$y" = internal unnamed_addr global i32 0, align 4 -@"main$y.7" = internal unnamed_addr global i32 0, align 4 -@"main$y.12" = internal unnamed_addr global i32 0, align 4 +@foo.y = internal unnamed_addr global i32 0, align 4 +@main.y = internal unnamed_addr global i32 0, align 4 +@main.y.7 = internal unnamed_addr global i32 0, align 4 +@main.y.12 = internal unnamed_addr global i32 0, align 4 define i32 @foo.foo(i32 %0) #0 { entry: @@ -53,18 +53,18 @@ entry: br i1 %gt, label %if.then, label %if.exit if.then: ; preds = %entry - %1 = load i32, ptr @"foo$y", align 4 + %1 = load i32, ptr @foo.y, align 4 %add = add i32 %1, 1 - store i32 %add, ptr @"foo$y", align 4 - %2 = load i32, ptr @"foo$y", align 4 + store i32 %add, ptr @foo.y, align 4 + %2 = load i32, ptr @foo.y, align 4 call void (ptr, ...) @printf(ptr @.str, i32 %2) ret i32 2 if.exit: ; preds = %entry - %3 = load i32, ptr @"foo$y", align 4 + %3 = load i32, ptr @foo.y, align 4 %add1 = add i32 %3, 1 - store i32 %add1, ptr @"foo$y", align 4 - %4 = load i32, ptr @"foo$y", align 4 + store i32 %add1, ptr @foo.y, align 4 + %4 = load i32, ptr @foo.y, align 4 call void (ptr, ...) @printf(ptr @.str.1, i32 %4) ret i32 %0 } @@ -98,21 +98,21 @@ loop.body: ; preds = %loop.cond br i1 %eq, label %if.then, label %if.exit if.then: ; preds = %loop.body - %7 = load i32, ptr @"main$y", align 4 + %7 = load i32, ptr @main.y, align 4 %add = add i32 %7, 1 - store i32 %add, ptr @"main$y", align 4 + store i32 %add, ptr @main.y, align 4 %8 = load i32, ptr %i, align 4 - %9 = load i32, ptr @"main$y", align 4 + %9 = load i32, ptr @main.y, align 4 call void (ptr, ...) @printf(ptr @.str.3, i32 %8, i32 %9) br label %loop.exit if.exit: ; preds = %loop.body call void (ptr, ...) @printf(ptr @.str.4) - %10 = load i32, ptr @"main$y", align 4 + %10 = load i32, ptr @main.y, align 4 %add1 = add i32 %10, 1 - store i32 %add1, ptr @"main$y", align 4 + store i32 %add1, ptr @main.y, align 4 %11 = load i32, ptr %i, align 4 - %12 = load i32, ptr @"main$y", align 4 + %12 = load i32, ptr @main.y, align 4 call void (ptr, ...) @printf(ptr @.str.5, i32 %11, i32 %12) %13 = load i32, ptr %i, align 4 %add2 = add i32 %13, 1 @@ -138,21 +138,21 @@ loop.body7: ; preds = %loop.cond5 br i1 %eq8, label %if.then9, label %if.exit11 if.then9: ; preds = %loop.body7 - %18 = load i32, ptr @"main$y.7", align 4 + %18 = load i32, ptr @main.y.7, align 4 %add10 = add i32 %18, 1 - store i32 %add10, ptr @"main$y.7", align 4 + store i32 %add10, ptr @main.y.7, align 4 %19 = load i32, ptr %i4, align 4 - %20 = load i32, ptr @"main$y.7", align 4 + %20 = load i32, ptr @main.y.7, align 4 call void (ptr, ...) @printf(ptr @.str.8, i32 %19, i32 %20) br label %loop.exit14 if.exit11: ; preds = %loop.body7 call void (ptr, ...) @printf(ptr @.str.9) - %21 = load i32, ptr @"main$y.7", align 4 + %21 = load i32, ptr @main.y.7, align 4 %add12 = add i32 %21, 1 - store i32 %add12, ptr @"main$y.7", align 4 + store i32 %add12, ptr @main.y.7, align 4 %22 = load i32, ptr %i4, align 4 - %23 = load i32, ptr @"main$y.7", align 4 + %23 = load i32, ptr @main.y.7, align 4 call void (ptr, ...) @printf(ptr @.str.10, i32 %22, i32 %23) %24 = load i32, ptr %i4, align 4 %add13 = add i32 %24, 1 @@ -178,21 +178,21 @@ loop.body19: ; preds = %loop.cond17 br i1 %eq20, label %if.then21, label %if.exit23 if.then21: ; preds = %loop.body19 - %29 = load i32, ptr @"main$y.12", align 4 + %29 = load i32, ptr @main.y.12, align 4 %add22 = add i32 %29, 1 - store i32 %add22, ptr @"main$y.12", align 4 + store i32 %add22, ptr @main.y.12, align 4 %30 = load i32, ptr %i16, align 4 - %31 = load i32, ptr @"main$y.12", align 4 + %31 = load i32, ptr @main.y.12, align 4 call void (ptr, ...) @printf(ptr @.str.13, i32 %30, i32 %31) br label %loop.exit26 if.exit23: ; preds = %loop.body19 call void (ptr, ...) @printf(ptr @.str.14) - %32 = load i32, ptr @"main$y.12", align 4 + %32 = load i32, ptr @main.y.12, align 4 %add24 = add i32 %32, 1 - store i32 %add24, ptr @"main$y.12", align 4 + store i32 %add24, ptr @main.y.12, align 4 %33 = load i32, ptr %i16, align 4 - %34 = load i32, ptr @"main$y.12", align 4 + %34 = load i32, ptr @main.y.12, align 4 call void (ptr, ...) @printf(ptr @.str.15, i32 %33, i32 %34) %35 = load i32, ptr %i16, align 4 %add25 = add i32 %35, 1 diff --git a/test/test_suite/functions/defered_default_arguments.c3t b/test/test_suite/functions/defered_default_arguments.c3t index 39d808cf7..86367a541 100644 --- a/test/test_suite/functions/defered_default_arguments.c3t +++ b/test/test_suite/functions/defered_default_arguments.c3t @@ -42,17 +42,15 @@ entry: %0 = call i32 @test2.foo() call void @test.test(i32 3, i32 %0) call void @test.test(i32 1, i32 32) - %1 = load i32, ptr @"main$x", align 4 + %1 = load i32, ptr @main.x, align 4 %add = add i32 %1, 1 - store i32 %add, ptr @"main$x", align 4 + store i32 %add, ptr @main.x, align 4 %2 = call i32 @test2.foo() call void @test.test(i32 %add, i32 %2) - %3 = load i32, ptr @"main$x.1", align 4 + %3 = load i32, ptr @main.x.1, align 4 %add1 = add i32 %3, 1 - store i32 %add1, ptr @"main$x.1", align 4 + store i32 %add1, ptr @main.x.1, align 4 %4 = call i32 @test2.foo() call void @test.test(i32 %add1, i32 %4) ret void -} - - +} \ No newline at end of file diff --git a/test/test_suite/functions/static_vars.c3t b/test/test_suite/functions/static_vars.c3t index bad77bb22..fdb68c98c 100644 --- a/test/test_suite/functions/static_vars.c3t +++ b/test/test_suite/functions/static_vars.c3t @@ -10,14 +10,14 @@ fn int test() /* #expect: foo.ll -@"test$x" = internal unnamed_addr global i32 1, align 4 -@"test$y" = internal thread_local(localdynamic) unnamed_addr global i32 2, align 4 +@test.x = internal unnamed_addr global i32 1, align 4 +@test.y = internal thread_local(localdynamic) unnamed_addr global i32 2, align 4 define i32 @foo.test() #0 { entry: - %0 = load i32, ptr @"test$x", align 4 + %0 = load i32, ptr @test.x, align 4 %add = add i32 %0, 1 - store i32 %add, ptr @"test$x", align 4 - %1 = load i32, ptr @"test$x", align 4 + store i32 %add, ptr @test.x, align 4 + %1 = load i32, ptr @test.x, align 4 ret i32 %1 -} +} \ No newline at end of file diff --git a/test/test_suite/functions/test_regression.c3t b/test/test_suite/functions/test_regression.c3t index f207aa1c6..88e893ace 100644 --- a/test/test_suite/functions/test_regression.c3t +++ b/test/test_suite/functions/test_regression.c3t @@ -247,10 +247,9 @@ fn Type getValue(Blob blob) @"$ct.test.Blob" = linkonce global %.introspect { i8 10, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 @"$ct.test.Foor" = linkonce global %.introspect { i8 11, ptr null, i64 16, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 @"$ct.test.Foo2" = linkonce global %.introspect { i8 10, ptr null, i64 4, i64 0, i64 1, [0 x i64] zeroinitializer }, align 8 - @"$ct.int" = linkonce global %.introspect { i8 2, ptr null, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 @"$ct.test.MyEnum" = linkonce global { i8, ptr, i64, i64, i64, [3 x %"char[]"] } { i8 8, ptr null, i64 4, i64 ptrtoint (ptr @"$ct.int" to i64), i64 3, [3 x %"char[]"] [%"char[]" { ptr @.enum.0, i64 4 }, %"char[]" { ptr @.enum.1, i64 5 }, %"char[]" { ptr @.enum.2, i64 3 }] }, align 8 -@"test_static$x" = internal unnamed_addr global i32 1, align 4 +@test_static.x = internal unnamed_addr global i32 1, align 4 define void @test.Foo2.printme(ptr %0) #0 { entry: @@ -284,12 +283,12 @@ entry: ; Function Attrs: nounwind define i32 @test.test_static() #0 { entry: - %0 = load i32, ptr @"test_static$x", align 4 + %0 = load i32, ptr @test_static.x, align 4 %add = add i32 %0, 1 - store i32 %add, ptr @"test_static$x", align 4 - %1 = load i32, ptr @"test_static$x", align 4 + store i32 %add, ptr @test_static.x, align 4 + %1 = load i32, ptr @test_static.x, align 4 %2 = call i32 (ptr, ...) @printf(ptr @.str.1, i32 %1) - %3 = load i32, ptr @"test_static$x", align 4 + %3 = load i32, ptr @test_static.x, align 4 ret i32 %3 } diff --git a/test/test_suite/functions/test_regression_mingw.c3t b/test/test_suite/functions/test_regression_mingw.c3t index 717997775..609eaf5b4 100644 --- a/test/test_suite/functions/test_regression_mingw.c3t +++ b/test/test_suite/functions/test_regression_mingw.c3t @@ -244,21 +244,13 @@ fn Type getValue(Blob blob) %LinkedList = type { ptr, i64, ptr, ptr } %List = type { i64, i64, ptr, ptr } %Foo = type { i32, i32 } - $"$ct.test.Bobo" = comdat any - $"$ct.test.Blob" = comdat any - $"$ct.test.Foor" = comdat any - $"$ct.test.Foo2" = comdat any - $"$ct.test.Foo" = comdat any - $"$ct.int" = comdat any - $"$ct.test.MyEnum" = comdat any - @"$ct.test.Bobo" = linkonce global %.introspect { i8 10, ptr null, i64 20, i64 0, i64 6, [0 x i64] zeroinitializer }, comdat, align 8 @"$ct.test.Blob" = linkonce global %.introspect { i8 10, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, comdat, align 8 @"$ct.test.Foor" = linkonce global %.introspect { i8 11, ptr null, i64 16, i64 0, i64 2, [0 x i64] zeroinitializer }, comdat, align 8 @@ -267,7 +259,7 @@ $"$ct.test.MyEnum" = comdat any @"$ct.int" = linkonce global %.introspect { i8 2, ptr null, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, comdat, align 8 @"$ct.test.MyEnum" = linkonce global { i8, ptr, i64, i64, i64, [3 x %"char[]"] } { i8 8, ptr null, i64 4, i64 ptrtoint (ptr @"$ct.int" to i64), i64 3, [3 x %"char[]"] [%"char[]" { ptr @.enum.0, i64 4 }, %"char[]" { ptr @.enum.1, i64 5 }, %"char[]" { ptr @.enum.2, i64 3 }] }, comdat, align 8 @.str = private unnamed_addr constant [13 x i8] c"helloWorld!\0A\00", align 1 -@"test_static$x" = internal unnamed_addr global i32 1, align 4 +@test_static.x = internal unnamed_addr global i32 1, align 4 @.str.1 = private unnamed_addr constant [16 x i8] c"Test static %d\0A\00", align 1 @.__const = private unnamed_addr constant [3 x i32] [i32 1, i32 2, i32 3], align 4 @.str.2 = private unnamed_addr constant [17 x i8] c"Element[%d]: %d\0A\00", align 1 @@ -291,7 +283,6 @@ $"$ct.test.MyEnum" = comdat any @.str.20 = private unnamed_addr constant [13 x i8] c"Vararg0: %d\0A\00", align 1 @.str.21 = private unnamed_addr constant [12 x i8] c"Foo is: %d\0A\00", align 1 @.str.22 = private unnamed_addr constant [9 x i8] c"Mutating\00", align 1 - ; Function Attrs: nounwind define void @test.Foo2.printme(ptr %0) #0 { entry: @@ -300,7 +291,6 @@ entry: %3 = call i32 (ptr, ...) @printf(ptr @.str.21, i32 %2) ret void } - ; Function Attrs: nounwind define i32 @test.Foo2.mutate(ptr %0) #0 { entry: @@ -311,29 +301,25 @@ entry: store i32 %add, ptr %2, align 4 ret i32 %add } - ; Function Attrs: nounwind declare i32 @printf(ptr, ...) #0 - ; Function Attrs: nounwind define void @test.helloWorld() #0 { entry: %0 = call i32 (ptr, ...) @printf(ptr @.str) ret void } - ; Function Attrs: nounwind define i32 @test.test_static() #0 { entry: - %0 = load i32, ptr @"test_static$x", align 4 + %0 = load i32, ptr @test_static.x, align 4 %add = add i32 %0, 1 - store i32 %add, ptr @"test_static$x", align 4 - %1 = load i32, ptr @"test_static$x", align 4 + store i32 %add, ptr @test_static.x, align 4 + %1 = load i32, ptr @test_static.x, align 4 %2 = call i32 (ptr, ...) @printf(ptr @.str.1, i32 %1) - %3 = load i32, ptr @"test_static$x", align 4 + %3 = load i32, ptr @test_static.x, align 4 ret i32 %3 } - ; Function Attrs: nounwind define i32 @test.helo(double %0, ptr align 4 %1) #0 { entry: @@ -346,7 +332,6 @@ entry: %2 = call i32 @test.helo(double 1.000000e+00, ptr align 4 %indirectarg) ret i32 1 } - ; Function Attrs: nounwind define i32 @test.test1(i32 %0, i32 %1) #0 { entry: @@ -358,15 +343,12 @@ entry: store i32 %3, ptr %a, align 4 %gt = icmp sgt i32 %1, 128 br i1 %gt, label %if.then, label %if.exit - if.then: ; preds = %entry ret i32 -1 - if.exit: ; preds = %entry %4 = load i32, ptr %a, align 4 ret i32 %4 } - ; Function Attrs: nounwind define i32 @test.sum_us(ptr align 8 %0) #0 { entry: @@ -377,10 +359,8 @@ entry: %2 = load i64, ptr %1, align 8 %eq = icmp eq i64 0, %2 br i1 %eq, label %if.then, label %if.exit - if.then: ; preds = %entry ret i32 0 - if.exit: ; preds = %entry %3 = load i32, ptr %sum, align 4 %4 = getelementptr inbounds %"int[]", ptr %0, i32 0, i32 0 @@ -404,7 +384,6 @@ if.exit: ; preds = %entry %14 = load i32, ptr %sum, align 4 ret i32 %14 } - ; Function Attrs: nounwind define i32 @test.sumd(ptr align 8 %0) #0 { entry: @@ -413,7 +392,6 @@ entry: store i32 0, ptr %sum, align 4 store i32 0, ptr %i, align 4 br label %loop.cond - loop.cond: ; preds = %loop.body, %entry %1 = load i32, ptr %i, align 4 %sext = sext i32 %1 to i64 @@ -423,7 +401,6 @@ loop.cond: ; preds = %loop.body, %entry %check = icmp slt i64 %3, 0 %siui-lt = or i1 %check, %lt br i1 %siui-lt, label %loop.body, label %loop.exit - loop.body: ; preds = %loop.cond %4 = load i32, ptr %sum, align 4 %5 = getelementptr inbounds %"int[]", ptr %0, i32 0, i32 0 @@ -438,12 +415,10 @@ loop.body: ; preds = %loop.cond %add2 = add i32 %9, 1 store i32 %add2, ptr %i, align 4 br label %loop.cond - loop.exit: ; preds = %loop.cond %10 = load i32, ptr %sum, align 4 ret i32 %10 } - ; Function Attrs: nounwind define void @test.main() #0 { entry: @@ -479,14 +454,12 @@ entry: call void @"std.collections.linkedlist$int$.LinkedList.push"(ptr %list, i32 30) store i32 0, ptr %i, align 4 br label %loop.cond - loop.cond: ; preds = %loop.body, %entry %3 = load i32, ptr %i, align 4 %4 = call i64 @"std.collections.linkedlist$int$.LinkedList.len"(ptr %list) #3 %trunc = trunc i64 %4 to i32 %lt = icmp slt i32 %3, %trunc br i1 %lt, label %loop.body, label %loop.exit - loop.body: ; preds = %loop.cond %5 = load i32, ptr %i, align 4 %6 = load i32, ptr %i, align 4 @@ -497,7 +470,6 @@ loop.body: ; preds = %loop.cond %add = add i32 %9, 1 store i32 %add, ptr %i, align 4 br label %loop.cond - loop.exit: ; preds = %loop.cond call void @"std.collections.linkedlist$int$.LinkedList.free"(ptr %list) %10 = call i32 (ptr, ...) @printf(ptr @.str.3, i32 3) @@ -511,14 +483,12 @@ loop.exit: ; preds = %loop.cond call void @"std.collections.list$int$.List.insert_at"(ptr %array, i64 2, i32 300) store i32 0, ptr %i1, align 4 br label %loop.cond2 - loop.cond2: ; preds = %loop.body5, %loop.exit %12 = load i32, ptr %i1, align 4 %13 = call i64 @"std.collections.list$int$.List.len"(ptr %array) %trunc3 = trunc i64 %13 to i32 %lt4 = icmp slt i32 %12, %trunc3 br i1 %lt4, label %loop.body5, label %loop.exit8 - loop.body5: ; preds = %loop.cond2 %14 = load i32, ptr %i1, align 4 %15 = load i32, ptr %i1, align 4 @@ -529,7 +499,6 @@ loop.body5: ; preds = %loop.cond2 %add7 = add i32 %18, 1 store i32 %add7, ptr %i1, align 4 br label %loop.cond2 - loop.exit8: ; preds = %loop.cond2 call void @"std.collections.list$int$.List.free"(ptr %array) call void @llvm.memcpy.p0.p0.i32(ptr align 4 %a, ptr align 4 @.__const.6, i32 4, i1 false) @@ -602,37 +571,21 @@ loop.exit8: ; preds = %loop.cond2 } declare void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i32, i1 immarg) #1 - declare void @hello_world.hello() #0 - declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2 - declare void @"std.collections.linkedlist$int$.LinkedList.push"(ptr, i32) #0 - declare i64 @"std.collections.linkedlist$int$.LinkedList.len"(ptr) #0 - declare i32 @"std.collections.linkedlist$int$.LinkedList.get"(ptr, i64) #0 - declare void @"std.collections.linkedlist$int$.LinkedList.free"(ptr) #0 - declare void @"std.collections.list$int$.List.append"(ptr, i32) #0 - declare void @"std.collections.list$int$.List.push"(ptr, i32) #0 - declare void @"std.collections.list$int$.List.insert_at"(ptr, i64, i32) #0 - declare i64 @"std.collections.list$int$.List.len"(ptr) #0 - declare i32 @"std.collections.list$int$.List.get"(ptr, i64) #0 - declare void @"std.collections.list$int$.List.free"(ptr) #0 - declare i32 @"test2$int$.getValue"(i32) #0 - declare double @"test2$double$.getValue"(i64) #0 - declare i32 @"test2$int$.getMult"(i32) #0 - declare double @"test2$double$.getMult"(double) #0 // #expect: hello_world.ll diff --git a/test/test_suite/initializer_lists/general_tests.c3t b/test/test_suite/initializer_lists/general_tests.c3t index a479fd4b1..8f815709e 100644 --- a/test/test_suite/initializer_lists/general_tests.c3t +++ b/test/test_suite/initializer_lists/general_tests.c3t @@ -31,7 +31,6 @@ fn int test() /* #expect: general_tests.ll - %Baz = type { double } %Bar = type { i32, i32 } %"int[]" = type { ptr, i64 } @@ -40,7 +39,7 @@ fn int test() @"$ct.general_tests.Baz" = linkonce global %.introspect { i8 11, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 @"$ct.general_tests.Bar" = linkonce global %.introspect { i8 10, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 @.__const = private unnamed_addr constant { i32, [4 x i8] } { i32 1, [4 x i8] undef }, align 8 -@"test$foo1" = internal unnamed_addr global i32 22, align 4 +@test.foo1 = internal unnamed_addr global i32 22, align 4 @.str = private unnamed_addr constant [7 x i8] c"Hello!\00", align 1 ; Function Attrs: nounwind diff --git a/test/test_suite/initializer_lists/statics.c3t b/test/test_suite/initializer_lists/statics.c3t index dacb5e0b1..97947e7d4 100644 --- a/test/test_suite/initializer_lists/statics.c3t +++ b/test/test_suite/initializer_lists/statics.c3t @@ -38,7 +38,7 @@ fn int main() @"$ct.statics.Baz" = linkonce global %.introspect { i8 11, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 @"$ct.statics.Bar" = linkonce global %.introspect { i8 10, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 @.taddr = private global [1 x %Bar] [%Bar { i32 1, i32 2 }], align 8 -@"test$c" = internal unnamed_addr global %"Bar[]" { ptr @.taddr, i64 1 }, align 8 +@test.c = internal unnamed_addr global %"Bar[]" { ptr @.taddr, i64 1 }, align 8 @.str = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1 define void @statics.test() #0 { @@ -58,7 +58,7 @@ entry: %ptroffset = getelementptr inbounds %Bar, ptr %6, i64 0 %7 = getelementptr inbounds %Bar, ptr %ptroffset, i32 0, i32 1 %8 = load i32, ptr %7, align 4 - %9 = load ptr, ptr @"test$c", align 8 + %9 = load ptr, ptr @test.c, align 8 %ptroffset1 = getelementptr inbounds %Bar, ptr %9, i64 0 %10 = getelementptr inbounds %Bar, ptr %ptroffset1, i32 0, i32 1 %11 = load i32, ptr %10, align 4 @@ -70,7 +70,7 @@ entry: %16 = load i32, ptr %15, align 4 %add = add i32 %16, 1 store i32 %add, ptr %15, align 4 - %17 = load ptr, ptr @"test$c", align 8 + %17 = load ptr, ptr @test.c, align 8 %ptroffset3 = getelementptr inbounds %Bar, ptr %17, i64 0 %18 = getelementptr inbounds %Bar, ptr %ptroffset3, i32 0, i32 1 %19 = load i32, ptr %18, align 4 diff --git a/test/test_suite/lambda/ct_lambda.c3t b/test/test_suite/lambda/ct_lambda.c3t index b175096ab..a672c12df 100644 --- a/test/test_suite/lambda/ct_lambda.c3t +++ b/test/test_suite/lambda/ct_lambda.c3t @@ -84,9 +84,8 @@ fn int main() /* #expect: test.ll - -@"init$foo" = internal unnamed_addr global ptr @"test.$global$lambda1", align 8 -@"init$foo.2" = internal unnamed_addr global ptr @"test.$global$lambda2", align 8 +@init.foo = internal unnamed_addr global ptr @"test.$global$lambda1", align 8 +@init.foo.2 = internal unnamed_addr global ptr @"test.$global$lambda2", align 8 ; Function Attrs: nounwind define void @test.Foo.test(ptr %0, i32 %1) #0 { @@ -102,13 +101,11 @@ define void @test.FooTest.init(ptr %0) #0 { entry: %1 = getelementptr inbounds %FooTest, ptr %0, i32 0, i32 0 %2 = getelementptr inbounds %Foo, ptr %1, i32 0, i32 0 - %3 = load ptr, ptr @"init$foo", align 8 + %3 = load ptr, ptr @init.foo, align 8 store ptr %3, ptr %2, align 8 ret void } -; Function Attrs: nounwind - define internal void @"test.$global$lambda1"(ptr %0, i32 %1) #0 { entry: %z = alloca ptr, align 8 diff --git a/test/test_suite/statements/fallthough_do.c3t b/test/test_suite/statements/fallthough_do.c3t index 12684d13b..673695553 100644 --- a/test/test_suite/statements/fallthough_do.c3t +++ b/test/test_suite/statements/fallthough_do.c3t @@ -35,7 +35,7 @@ fn void main() /* #expect: foo.ll -@"test$x" = internal unnamed_addr global i32 0, align 4 +@test.x = internal unnamed_addr global i32 0, align 4 @.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 @.str.1 = private unnamed_addr constant [8 x i8] c"%d, %d\0A\00", align 1 diff --git a/test/test_suite/statements/simple_do.c3t b/test/test_suite/statements/simple_do.c3t index 0683288c1..ee6114f17 100644 --- a/test/test_suite/statements/simple_do.c3t +++ b/test/test_suite/statements/simple_do.c3t @@ -30,16 +30,16 @@ source_filename = "foo" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-darwin" -@"test$x" = internal unnamed_addr global i32 0, align 4 +@test.x = internal unnamed_addr global i32 0, align 4 @.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 @.str.1 = private unnamed_addr constant [8 x i8] c"%d, %d\0A\00", align 1 ; Function Attrs: nounwind define i32 @foo.test() #0 { entry: - %0 = load i32, ptr @"test$x", align 4 + %0 = load i32, ptr @test.x, align 4 %add = add i32 %0, 1 - store i32 %add, ptr @"test$x", align 4 + store i32 %add, ptr @test.x, align 4 %add1 = add i32 1, %0 ret i32 %add1 } diff --git a/test/test_suite/variables/var_init_multi.c3t b/test/test_suite/variables/var_init_multi.c3t index e55193ecf..595f5a311 100644 --- a/test/test_suite/variables/var_init_multi.c3t +++ b/test/test_suite/variables/var_init_multi.c3t @@ -11,10 +11,10 @@ fn int main() /* #expect: test.ll -@"main$sx" = internal unnamed_addr global i32 0, align 4 -@"main$sy" = internal unnamed_addr global i32 0, align 4 -@"main$tx" = internal thread_local(localdynamic) unnamed_addr global i32 0, align 4 -@"main$ty" = internal thread_local(localdynamic) unnamed_addr global i32 0, align 4 +@main.sx = internal unnamed_addr global i32 0, align 4 +@main.sy = internal unnamed_addr global i32 0, align 4 +@main.tx = internal thread_local(localdynamic) unnamed_addr global i32 0, align 4 +@main.ty = internal thread_local(localdynamic) unnamed_addr global i32 0, align 4 entry: %x = alloca i32, align 4