Pass 'small_struct_ints'

This commit is contained in:
David Gonzalez Martin 2025-06-13 13:41:51 -06:00
parent 9e1856d4c5
commit 45fab3dd29
2 changed files with 45 additions and 12 deletions

View File

@ -7172,7 +7172,26 @@ contains_no_user_data = fn (type: &Type, start: u64, end: u64) u1
.struct =>
{
result = 1;
#trap();
>fields = type.content.struct.fields;
for (&field: fields)
{
>field_offset = field.offset;
if (field_offset >= end)
{
break;
}
>field_start = #select(field_offset < start, start - field_offset, 0);
if (!contains_no_user_data(field.type, field_start, end - field_offset))
{
result = 0;
break;
}
}
},
.array, .enum_array =>
{
@ -12952,9 +12971,24 @@ emit = fn (module: &Module) void
}
}
else
{
>source: &LLVMValue = zero;
if (function_type.abi.return_abi.attributes.direct.offset == 0)
{
source = return_alloca;
}
else
{
#trap();
}
assert(source != zero);
>source_type = function_type.abi.return_abi.semantic_type;
>destination_type = coerce_to_type;
>result = create_coerced_load(module, source, source_type, destination_type);
return_value = result;
}
},
.indirect =>
{
@ -13329,6 +13363,7 @@ names: [_][]u8 =
"return_u64_u64",
"select",
"slice",
"small_struct_ints",
];
[export] main = fn [cc(c)] (argument_count: u32, argv: &&u8, envp: &&u8) s32

View File

@ -609,21 +609,19 @@ fn bool contains_no_user_data(Type* type, u64 start, u64 end)
{
case TypeId::structure:
{
u64 offset = 0;
for (auto& field: type->structure.fields)
{
if (offset >= end)
auto field_offset = field.offset;
if (field_offset >= end)
{
break;
}
auto field_start = offset < start ? start - offset : 0;
if (!contains_no_user_data(field.type, field_start, end - offset))
auto field_start = field_offset < start ? start - field_offset : 0;
if (!contains_no_user_data(field.type, field_start, end - field_offset))
{
return false;
}
offset += get_byte_size(field.type);
}
return true;