aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-09-14 17:57:12 +0100
committergingerBill <bill@gingerbill.org>2022-09-14 17:57:12 +0100
commita3c04db82831d8d56e4aa4be7c7de6f53286682c (patch)
tree0fd8a7d89f69438d3fab1e55ba72f6106ed426f7 /src/llvm_backend.cpp
parent3ea7af4c9ca716baf48bca029f585d2b9a934ac9 (diff)
Revert "Just get the value directly and store it in another global variable"
This reverts commit 190c3ab0cdc031e45d450e64715452fb2e576d1e.
Diffstat (limited to 'src/llvm_backend.cpp')
-rw-r--r--src/llvm_backend.cpp25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp
index d7f391690..4eb343fa7 100644
--- a/src/llvm_backend.cpp
+++ b/src/llvm_backend.cpp
@@ -758,29 +758,9 @@ lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProcedure *start
GB_ASSERT(e->kind == Entity_Variable);
e->code_gen_module = entity_module;
- Ast *init_expr = unparen_expr(var->decl->init_expr);
+ Ast *init_expr = var->decl->init_expr;
if (init_expr != nullptr) {
- lbValue init = {};
-
- if (!(is_type_any(e->type) || is_type_union(e->type))) {
- if (init_expr->kind == Ast_UnaryExpr && init_expr->UnaryExpr.op.kind == Token_And) {
- // NOTE(bill): Just get the value directly and store it in another global variable
- Ast *expr = unparen_expr(init_expr->UnaryExpr.expr);
- if (expr->tav.value.kind != ExactValue_Invalid) {
- init = lb_build_expr(p, expr);
- GB_ASSERT(init.value != nullptr);
- GB_ASSERT(LLVMIsConstant(init.value));
-
- lbAddr addr = lb_add_global_generated(p->module, init.type, init, nullptr);
- LLVMValueRef global_val = lb_make_global_truly_private(addr);
- LLVMSetInitializer(var->var.value, global_val);
- var->is_initialized = true;
- continue;
- }
- }
- }
-
- init = lb_build_expr(p, init_expr);
+ lbValue init = lb_build_expr(p, init_expr);
if (init.value == nullptr) {
LLVMTypeRef global_type = llvm_addr_type(p->module, var->var);
if (is_type_untyped_undef(init.type)) {
@@ -1608,6 +1588,7 @@ void lb_generate_code(lbGenerator *gen) {
bool is_foreign = e->Variable.is_foreign;
bool is_export = e->Variable.is_export;
+
lbModule *m = &gen->default_module;
String name = lb_get_entity_name(m, e);