Fix interface lazy resolution errors. Fix i128 change in LLVM.

This commit is contained in:
Christoffer Lerno
2024-08-11 23:19:01 +02:00
parent 412fa4b12f
commit baf6e71a80
8 changed files with 34 additions and 18 deletions

View File

@@ -214,7 +214,7 @@ jobs:
fail-fast: false
matrix:
build_type: [Release, Debug]
llvm_version: [17, 19, 20]
llvm_version: [17, 18, 19, 20]
steps:
- uses: actions/checkout@v4
@@ -373,7 +373,7 @@ jobs:
fail-fast: false
matrix:
build_type: [Release, Debug]
llvm_version: [17, 19]
llvm_version: [17, 18, 19]
steps:
- uses: actions/checkout@v4
- name: Install common deps

View File

@@ -190,7 +190,6 @@ fn void Object.set_object(&self, String key, Object* new_object) @private
macro Object* Object.object_from_value(&self, value) @private
{
var $Type = $typeof(value);
$switch
$case types::is_int($Type):
return new_int(value, self.allocator);

View File

@@ -64,7 +64,8 @@
- Fix Vec2.angle
- Update to libc::setjmp on Win32, to do no stack unwinding.
- Recursively follow interfaces when looking up method.
- Int128 alignment fixed on x64 Linux.
- Int128 alignment change in LLVM fixed on x64.
- Fix interface lazy resolution errors.
### Stdlib changes

View File

@@ -2179,7 +2179,7 @@ Path *path_create_from_string(const char *string, uint32_t len, SourceSpan span)
void sema_analysis_run(void);
Decl **sema_decl_stack_store(void);
Decl *sema_decl_stack_find_decl_member(Decl *decl_owner, const char *symbol);
Decl *sema_decl_stack_find_decl_member(SemaContext *context, Decl *decl_owner, const char *symbol);
Decl *sema_decl_stack_resolve_symbol(const char *symbol);
void sema_decl_stack_restore(Decl **state);
void sema_decl_stack_push(Decl *decl);

View File

@@ -3357,7 +3357,8 @@ static inline bool sema_expr_analyse_type_access(SemaContext *context, Expr *exp
UNREACHABLE
}
Decl *member = sema_decl_stack_find_decl_member(decl, name);
Decl *member = sema_decl_stack_find_decl_member(context, decl, name);
if (!decl_ok(member)) return false;
if (!member)
{
Decl *ambiguous = NULL;
@@ -3484,7 +3485,8 @@ static inline bool sema_expr_analyse_member_access(SemaContext *context, Expr *e
}
Decl *underlying_type_decl = underlying_type->decl;
Decl *member = sema_decl_stack_find_decl_member(underlying_type_decl, name);
Decl *member = sema_decl_stack_find_decl_member(context, underlying_type_decl, name);
if (!decl_ok(member)) return false;
if (!member || !(decl_is_struct_type(member) || member->decl_kind == DECL_VAR || member->decl_kind == DECL_BITSTRUCT))
{
if (missing_ref) goto MISSING_REF;
@@ -4667,7 +4669,8 @@ CHECK_DEEPER:
// 10. Dump all members and methods into a decl stack.
Decl *decl = type->decl;
Decl *member = sema_decl_stack_find_decl_member(decl, kw);
Decl *member = sema_decl_stack_find_decl_member(context, decl, kw);
if (!decl_ok(member)) return false;
if (member && decl_is_enum_kind(decl) && member->decl_kind == DECL_VAR && sema_cast_const(parent))
{
if (!sema_analyse_decl(context, decl)) return false;
@@ -8090,7 +8093,8 @@ static inline bool sema_expr_analyse_decl_element(SemaContext *context, Designat
}
return false;
}
Decl *member = sema_decl_stack_find_decl_member(actual_type->decl, kw);
Decl *member = sema_decl_stack_find_decl_member(context, actual_type->decl, kw);
if (!decl_ok(member)) return false;
if (!member)
{
Decl *ambiguous = NULL;

View File

@@ -66,16 +66,20 @@ void sema_decl_stack_push(Decl *decl)
compiler.context.decl_stack_top = current;
}
static void add_interface_to_decl_stack(Decl *decl)
static bool add_interface_to_decl_stack(SemaContext *context, Decl *decl)
{
FOREACH(TypeInfo *, parent_interface, decl->interfaces)
{
add_interface_to_decl_stack(parent_interface->type->decl);
if (!sema_resolve_type_info(context, parent_interface, RESOLVE_TYPE_DEFAULT)) return false;
Decl *inf = parent_interface->type->decl;
if (!sema_analyse_decl(context, inf)) return false;
add_interface_to_decl_stack(context, inf);
}
FOREACH(Decl *, interface, decl->interface_methods) sema_decl_stack_push(interface);
return true;
}
static void add_members_to_decl_stack(Decl *decl)
static bool add_members_to_decl_stack(SemaContext *context, Decl *decl)
{
FOREACH(Decl *, func, decl->methods)
{
@@ -93,7 +97,7 @@ static void add_members_to_decl_stack(Decl *decl)
}
if (decl->decl_kind == DECL_INTERFACE)
{
add_interface_to_decl_stack(decl);
if (!add_interface_to_decl_stack(context, decl)) return false;
}
if (decl_is_struct_type(decl) || decl->decl_kind == DECL_BITSTRUCT)
{
@@ -101,18 +105,19 @@ static void add_members_to_decl_stack(Decl *decl)
{
if (member->name == NULL)
{
add_members_to_decl_stack(member);
if (!add_members_to_decl_stack(context, member)) return false;
continue;
}
sema_decl_stack_push(member);
}
}
return true;
}
Decl *sema_decl_stack_find_decl_member(Decl *decl_owner, const char *symbol)
Decl *sema_decl_stack_find_decl_member(SemaContext *context, Decl *decl_owner, const char *symbol)
{
Decl **state = sema_decl_stack_store();
add_members_to_decl_stack(decl_owner);
if (!add_members_to_decl_stack(context, decl_owner)) return poisoned_decl;
Decl *member = sema_decl_stack_resolve_symbol(symbol);
sema_decl_stack_restore(state);
return member;

View File

@@ -1552,6 +1552,11 @@ static AlignData os_target_alignment_of_int(OsType os, ArchType arch, uint32_t b
case ARCH_TYPE_XTENSA:
return (AlignData) { MIN(64u, bits), MIN(64u, bits) };
case ARCH_TYPE_X86_64:
#if LLVM_VERSION_MAJOR < 18
return (AlignData) { MIN(64u, bits), MIN(64u, bits) };
#else
FALLTHROUGH;
#endif
case ARCH_TYPE_RISCV64:
return (AlignData) { bits, bits };
case ARCH_TYPE_AARCH64:
@@ -1560,7 +1565,9 @@ static AlignData os_target_alignment_of_int(OsType os, ArchType arch, uint32_t b
return (AlignData) { bits, bits };
case ARCH_TYPE_X86:
if (bits <= 32) return (AlignData) { bits, bits };
#if LLVM_VERSION_MAJOR > 17
if (bits == 128) return (AlignData) { 128, 128 };
#endif
if (os == OS_TYPE_ELFIAMCU) return (AlignData) { 32, 32 };
if (os == OS_TYPE_WIN32 || os == OS_TYPE_NACL) return (AlignData) { 64, 64 };
return (AlignData) { 32, 64 };

View File

@@ -26,5 +26,5 @@ const int128 I128 = 0b0100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_000
@test.I = local_unnamed_addr constant i32 1073741824, align 4
@test.UL = local_unnamed_addr constant i64 -9223372036854775808, align 8
@test.L = local_unnamed_addr constant i64 4611686018427387904, align 8
@test.UI128 = local_unnamed_addr constant i128 -170141183460469231731687303715884105728, align 16
@test.I128 = local_unnamed_addr constant i128 85070591730234615865843651857942052864, align 16
@test.UI128 = local_unnamed_addr constant i128 -170141183460469231731687303715884105728,
@test.I128 = local_unnamed_addr constant i128 85070591730234615865843651857942052864,