mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 14:18:47 +00:00
Use direct parameter value in lb_find_ident when possible
This commit is contained in:
@@ -298,6 +298,7 @@ struct lbProcedure {
|
|||||||
lbBlock * entry_block;
|
lbBlock * entry_block;
|
||||||
lbBlock * curr_block;
|
lbBlock * curr_block;
|
||||||
lbTargetList * target_list;
|
lbTargetList * target_list;
|
||||||
|
PtrMap<Entity *, lbValue> direct_parameters;
|
||||||
|
|
||||||
Ast *curr_stmt;
|
Ast *curr_stmt;
|
||||||
|
|
||||||
|
|||||||
@@ -2590,6 +2590,15 @@ lbValue lb_find_or_add_entity_string_byte_slice_with_type(lbModule *m, String co
|
|||||||
|
|
||||||
|
|
||||||
lbValue lb_find_ident(lbProcedure *p, lbModule *m, Entity *e, Ast *expr) {
|
lbValue lb_find_ident(lbProcedure *p, lbModule *m, Entity *e, Ast *expr) {
|
||||||
|
if (e->flags & EntityFlag_Param) {
|
||||||
|
// NOTE(bill): Bypass the stack copied variable for
|
||||||
|
// direct parameters as there is no need for the direct load
|
||||||
|
auto *found = map_get(&p->direct_parameters, e);
|
||||||
|
if (found) {
|
||||||
|
return *found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto *found = map_get(&m->values, e);
|
auto *found = map_get(&m->values, e);
|
||||||
if (found) {
|
if (found) {
|
||||||
auto v = *found;
|
auto v = *found;
|
||||||
|
|||||||
@@ -486,6 +486,8 @@ void lb_begin_procedure_body(lbProcedure *p) {
|
|||||||
p->entry_block = lb_create_block(p, "entry", true);
|
p->entry_block = lb_create_block(p, "entry", true);
|
||||||
lb_start_block(p, p->entry_block);
|
lb_start_block(p, p->entry_block);
|
||||||
|
|
||||||
|
map_init(&p->direct_parameters, heap_allocator());
|
||||||
|
|
||||||
GB_ASSERT(p->type != nullptr);
|
GB_ASSERT(p->type != nullptr);
|
||||||
|
|
||||||
lb_ensure_abi_function_type(p->module, p);
|
lb_ensure_abi_function_type(p->module, p);
|
||||||
@@ -539,6 +541,8 @@ void lb_begin_procedure_body(lbProcedure *p) {
|
|||||||
param.value = value;
|
param.value = value;
|
||||||
param.type = e->type;
|
param.type = e->type;
|
||||||
|
|
||||||
|
map_set(&p->direct_parameters, e, param);
|
||||||
|
|
||||||
lbValue ptr = lb_address_from_load_or_generate_local(p, param);
|
lbValue ptr = lb_address_from_load_or_generate_local(p, param);
|
||||||
GB_ASSERT(LLVMIsAAllocaInst(ptr.value));
|
GB_ASSERT(LLVMIsAAllocaInst(ptr.value));
|
||||||
lb_add_entity(p->module, e, ptr);
|
lb_add_entity(p->module, e, ptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user