mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-26 07:25:00 -07:00
Remove copy elision code
This commit is contained in:
@@ -1165,7 +1165,7 @@ lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProcedure *start
|
||||
|
||||
for (Entity *e : info->init_procedures) {
|
||||
lbValue value = lb_find_procedure_value_from_entity(main_module, e);
|
||||
lb_emit_call(p, value, {}, ProcInlining_none, false);
|
||||
lb_emit_call(p, value, {}, ProcInlining_none);
|
||||
}
|
||||
|
||||
|
||||
@@ -1243,7 +1243,7 @@ lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *startup_runtime)
|
||||
}
|
||||
|
||||
lbValue startup_runtime_value = {startup_runtime->value, startup_runtime->type};
|
||||
lb_emit_call(p, startup_runtime_value, {}, ProcInlining_none, false);
|
||||
lb_emit_call(p, startup_runtime_value, {}, ProcInlining_none);
|
||||
|
||||
if (build_context.command_kind == Command_test) {
|
||||
Type *t_Internal_Test = find_type_in_pkg(m->info, str_lit("testing"), str_lit("Internal_Test"));
|
||||
@@ -1304,7 +1304,7 @@ lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *startup_runtime)
|
||||
|
||||
if (call_cleanup) {
|
||||
lbValue cleanup_runtime_value = lb_find_runtime_value(m, str_lit("_cleanup_runtime"));
|
||||
lb_emit_call(p, cleanup_runtime_value, {}, ProcInlining_none, false);
|
||||
lb_emit_call(p, cleanup_runtime_value, {}, ProcInlining_none);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-13
@@ -259,12 +259,6 @@ enum lbProcedureFlag : u32 {
|
||||
lbProcedureFlag_DebugAllocaCopy = 1<<1,
|
||||
};
|
||||
|
||||
struct lbCopyElisionHint {
|
||||
lbValue ptr;
|
||||
Ast * ast;
|
||||
bool used;
|
||||
};
|
||||
|
||||
struct lbProcedure {
|
||||
u32 flags;
|
||||
u16 state_flags;
|
||||
@@ -310,8 +304,6 @@ struct lbProcedure {
|
||||
|
||||
LLVMMetadataRef debug_info;
|
||||
|
||||
lbCopyElisionHint copy_elision_hint;
|
||||
|
||||
PtrMap<Ast *, lbValue> selector_values;
|
||||
PtrMap<Ast *, lbAddr> selector_addr;
|
||||
};
|
||||
@@ -383,7 +375,7 @@ lbValue lb_emit_byte_swap(lbProcedure *p, lbValue value, Type *end_type);
|
||||
void lb_emit_defer_stmts(lbProcedure *p, lbDeferExitKind kind, lbBlock *block);
|
||||
lbValue lb_emit_transmute(lbProcedure *p, lbValue value, Type *t);
|
||||
lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue right);
|
||||
lbValue lb_emit_call(lbProcedure *p, lbValue value, Array<lbValue> const &args, ProcInlining inlining = ProcInlining_none, bool use_return_ptr_hint = false);
|
||||
lbValue lb_emit_call(lbProcedure *p, lbValue value, Array<lbValue> const &args, ProcInlining inlining = ProcInlining_none);
|
||||
lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t);
|
||||
lbValue lb_emit_comp_against_nil(lbProcedure *p, TokenKind op_kind, lbValue x);
|
||||
|
||||
@@ -497,10 +489,6 @@ void lb_mem_zero_ptr(lbProcedure *p, LLVMValueRef ptr, Type *type, unsigned alig
|
||||
|
||||
void lb_emit_init_context(lbProcedure *p, lbAddr addr);
|
||||
|
||||
lbCopyElisionHint lb_set_copy_elision_hint(lbProcedure *p, lbAddr const &addr, Ast *ast);
|
||||
void lb_reset_copy_elision_hint(lbProcedure *p, lbCopyElisionHint prev_hint);
|
||||
lbValue lb_consume_copy_elision_hint(lbProcedure *p);
|
||||
|
||||
|
||||
lbStructFieldRemapping lb_get_struct_remapping(lbModule *m, Type *t);
|
||||
LLVMTypeRef lb_type_padding_filler(lbModule *m, i64 padding, i64 padding_align);
|
||||
|
||||
@@ -882,7 +882,7 @@ lbValue lb_emit_conjugate(lbProcedure *p, lbValue val, Type *type) {
|
||||
return lb_emit_load(p, res);
|
||||
}
|
||||
|
||||
lbValue lb_emit_call(lbProcedure *p, lbValue value, Array<lbValue> const &args, ProcInlining inlining, bool use_copy_elision_hint) {
|
||||
lbValue lb_emit_call(lbProcedure *p, lbValue value, Array<lbValue> const &args, ProcInlining inlining) {
|
||||
lbModule *m = p->module;
|
||||
|
||||
Type *pt = base_type(value.type);
|
||||
@@ -981,11 +981,6 @@ lbValue lb_emit_call(lbProcedure *p, lbValue value, Array<lbValue> const &args,
|
||||
Type *rt = reduce_tuple_to_single_type(results);
|
||||
if (return_by_pointer) {
|
||||
lbValue return_ptr = {};
|
||||
if (use_copy_elision_hint && p->copy_elision_hint.ptr.value != nullptr) {
|
||||
if (are_types_identical(type_deref(p->copy_elision_hint.ptr.type), rt)) {
|
||||
return_ptr = lb_consume_copy_elision_hint(p);
|
||||
}
|
||||
}
|
||||
if (return_ptr.value == nullptr) {
|
||||
lbAddr r = lb_add_local_generated(p, rt, true);
|
||||
return_ptr = r.addr;
|
||||
@@ -3032,7 +3027,7 @@ lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr) {
|
||||
}
|
||||
}
|
||||
|
||||
return lb_emit_call(p, value, args, ce->inlining, p->copy_elision_hint.ast == expr);
|
||||
return lb_emit_call(p, value, args, ce->inlining);
|
||||
}
|
||||
|
||||
isize arg_index = 0;
|
||||
@@ -3213,6 +3208,6 @@ lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr) {
|
||||
}
|
||||
|
||||
auto call_args = array_slice(args, 0, final_count);
|
||||
return lb_emit_call(p, value, call_args, ce->inlining, p->copy_elision_hint.ast == expr);
|
||||
return lb_emit_call(p, value, call_args, ce->inlining);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +1,3 @@
|
||||
lbCopyElisionHint lb_set_copy_elision_hint(lbProcedure *p, lbAddr const &addr, Ast *ast) {
|
||||
lbCopyElisionHint prev = p->copy_elision_hint;
|
||||
p->copy_elision_hint.used = false;
|
||||
p->copy_elision_hint.ptr = {};
|
||||
p->copy_elision_hint.ast = nullptr;
|
||||
#if 0
|
||||
if (addr.kind == lbAddr_Default && addr.addr.value != nullptr) {
|
||||
p->copy_elision_hint.ptr = lb_addr_get_ptr(p, addr);
|
||||
p->copy_elision_hint.ast = unparen_expr(ast);
|
||||
}
|
||||
#endif
|
||||
return prev;
|
||||
}
|
||||
|
||||
void lb_reset_copy_elision_hint(lbProcedure *p, lbCopyElisionHint prev_hint) {
|
||||
p->copy_elision_hint = prev_hint;
|
||||
}
|
||||
|
||||
|
||||
lbValue lb_consume_copy_elision_hint(lbProcedure *p) {
|
||||
lbValue return_ptr = p->copy_elision_hint.ptr;
|
||||
p->copy_elision_hint.used = true;
|
||||
p->copy_elision_hint.ptr = {};
|
||||
p->copy_elision_hint.ast = nullptr;
|
||||
return return_ptr;
|
||||
}
|
||||
|
||||
|
||||
void lb_build_constant_value_decl(lbProcedure *p, AstValueDecl *vd) {
|
||||
if (vd == nullptr || vd->is_mutable) {
|
||||
return;
|
||||
@@ -1591,12 +1563,7 @@ void lb_build_assignment(lbProcedure *p, Array<lbAddr> &lvals, Slice<Ast *> cons
|
||||
array_add(&inits, v);
|
||||
}
|
||||
} else {
|
||||
auto prev_hint = lb_set_copy_elision_hint(p, lvals[inits.count], rhs);
|
||||
lbValue init = lb_build_expr(p, rhs);
|
||||
if (p->copy_elision_hint.used) {
|
||||
lvals[inits.count] = {}; // zero lval
|
||||
}
|
||||
lb_reset_copy_elision_hint(p, prev_hint);
|
||||
array_add(&inits, init);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user