fix vector debug info tripping LLVM assertion

This commit is contained in:
Andrew Kelley 2019-02-04 22:14:35 -05:00
parent 8c6fa982cd
commit 06be65a602
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
3 changed files with 7 additions and 6 deletions

View File

@ -4486,8 +4486,9 @@ ZigType *get_vector_type(CodeGen *g, uint32_t len, ZigType *elem_type) {
buf_resize(&entry->name, 0);
buf_appendf(&entry->name, "@Vector(%u, %s)", len, buf_ptr(&elem_type->name));
entry->di_type = ZigLLVMDIBuilderCreateVectorType(g->dbuilder, len,
LLVMABIAlignmentOfType(g->target_data_ref, entry->type_ref), elem_type->di_type);
entry->di_type = ZigLLVMDIBuilderCreateVectorType(g->dbuilder,
len * type_size_bits(g, elem_type),
LLVMABIAlignmentOfType(g->target_data_ref, entry->type_ref), elem_type->di_type, len);
g->type_table.put(type_id, entry);
return entry;

View File

@ -264,12 +264,12 @@ ZigLLVMDIType *ZigLLVMCreateDebugBasicType(ZigLLVMDIBuilder *dibuilder, const ch
}
struct ZigLLVMDIType *ZigLLVMDIBuilderCreateVectorType(struct ZigLLVMDIBuilder *dibuilder,
uint64_t Size, uint32_t AlignInBits, struct ZigLLVMDIType *Ty)
uint64_t SizeInBits, uint32_t AlignInBits, struct ZigLLVMDIType *Ty, uint32_t elem_count)
{
SmallVector<Metadata *, 1> subrange;
subrange.push_back(reinterpret_cast<DIBuilder*>(dibuilder)->getOrCreateSubrange(0, Size));
subrange.push_back(reinterpret_cast<DIBuilder*>(dibuilder)->getOrCreateSubrange(0, elem_count));
DIType *di_type = reinterpret_cast<DIBuilder*>(dibuilder)->createVectorType(
Size,
SizeInBits,
AlignInBits,
reinterpret_cast<DIType*>(Ty),
reinterpret_cast<DIBuilder*>(dibuilder)->getOrCreateArray(subrange));

View File

@ -192,7 +192,7 @@ ZIG_EXTERN_C struct ZigLLVMDISubprogram *ZigLLVMCreateFunction(struct ZigLLVMDIB
unsigned scope_line, unsigned flags, bool is_optimized, struct ZigLLVMDISubprogram *decl_subprogram);
ZIG_EXTERN_C struct ZigLLVMDIType *ZigLLVMDIBuilderCreateVectorType(struct ZigLLVMDIBuilder *dibuilder,
uint64_t Size, uint32_t AlignInBits, struct ZigLLVMDIType *Ty);
uint64_t SizeInBits, uint32_t AlignInBits, struct ZigLLVMDIType *Ty, uint32_t elem_count);
ZIG_EXTERN_C void ZigLLVMFnSetSubprogram(LLVMValueRef fn, struct ZigLLVMDISubprogram *subprogram);