Skip to content

Allow the creation of a shadow variable when the type is a refcounted pointer #34835

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
merged 1 commit into from
Nov 30, 2020
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
2 changes: 1 addition & 1 deletion lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ class IRGenSILFunction :
if (IGM.IRGen.Opts.DisableDebuggerShadowCopies ||
IGM.IRGen.Opts.shouldOptimize() || IsAnonymous ||
isa<llvm::AllocaInst>(Storage) || isa<llvm::UndefValue>(Storage) ||
Storage->getType() == IGM.RefCountedPtrTy || !needsShadowCopy(Storage))
!needsShadowCopy(Storage))
return Storage;

// Emit a shadow copy.
Expand Down
5 changes: 3 additions & 2 deletions test/IRGen/builtins.swift
Original file line number Diff line number Diff line change
Expand Up @@ -759,9 +759,10 @@ func generic_unsafeGuaranteed_test<T: AnyObject>(_ t : T) -> T {
}

// CHECK-LABEL: define {{.*}} @{{.*}}unsafeGuaranteed_test
// CHECK: [[LOCAL:%.*]] = alloca %swift.refcounted*
// CHECK: [[LOCAL1:%.*]] = alloca %swift.refcounted*
// CHECK: [[LOCAL2:%.*]] = alloca %swift.refcounted*
// CHECK: call %swift.refcounted* @swift_retain(%swift.refcounted* returned %0)
// CHECK: store %swift.refcounted* %0, %swift.refcounted** [[LOCAL]]
// CHECK: store %swift.refcounted* %0, %swift.refcounted** [[LOCAL2]]
// CHECK-NOT: call void @swift_release(%swift.refcounted* %0)
// CHECK: ret %swift.refcounted* %0
func unsafeGuaranteed_test(_ x: Builtin.NativeObject) -> Builtin.NativeObject {
Expand Down