diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-08-29 09:30:22 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-08-29 09:30:22 -0400 |
| commit | 8f682efbc5abf4d631f60310f95b998c6fe44669 (patch) | |
| tree | bbb70e115d7cb66f7a29e63128ca6fb19210f599 /src | |
| parent | 1116d82197b46010b80e0e4454abc8881a642947 (diff) | |
| download | zig-8f682efbc5abf4d631f60310f95b998c6fe44669.tar.gz zig-8f682efbc5abf4d631f60310f95b998c6fe44669.zip | |
pass all tests without triggering assertions
fixes tests when targeting darwin
Diffstat (limited to 'src')
| -rw-r--r-- | src/analyze.cpp | 2 | ||||
| -rw-r--r-- | src/codegen.cpp | 19 |
2 files changed, 9 insertions, 12 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 5fcbd92142..c6e0c28b90 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -4812,6 +4812,8 @@ uint32_t get_abi_alignment(CodeGen *g, TypeTableEntry *type_entry) { return type_entry->data.enumeration.abi_alignment; } else if (type_entry->id == TypeTableEntryIdUnion) { zig_panic("TODO"); + } else if (type_entry->id == TypeTableEntryIdOpaque) { + return 1; } else { return LLVMABIAlignmentOfType(g->target_data_ref, type_entry->type_ref); } diff --git a/src/codegen.cpp b/src/codegen.cpp index 840836c622..cd0dc60f00 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -350,12 +350,6 @@ static LLVMCallConv get_llvm_cc(CodeGen *g, CallingConvention cc) { zig_unreachable(); } -static uint32_t get_pref_fn_align(CodeGen *g, LLVMTypeRef fn_type_ref) { - uint32_t pref_align = LLVMPreferredAlignmentOfType(g->target_data_ref, fn_type_ref); - uint32_t abi_align = LLVMABIAlignmentOfType(g->target_data_ref, fn_type_ref); - return (pref_align > abi_align) ? pref_align : abi_align; -} - static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) { if (fn_table_entry->llvm_value) return fn_table_entry->llvm_value; @@ -450,12 +444,11 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) { } if (fn_table_entry->align_bytes > 0) { LLVMSetAlignment(fn_table_entry->llvm_value, (unsigned)fn_table_entry->align_bytes); - } else if (fn_table_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionUnspecified) { - LLVMSetAlignment(fn_table_entry->llvm_value, - get_pref_fn_align(g, fn_table_entry->type_entry->data.fn.raw_type_ref)); } else { - LLVMSetAlignment(fn_table_entry->llvm_value, - LLVMABIAlignmentOfType(g->target_data_ref, fn_table_entry->type_entry->data.fn.raw_type_ref)); + // We'd like to set the best alignment for the function here, but on Darwin LLVM gives + // "Cannot getTypeInfo() on a type that is unsized!" assertion failure when calling + // any of the functions for getting alignment. Not specifying the alignment should + // use the ABI alignment, which is fine. } return fn_table_entry->llvm_value; @@ -814,7 +807,9 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) { ZigLLVMAddFunctionAttr(fn_val, "no-frame-pointer-elim", "true"); ZigLLVMAddFunctionAttr(fn_val, "no-frame-pointer-elim-non-leaf", nullptr); } - LLVMSetAlignment(fn_val, get_pref_fn_align(g, fn_type_ref)); + // Not setting alignment here. See the comment above about + // "Cannot getTypeInfo() on a type that is unsized!" + // assertion failure on Darwin. LLVMBasicBlockRef entry_block = LLVMAppendBasicBlock(fn_val, "Entry"); LLVMBasicBlockRef prev_block = LLVMGetInsertBlock(g->builder); |
