mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Improve basic escape analysis
This commit is contained in:
+4
-7
@@ -1400,7 +1400,7 @@ bool check_expr_is_stack_variable(Ast *expr) {
|
|||||||
expr = unparen_expr(expr);
|
expr = unparen_expr(expr);
|
||||||
Entity *e = entity_of_node(expr);
|
Entity *e = entity_of_node(expr);
|
||||||
if (e && e->kind == Entity_Variable) {
|
if (e && e->kind == Entity_Variable) {
|
||||||
if (e->flags & (EntityFlag_Static|EntityFlag_Using)) {
|
if (e->flags & (EntityFlag_Static|EntityFlag_Using|EntityFlag_ImplicitReference|EntityFlag_ForValue)) {
|
||||||
// okay
|
// okay
|
||||||
} else if (e->Variable.thread_local_model.len != 0) {
|
} else if (e->Variable.thread_local_model.len != 0) {
|
||||||
// okay
|
// okay
|
||||||
@@ -1941,13 +1941,10 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) {
|
|||||||
}
|
}
|
||||||
if (found == nullptr) {
|
if (found == nullptr) {
|
||||||
entity = alloc_entity_variable(ctx->scope, token, type, EntityState_Resolved);
|
entity = alloc_entity_variable(ctx->scope, token, type, EntityState_Resolved);
|
||||||
|
entity->flags |= EntityFlag_ForValue;
|
||||||
entity->flags |= EntityFlag_Value;
|
entity->flags |= EntityFlag_Value;
|
||||||
if (i == addressable_index) {
|
if (i == addressable_index && use_by_reference_for_value) {
|
||||||
if (use_by_reference_for_value) {
|
entity->flags &= ~EntityFlag_Value;
|
||||||
entity->flags &= ~EntityFlag_Value;
|
|
||||||
} else {
|
|
||||||
entity->flags |= EntityFlag_ForValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (is_soa) {
|
if (is_soa) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user