| ... | ... | @@ -350,12 +350,6 @@ static LLVMCallConv get_llvm_cc(CodeGen *g, CallingConvention cc) { |
| 350 | 350 | zig_unreachable(); |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | | static uint32_t get_pref_fn_align(CodeGen *g, LLVMTypeRef fn_type_ref) { |
| 354 | | uint32_t pref_align = LLVMPreferredAlignmentOfType(g->target_data_ref, fn_type_ref); |
| 355 | | uint32_t abi_align = LLVMABIAlignmentOfType(g->target_data_ref, fn_type_ref); |
| 356 | | return (pref_align > abi_align) ? pref_align : abi_align; |
| 357 | | } |
| 358 | | |
| 359 | 353 | static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) { |
| 360 | 354 | if (fn_table_entry->llvm_value) |
| 361 | 355 | return fn_table_entry->llvm_value; |
| ... | ... | @@ -450,12 +444,11 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) { |
| 450 | 444 | } |
| 451 | 445 | if (fn_table_entry->align_bytes > 0) { |
| 452 | 446 | LLVMSetAlignment(fn_table_entry->llvm_value, (unsigned)fn_table_entry->align_bytes); |
| 453 | | } else if (fn_table_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionUnspecified) { |
| 454 | | LLVMSetAlignment(fn_table_entry->llvm_value, |
| 455 | | get_pref_fn_align(g, fn_table_entry->type_entry->data.fn.raw_type_ref)); |
| 456 | 447 | } else { |
| 457 | | LLVMSetAlignment(fn_table_entry->llvm_value, |
| 458 | | LLVMABIAlignmentOfType(g->target_data_ref, fn_table_entry->type_entry->data.fn.raw_type_ref)); |
| 448 | // We'd like to set the best alignment for the function here, but on Darwin LLVM gives |
| 449 | // "Cannot getTypeInfo() on a type that is unsized!" assertion failure when calling |
| 450 | // any of the functions for getting alignment. Not specifying the alignment should |
| 451 | // use the ABI alignment, which is fine. |
| 459 | 452 | } |
| 460 | 453 | |
| 461 | 454 | return fn_table_entry->llvm_value; |
| ... | ... | @@ -814,7 +807,9 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) { |
| 814 | 807 | ZigLLVMAddFunctionAttr(fn_val, "no-frame-pointer-elim", "true"); |
| 815 | 808 | ZigLLVMAddFunctionAttr(fn_val, "no-frame-pointer-elim-non-leaf", nullptr); |
| 816 | 809 | } |
| 817 | | LLVMSetAlignment(fn_val, get_pref_fn_align(g, fn_type_ref)); |
| 810 | // Not setting alignment here. See the comment above about |
| 811 | // "Cannot getTypeInfo() on a type that is unsized!" |
| 812 | // assertion failure on Darwin. |
| 818 | 813 | |
| 819 | 814 | LLVMBasicBlockRef entry_block = LLVMAppendBasicBlock(fn_val, "Entry"); |
| 820 | 815 | LLVMBasicBlockRef prev_block = LLVMGetInsertBlock(g->builder); |