Skip to content

Commit

Permalink
Fix #2261
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerBill committed Sep 30, 2023
1 parent b9cc260 commit f9c6f68
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/llvm_backend_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3513,8 +3513,15 @@ gb_internal lbAddr lb_build_addr_from_entity(lbProcedure *p, Entity *e, Ast *exp
if (e->kind == Entity_Constant) {
Type *t = default_type(type_of_expr(expr));
lbValue v = lb_const_value(p->module, t, e->Constant.value);
lbAddr g = lb_add_global_generated(p->module, t, v);
return g;
if (LLVMIsConstant(v.value)) {
lbAddr g = lb_add_global_generated(p->module, t, v);
return g;
}
GB_ASSERT(LLVMIsALoadInst(v.value));
lbValue ptr = {};
ptr.value = LLVMGetOperand(v.value, 0);
ptr.type = alloc_type_pointer(t);
return lb_addr(ptr);
}


Expand Down

0 comments on commit f9c6f68

Please sign in to comment.