From ff4591f0e61266da6cac47644986d381b99dec5b Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 4 Sep 2018 12:14:38 -0400 Subject: fix llvm assertion when adding callsite sret attr --- src/codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/codegen.cpp b/src/codegen.cpp index 298e89579f..a15ecbaf6e 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3106,7 +3106,7 @@ static void gen_set_stack_pointer(CodeGen *g, LLVMValueRef aligned_end_addr) { static void set_call_instr_sret(CodeGen *g, LLVMValueRef call_instr) { unsigned attr_kind_id = LLVMGetEnumAttributeKindForName("sret", 4); - LLVMAttributeRef sret_attr = LLVMCreateEnumAttribute(LLVMGetGlobalContext(), attr_kind_id, 1); + LLVMAttributeRef sret_attr = LLVMCreateEnumAttribute(LLVMGetGlobalContext(), attr_kind_id, 0); LLVMAddCallSiteAttribute(call_instr, 1, sret_attr); } -- cgit v1.2.3 From 36828a2e6aa6879641bf6980379dd806b6f479a1 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 4 Sep 2018 12:50:02 -0400 Subject: fix incorrect variable ref count regression introduced by e82cd53df483a --- src/all_types.hpp | 1 - src/ir.cpp | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/all_types.hpp b/src/all_types.hpp index d580191afe..fd8801f994 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -1806,7 +1806,6 @@ struct VariableTableEntry { IrExecutable *owner_exec; size_t ref_count; VarLinkage linkage; - IrInstruction *decl_instruction; uint32_t align_bytes; // In an inline loop, multiple variables may be created, diff --git a/src/ir.cpp b/src/ir.cpp index 8bf0e710b3..5ac321c0f3 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -1446,8 +1446,6 @@ static IrInstruction *ir_build_var_decl(IrBuilder *irb, Scope *scope, AstNode *s if (align_value) ir_ref_instruction(align_value, irb->current_basic_block); ir_ref_instruction(init_value, irb->current_basic_block); - var->decl_instruction = &decl_var_instruction->base; - return &decl_var_instruction->base; } @@ -12433,8 +12431,6 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc return var->value->type; } - var->ref_count = 0; - TypeTableEntry *explicit_type = nullptr; IrInstruction *var_type = nullptr; if (decl_var_instruction->var_type != nullptr) { @@ -12503,6 +12499,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc VariableTableEntry *new_var = create_local_var(ira->codegen, var->decl_node, var->child_scope, &var->name, var->src_is_const, var->gen_is_const, var->shadowable, var->is_comptime, true); new_var->owner_exec = var->owner_exec; + new_var->align_bytes = var->align_bytes; if (var->mem_slot_index != SIZE_MAX) { ConstExprValue *vals = create_const_vals(1); new_var->mem_slot_index = ira->exec_context.mem_slot_list.length; @@ -12513,6 +12510,9 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc var = new_var; } + // This must be done after possibly creating a new variable above + var->ref_count = 0; + var->value->type = result_type; assert(var->value->type); -- cgit v1.2.3