Compiler hang with unaligned load-store pair. #2470

This commit is contained in:
Christoffer Lerno
2025-09-09 00:07:45 +02:00
parent a2206f1bcd
commit 3caaf0a3e8
4 changed files with 27 additions and 3 deletions

View File

@@ -18,6 +18,7 @@
- Overloading &[] should be enough for foreach. #2466
- Any register allowed in X86_64 inline asm address. #2463
- int val = some_int + some_distinct_inline_int errors that int cannot be cast to DistinctInt #2468
- Compiler hang with unaligned load-store pair. #2470
### Stdlib changes
- Added generic `InterfaceList` to store a list of values that implement a specific interface

View File

@@ -169,10 +169,9 @@ INLINE void llvm_emit_unaligned_store(GenContext *c, BEValue *result_value, Expr
c->emitting_load_store_check = true;
BEValue value;
llvm_emit_expr(c, &value, expr->call_expr.arguments[0]);
llvm_value_rvalue(c, &value);
llvm_emit_expr(c, result_value, expr->call_expr.arguments[1]);
llvm_value_deref(c, &value);
value.alignment = expr->call_expr.arguments[2]->const_expr.ixx.i.low;
llvm_store(c, &value, result_value);
llvm_store_to_ptr_aligned(c, value.value, result_value, expr->call_expr.arguments[2]->const_expr.ixx.i.low);
c->emitting_load_store_check = emit_check;
}

View File

@@ -1,3 +1,4 @@
// #target: macos-x64
module test;
struct Foo

View File

@@ -0,0 +1,23 @@
// #target: macos-x64
module test;
module test;
import std, libc;
fn void unaligned_load_store(void* dst, void* src) @nostrip
{
$$unaligned_store(dst, $$unaligned_load((char*)src, 2), 2);
}
fn int main()
{
return 0;
}
/* #expect: test.ll
define void @test.unaligned_load_store(ptr %0, ptr %1) #0 {
entry:
%2 = load i8, ptr %1, align 2
store i8 %2, ptr %0, align 2
ret void
}