mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Force call site attributes for procedures (relating to #2121 causing ABI issues for intrinsics.objc_send)
This commit is contained in:
+16
-16
@@ -550,10 +550,10 @@ namespace lbAbiAmd64SysV {
|
|||||||
if (is_mem_cls(cls, attribute_kind)) {
|
if (is_mem_cls(cls, attribute_kind)) {
|
||||||
LLVMAttributeRef attribute = nullptr;
|
LLVMAttributeRef attribute = nullptr;
|
||||||
if (attribute_kind == Amd64TypeAttribute_ByVal) {
|
if (attribute_kind == Amd64TypeAttribute_ByVal) {
|
||||||
if (!is_calling_convention_odin(calling_convention)) {
|
// if (!is_calling_convention_odin(calling_convention)) {
|
||||||
return lb_arg_type_indirect_byval(c, type);
|
return lb_arg_type_indirect_byval(c, type);
|
||||||
}
|
// }
|
||||||
attribute = nullptr;
|
// attribute = nullptr;
|
||||||
} else if (attribute_kind == Amd64TypeAttribute_StructRect) {
|
} else if (attribute_kind == Amd64TypeAttribute_StructRect) {
|
||||||
attribute = lb_create_enum_attribute_with_type(c, "sret", type);
|
attribute = lb_create_enum_attribute_with_type(c, "sret", type);
|
||||||
}
|
}
|
||||||
@@ -983,12 +983,12 @@ namespace lbAbiArm64 {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned is_homogenous_aggregate_small_enough(LLVMTypeRef *base_type_, unsigned member_count_) {
|
unsigned is_homogenous_aggregate_small_enough(LLVMTypeRef base_type, unsigned member_count) {
|
||||||
return (member_count_ <= 4);
|
return (member_count <= 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
lbArgType compute_return_type(LLVMContextRef c, LLVMTypeRef type, bool return_is_defined) {
|
lbArgType compute_return_type(LLVMContextRef c, LLVMTypeRef type, bool return_is_defined) {
|
||||||
LLVMTypeRef homo_base_type = {};
|
LLVMTypeRef homo_base_type = nullptr;
|
||||||
unsigned homo_member_count = 0;
|
unsigned homo_member_count = 0;
|
||||||
|
|
||||||
if (!return_is_defined) {
|
if (!return_is_defined) {
|
||||||
@@ -996,16 +996,16 @@ namespace lbAbiArm64 {
|
|||||||
} else if (is_register(type)) {
|
} else if (is_register(type)) {
|
||||||
return non_struct(c, type);
|
return non_struct(c, type);
|
||||||
} else if (is_homogenous_aggregate(c, type, &homo_base_type, &homo_member_count)) {
|
} else if (is_homogenous_aggregate(c, type, &homo_base_type, &homo_member_count)) {
|
||||||
if(is_homogenous_aggregate_small_enough(&homo_base_type, homo_member_count)) {
|
if (is_homogenous_aggregate_small_enough(homo_base_type, homo_member_count)) {
|
||||||
return lb_arg_type_direct(type, LLVMArrayType(homo_base_type, homo_member_count), nullptr, nullptr);
|
return lb_arg_type_direct(type, LLVMArrayType(homo_base_type, homo_member_count), nullptr, nullptr);
|
||||||
} else {
|
} else {
|
||||||
//TODO(Platin): do i need to create stuff that can handle the diffrent return type?
|
//TODO(Platin): do i need to create stuff that can handle the diffrent return type?
|
||||||
// else this needs a fix in llvm_backend_proc as we would need to cast it to the correct array type
|
// else this needs a fix in llvm_backend_proc as we would need to cast it to the correct array type
|
||||||
|
|
||||||
//LLVMTypeRef array_type = LLVMArrayType(homo_base_type, homo_member_count);
|
//LLVMTypeRef array_type = LLVMArrayType(homo_base_type, homo_member_count);
|
||||||
LLVMAttributeRef attr = lb_create_enum_attribute_with_type(c, "sret", type);
|
LLVMAttributeRef attr = lb_create_enum_attribute_with_type(c, "sret", type);
|
||||||
return lb_arg_type_indirect(type, attr);
|
return lb_arg_type_indirect(type, attr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
i64 size = lb_sizeof(type);
|
i64 size = lb_sizeof(type);
|
||||||
if (size <= 16) {
|
if (size <= 16) {
|
||||||
|
|||||||
@@ -753,12 +753,16 @@ lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue return_ptr,
|
|||||||
}
|
}
|
||||||
GB_ASSERT_MSG(lb_is_type_kind(fnp, LLVMFunctionTypeKind), "%s", LLVMPrintTypeToString(fnp));
|
GB_ASSERT_MSG(lb_is_type_kind(fnp, LLVMFunctionTypeKind), "%s", LLVMPrintTypeToString(fnp));
|
||||||
|
|
||||||
|
lbFunctionType *ft = map_must_get(&p->module->function_type_map, base_type(value.type));
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned param_count = LLVMCountParamTypes(fnp);
|
unsigned param_count = LLVMCountParamTypes(fnp);
|
||||||
GB_ASSERT(arg_count >= param_count);
|
GB_ASSERT(arg_count >= param_count);
|
||||||
|
|
||||||
LLVMTypeRef *param_types = gb_alloc_array(temporary_allocator(), LLVMTypeRef, param_count);
|
LLVMTypeRef *param_types = gb_alloc_array(temporary_allocator(), LLVMTypeRef, param_count);
|
||||||
LLVMGetParamTypes(fnp, param_types);
|
LLVMGetParamTypes(fnp, param_types);
|
||||||
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < param_count; i++) {
|
for (unsigned i = 0; i < param_count; i++) {
|
||||||
LLVMTypeRef param_type = param_types[i];
|
LLVMTypeRef param_type = param_types[i];
|
||||||
LLVMTypeRef arg_type = LLVMTypeOf(args[i]);
|
LLVMTypeRef arg_type = LLVMTypeOf(args[i]);
|
||||||
@@ -776,10 +780,20 @@ lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue return_ptr,
|
|||||||
|
|
||||||
LLVMValueRef ret = LLVMBuildCall2(p->builder, fnp, fn, args, arg_count, "");
|
LLVMValueRef ret = LLVMBuildCall2(p->builder, fnp, fn, args, arg_count, "");
|
||||||
|
|
||||||
|
LLVMAttributeIndex param_offset = LLVMAttributeIndex_FirstArgIndex;
|
||||||
if (return_ptr.value != nullptr) {
|
if (return_ptr.value != nullptr) {
|
||||||
|
param_offset += 1;
|
||||||
|
|
||||||
LLVMAddCallSiteAttribute(ret, 1, lb_create_enum_attribute_with_type(p->module->ctx, "sret", LLVMTypeOf(args[0])));
|
LLVMAddCallSiteAttribute(ret, 1, lb_create_enum_attribute_with_type(p->module->ctx, "sret", LLVMTypeOf(args[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for_array(i, ft->args) {
|
||||||
|
LLVMAttributeRef attribute = ft->args[i].attribute;
|
||||||
|
if (attribute != nullptr) {
|
||||||
|
LLVMAddCallSiteAttribute(ret, param_offset + cast(LLVMAttributeIndex)i, attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (inlining) {
|
switch (inlining) {
|
||||||
case ProcInlining_none:
|
case ProcInlining_none:
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user