Skip to content

Conversation

Vexu
Copy link
Member

@Vexu Vexu commented Feb 25, 2020

NumCases in LLVMBuildSwitch is for optimizing memory allocations, so it should be okay to leave out some cases.

Closes #3991

Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just do that in a fixup so that we can land these changes in master faster :)

@@ -3329,9 +3329,21 @@ static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutableGen *executabl
LLVMBasicBlockRef ok_value_block = LLVMAppendBasicBlock(g->cur_fn_val, "OkValue");
size_t field_count = wanted_type->data.enumeration.src_field_count;
LLVMValueRef switch_instr = LLVMBuildSwitch(g->builder, tag_int_value, bad_value_block, field_count);

HashMap<BigInt, Buf *, bigint_hash, bigint_eql> occupied_tag_values = {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you call deinit() after the loop? We're starting to care about these things because of #471

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

extern enums are unsafe
2 participants