Skip to content

🍒Fix LoadableByAddress assert: missing case. #73354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/IRGen/LoadableByAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3051,6 +3051,7 @@ void LoadableByAddress::run() {
builtinInstrs.insert(instr);
break;
}
case SILInstructionKind::StructInst:
case SILInstructionKind::DebugValueInst:
break;
default:
Expand Down
25 changes: 25 additions & 0 deletions test/IRGen/big_types.sil
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ sil @use_big_struct : $@convention(thin) (BigStruct) -> ()

sil @takeClosure : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> ()) -> ()

typealias Invocation = @convention(thin) (BigStruct) -> ()

struct InvocationWrapper {
let invocation: Invocation
}

sil_global hidden [let] @invocation : $InvocationWrapper

sil @invocationClosure : $@convention(thin) (BigStruct) -> ()

// CHECK-LABEL: sil_global @globalWithClosureInStruct : $ContainsClosure = {
// CHECK: %0 = function_ref @make_big_struct : $@convention(thin) () -> @out BigStruct
// CHECK-NEXT: %1 = thin_to_thick_function %0 : $@convention(thin) () -> @out BigStruct to $@callee_guaranteed () -> @out BigStruct
Expand Down Expand Up @@ -158,3 +168,18 @@ bb0(%0 : @closureCapture $BigStruct):
%2 = tuple ()
return %2 : $()
}

// Test a rewritten function_ref stored in a struct property.
// CHECK-LABEL: sil [global_init_once_fn] @test_invocation : $@convention(c) (Builtin.RawPointer) -> () {
// CHECK: [[F:%[0-9]+]] = function_ref @invocationClosure : $@convention(thin) (@in_guaranteed BigStruct) -> ()
// CHECK: = struct $InvocationWrapper ([[F]] : $@convention(thin) (@in_guaranteed BigStruct) -> ())
sil [global_init_once_fn] @test_invocation : $@convention(c) (Builtin.RawPointer) -> () {
bb0(%0 : $Builtin.RawPointer):
alloc_global @invocation
%g = global_addr @invocation : $*InvocationWrapper
%f = function_ref @invocationClosure : $@convention(thin) (BigStruct) -> ()
%s = struct $InvocationWrapper (%f : $@convention(thin) (BigStruct) -> ())
store %s to %g : $*InvocationWrapper
%r = tuple ()
return %r : $()
}