Files
sx/tests/expected/ffi-objc-call-03-selector-sharing.ir
agra b69a2ea29c mem: Step 8 — delete context global from std.sx
The `context : Context = ---;` global in `library/modules/std.sx` had
no remaining readers — all `context.X` lookups in user code resolve
through `current_ctx_ref` (Step 5), `push Context.{...}` uses an alloca
slot (Step 6), and `allocViaContext` sources from the lowering's
current ref. `emitDefaultContextInit` (the only writer) was already
removed in Step 5.

`inferExprType` for the `context` identifier now returns the registered
`Context` type when implicit-ctx is enabled, mirroring the lowering's
identifier-handling fast path. Without this, `context.allocator` would
type as `s64` (the fallback) and the field access would fail.

11 JNI/ObjC IR snapshots regen — the `@context` LLVM global is gone
from each.

152/152 example tests pass.
2026-05-25 09:13:36 +03:00

395 lines
12 KiB
Plaintext

@OS = internal global i64 0
@ARCH = internal global i64 0
@POINTER_SIZE = internal global i64 8
@__sx_default_context = internal global { { ptr, ptr, ptr }, ptr } { { ptr, ptr, ptr } { ptr null, ptr @__thunk_CAllocator_Allocator_alloc, ptr @__thunk_CAllocator_Allocator_dealloc }, ptr null }
@OBJC_SELECTOR_REFERENCES_init = internal global ptr null
@OBJC_SELECTOR_REFERENCES_release = internal global ptr null
@str = private unnamed_addr constant [4 x i8] c"ok\0A\00", align 1
@str.1 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
@OBJC_METH_VAR_NAME_ = private unnamed_addr constant [5 x i8] c"init\00"
@OBJC_METH_VAR_NAME_.2 = private unnamed_addr constant [8 x i8] c"release\00"
@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @__sx_objc_selector_init, ptr null }]
; Function Attrs: nounwind
declare void @out(ptr) #0
declare ptr @malloc(i64)
declare void @free(ptr)
declare ptr @memcpy(ptr, ptr, i64)
declare ptr @memset(ptr, i32, i64)
; Function Attrs: nounwind
define internal ptr @CAllocator.alloc(ptr %0, ptr %1, i64 %2) #0 {
entry:
%alloca = alloca ptr, align 8
store ptr %1, ptr %alloca, align 8
%allocaN = alloca i64, align 8
store i64 %2, ptr %allocaN, align 8
%load = load i64, ptr %allocaN, align 8
%call = call ptr @malloc(i64 %load)
ret ptr %call
}
; Function Attrs: nounwind
define internal void @CAllocator.dealloc(ptr %0, ptr %1, ptr %2) #0 {
entry:
%alloca = alloca ptr, align 8
store ptr %1, ptr %alloca, align 8
%allocaN = alloca ptr, align 8
store ptr %2, ptr %allocaN, align 8
%load = load ptr, ptr %allocaN, align 8
call void @free(ptr %load)
ret void
}
; Function Attrs: nounwind
declare ptr @GPA.init(ptr) #0
; Function Attrs: nounwind
declare ptr @GPA.alloc(ptr, ptr, i64) #0
; Function Attrs: nounwind
declare void @GPA.dealloc(ptr, ptr, ptr) #0
; Function Attrs: nounwind
declare void @Arena.add_chunk(ptr, ptr, i64) #0
; Function Attrs: nounwind
declare ptr @Arena.init(ptr, ptr, i64) #0
; Function Attrs: nounwind
declare void @Arena.reset(ptr, ptr) #0
; Function Attrs: nounwind
declare void @Arena.deinit(ptr, ptr) #0
; Function Attrs: nounwind
declare ptr @Arena.alloc(ptr, ptr, i64) #0
; Function Attrs: nounwind
declare void @Arena.dealloc(ptr, ptr, ptr) #0
; Function Attrs: nounwind
declare ptr @BufAlloc.init(ptr, ptr, i64) #0
; Function Attrs: nounwind
declare void @BufAlloc.reset(ptr, ptr) #0
; Function Attrs: nounwind
declare ptr @BufAlloc.alloc(ptr, ptr, i64) #0
; Function Attrs: nounwind
declare void @BufAlloc.dealloc(ptr, ptr, ptr) #0
; Function Attrs: nounwind
declare ptr @TrackingAllocator.init(ptr, ptr) #0
; Function Attrs: nounwind
declare i64 @TrackingAllocator.leak_count(ptr, ptr) #0
; Function Attrs: nounwind
declare void @TrackingAllocator.report(ptr, ptr) #0
; Function Attrs: nounwind
declare ptr @TrackingAllocator.alloc(ptr, ptr, i64) #0
; Function Attrs: nounwind
declare void @TrackingAllocator.dealloc(ptr, ptr, ptr) #0
; Function Attrs: nounwind
define internal { ptr, i64 } @cstring(ptr %0, i64 %1) #0 {
entry:
%alloca = alloca i64, align 8
store i64 %1, ptr %alloca, align 8
%load = load i64, ptr %alloca, align 8
%add = add i64 %load, 1
%heap = call ptr @malloc(i64 %add)
%allocaN = alloca ptr, align 8
store ptr %heap, ptr %allocaN, align 8
%loadN = load ptr, ptr %allocaN, align 8
%loadN = load i64, ptr %alloca, align 8
%addN = add i64 %loadN, 1
%2 = call ptr @memset(ptr %loadN, i32 0, i64 %addN)
%allocaN = alloca { ptr, i64 }, align 8
store { ptr, i64 } undef, ptr %allocaN, align 8
%loadN = load ptr, ptr %allocaN, align 8
%gep = getelementptr inbounds { ptr, i64 }, ptr %allocaN, i32 0, i32 0
%pti = ptrtoint ptr %loadN to i64
store i64 %pti, ptr %gep, align 8
%loadN = load i64, ptr %alloca, align 8
%gepN = getelementptr inbounds { ptr, i64 }, ptr %allocaN, i32 0, i32 1
store i64 %loadN, ptr %gepN, align 8
%loadN = load { ptr, i64 }, ptr %allocaN, align 8
ret { ptr, i64 } %loadN
}
; Function Attrs: nounwind
declare ptr @int_to_string(ptr, i64) #0
; Function Attrs: nounwind
declare ptr @bool_to_string(ptr, i1) #0
; Function Attrs: nounwind
declare ptr @float_to_string(ptr, double) #0
; Function Attrs: nounwind
declare void @hex_group(ptr, ptr, i64, i64) #0
; Function Attrs: nounwind
declare ptr @int_to_hex_string(ptr, i64) #0
; Function Attrs: nounwind
define internal { ptr, i64 } @concat(ptr %0, { ptr, i64 } %1, { ptr, i64 } %2) #0 {
entry:
%alloca = alloca { ptr, i64 }, align 8
store { ptr, i64 } %1, ptr %alloca, align 8
%allocaN = alloca { ptr, i64 }, align 8
store { ptr, i64 } %2, ptr %allocaN, align 8
%load = load { ptr, i64 }, ptr %alloca, align 8
%len = extractvalue { ptr, i64 } %load, 1
%allocaN = alloca i64, align 8
store i64 %len, ptr %allocaN, align 8
%loadN = load { ptr, i64 }, ptr %allocaN, align 8
%lenN = extractvalue { ptr, i64 } %loadN, 1
%allocaN = alloca i64, align 8
store i64 %lenN, ptr %allocaN, align 8
%loadN = load i64, ptr %allocaN, align 8
%loadN = load i64, ptr %allocaN, align 8
%add = add i64 %loadN, %loadN
%call = call { ptr, i64 } @cstring(ptr %0, i64 %add)
%allocaN = alloca { ptr, i64 }, align 8
store { ptr, i64 } %call, ptr %allocaN, align 8
%loadN = load { ptr, i64 }, ptr %allocaN, align 8
%dptr = extractvalue { ptr, i64 } %loadN, 0
%loadN = load { ptr, i64 }, ptr %alloca, align 8
%dptrN = extractvalue { ptr, i64 } %loadN, 0
%loadN = load i64, ptr %allocaN, align 8
%callN = call ptr @memcpy(ptr %dptr, ptr %dptrN, i64 %loadN)
%loadN = load i64, ptr %allocaN, align 8
%loadN = load { ptr, i64 }, ptr %allocaN, align 8
%igp.data = extractvalue { ptr, i64 } %loadN, 0
%igp.ptr = getelementptr i8, ptr %igp.data, i64 %loadN
%loadN = load { ptr, i64 }, ptr %allocaN, align 8
%dptrN = extractvalue { ptr, i64 } %loadN, 0
%loadN = load i64, ptr %allocaN, align 8
%callN = call ptr @memcpy(ptr %igp.ptr, ptr %dptrN, i64 %loadN)
%loadN = load { ptr, i64 }, ptr %allocaN, align 8
ret { ptr, i64 } %loadN
}
; Function Attrs: nounwind
define internal { ptr, i64 } @substr(ptr %0, { ptr, i64 } %1, i64 %2, i64 %3) #0 {
entry:
%alloca = alloca { ptr, i64 }, align 8
store { ptr, i64 } %1, ptr %alloca, align 8
%allocaN = alloca i64, align 8
store i64 %2, ptr %allocaN, align 8
%allocaN = alloca i64, align 8
store i64 %3, ptr %allocaN, align 8
%load = load i64, ptr %allocaN, align 8
%call = call { ptr, i64 } @cstring(ptr %0, i64 %load)
%allocaN = alloca { ptr, i64 }, align 8
store { ptr, i64 } %call, ptr %allocaN, align 8
%loadN = load { ptr, i64 }, ptr %allocaN, align 8
%dptr = extractvalue { ptr, i64 } %loadN, 0
%loadN = load i64, ptr %allocaN, align 8
%loadN = load { ptr, i64 }, ptr %alloca, align 8
%igp.data = extractvalue { ptr, i64 } %loadN, 0
%igp.ptr = getelementptr i8, ptr %igp.data, i64 %loadN
%loadN = load i64, ptr %allocaN, align 8
%callN = call ptr @memcpy(ptr %dptr, ptr %igp.ptr, i64 %loadN)
%loadN = load { ptr, i64 }, ptr %allocaN, align 8
ret { ptr, i64 } %loadN
}
; Function Attrs: nounwind
declare ptr @xml_escape(ptr, ptr) #0
; Function Attrs: nounwind
declare ptr @path_join(ptr, ptr) #0
; Function Attrs: nounwind
declare ptr @any_to_string(ptr, [2 x i64]) #0
; Function Attrs: nounwind
declare ptr @build_format(ptr, ptr) #0
; Function Attrs: nounwind
declare void @BuildOptions.add_link_flag(i64, ptr) #0
; Function Attrs: nounwind
declare void @BuildOptions.add_framework(i64, ptr) #0
; Function Attrs: nounwind
declare void @BuildOptions.set_output_path(i64, ptr) #0
; Function Attrs: nounwind
declare void @BuildOptions.set_wasm_shell(i64, ptr) #0
; Function Attrs: nounwind
declare void @BuildOptions.add_asset_dir(i64, ptr, ptr) #0
; Function Attrs: nounwind
declare i64 @BuildOptions.asset_dir_count(i64) #0
; Function Attrs: nounwind
declare ptr @BuildOptions.asset_dir_src_at(i64, i64) #0
; Function Attrs: nounwind
declare ptr @BuildOptions.asset_dir_dest_at(i64, i64) #0
; Function Attrs: nounwind
declare void @BuildOptions.set_post_link_callback(i64, ptr) #0
; Function Attrs: nounwind
declare void @BuildOptions.set_post_link_module(i64, ptr) #0
; Function Attrs: nounwind
declare ptr @BuildOptions.binary_path(i64) #0
; Function Attrs: nounwind
declare void @BuildOptions.set_bundle_path(i64, ptr) #0
; Function Attrs: nounwind
declare void @BuildOptions.set_bundle_id(i64, ptr) #0
; Function Attrs: nounwind
declare void @BuildOptions.set_codesign_identity(i64, ptr) #0
; Function Attrs: nounwind
declare void @BuildOptions.set_provisioning_profile(i64, ptr) #0
; Function Attrs: nounwind
declare ptr @BuildOptions.bundle_path(i64) #0
; Function Attrs: nounwind
declare ptr @BuildOptions.bundle_id(i64) #0
; Function Attrs: nounwind
declare ptr @BuildOptions.codesign_identity(i64) #0
; Function Attrs: nounwind
declare ptr @BuildOptions.provisioning_profile(i64) #0
; Function Attrs: nounwind
declare ptr @BuildOptions.target_triple(i64) #0
; Function Attrs: nounwind
declare i1 @BuildOptions.is_macos(i64) #0
; Function Attrs: nounwind
declare i1 @BuildOptions.is_ios(i64) #0
; Function Attrs: nounwind
declare i1 @BuildOptions.is_ios_device(i64) #0
; Function Attrs: nounwind
declare i1 @BuildOptions.is_ios_simulator(i64) #0
; Function Attrs: nounwind
declare i1 @BuildOptions.is_android(i64) #0
; Function Attrs: nounwind
declare i64 @BuildOptions.framework_count(i64) #0
; Function Attrs: nounwind
declare ptr @BuildOptions.framework_at(i64, i64) #0
; Function Attrs: nounwind
declare i64 @BuildOptions.framework_path_count(i64) #0
; Function Attrs: nounwind
declare ptr @BuildOptions.framework_path_at(i64, i64) #0
; Function Attrs: nounwind
declare void @BuildOptions.set_manifest_path(i64, ptr) #0
; Function Attrs: nounwind
declare void @BuildOptions.set_keystore_path(i64, ptr) #0
; Function Attrs: nounwind
declare ptr @BuildOptions.manifest_path(i64) #0
; Function Attrs: nounwind
declare ptr @BuildOptions.keystore_path(i64) #0
; Function Attrs: nounwind
declare i64 @BuildOptions.jni_main_count(i64) #0
; Function Attrs: nounwind
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
; Function Attrs: nounwind
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
; Function Attrs: nounwind
declare i64 @build_options() #0
; Function Attrs: nounwind
define i32 @main() #0 {
entry:
call void @__sx_objc_selector_init()
%load = load ptr, ptr @OBJC_SELECTOR_REFERENCES_init, align 8
call void @objc_msgSend(ptr null, ptr %load)
%loadN = load ptr, ptr @OBJC_SELECTOR_REFERENCES_init, align 8
call void @objc_msgSend(ptr null, ptr %loadN)
%loadN = load ptr, ptr @OBJC_SELECTOR_REFERENCES_init, align 8
call void @objc_msgSend(ptr null, ptr %loadN)
%loadN = load ptr, ptr @OBJC_SELECTOR_REFERENCES_release, align 8
call void @objc_msgSend(ptr null, ptr %loadN)
%alloca = alloca { ptr, i64 }, align 8
%gep = getelementptr inbounds { ptr, i64 }, ptr %alloca, i32 0, i32 0
store ptr null, ptr %gep, align 8
%gepN = getelementptr inbounds { ptr, i64 }, ptr %alloca, i32 0, i32 1
store i64 0, ptr %gepN, align 8
%allocaN = alloca { ptr, i64 }, align 8
store { ptr, i64 } { ptr @str, i64 3 }, ptr %allocaN, align 8
%allocaN = alloca { ptr, i64 }, align 8
store { ptr, i64 } { ptr @str.1, i64 0 }, ptr %allocaN, align 8
%loadN = load { ptr, i64 }, ptr %allocaN, align 8
%loadN = load { ptr, i64 }, ptr %allocaN, align 8
%call = call { ptr, i64 } @substr(ptr @__sx_default_context, { ptr, i64 } %loadN, i64 0, i64 3)
%callN = call { ptr, i64 } @concat(ptr @__sx_default_context, { ptr, i64 } %loadN, { ptr, i64 } %call)
store { ptr, i64 } %callN, ptr %allocaN, align 8
%loadN = load { ptr, i64 }, ptr %allocaN, align 8
%str.ptr = extractvalue { ptr, i64 } %loadN, 0
%str.len = extractvalue { ptr, i64 } %loadN, 1
%0 = call i64 @write(i32 1, ptr %str.ptr, i64 %str.len)
ret i32 0
}
; Function Attrs: nounwind
define internal ptr @__thunk_CAllocator_Allocator_alloc(ptr %0, ptr %1, i64 %2) #0 {
entry:
%call = call ptr @CAllocator.alloc(ptr %0, ptr %1, i64 %2)
ret ptr %call
}
; Function Attrs: nounwind
define internal void @__thunk_CAllocator_Allocator_dealloc(ptr %0, ptr %1, ptr %2) #0 {
entry:
call void @CAllocator.dealloc(ptr %0, ptr %1, ptr %2)
ret void
}
declare ptr @objc_msgSend(ptr, ptr)
declare i64 @write(i32, ptr, i64)
declare ptr @sel_registerName(ptr)
define internal void @__sx_objc_selector_init() {
entry:
%sel = call ptr @sel_registerName(ptr @OBJC_METH_VAR_NAME_)
store ptr %sel, ptr @OBJC_SELECTOR_REFERENCES_init, align 8
%selN = call ptr @sel_registerName(ptr @OBJC_METH_VAR_NAME_.2)
store ptr %selN, ptr @OBJC_SELECTOR_REFERENCES_release, align 8
ret void
}