From 5c48c89400f61019ffcea72f7262c45f33c184d7 Mon Sep 17 00:00:00 2001 From: Augusto Noronha Date: Thu, 19 Nov 2020 19:13:41 -0300 Subject: [PATCH] Allow the creation of a shadow variable when the type is a refcounted pointer --- lib/IRGen/IRGenSIL.cpp | 2 +- test/IRGen/builtins.swift | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index 349bf71f791e2..2a2b42fd22f3f 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -758,7 +758,7 @@ class IRGenSILFunction : if (IGM.IRGen.Opts.DisableDebuggerShadowCopies || IGM.IRGen.Opts.shouldOptimize() || IsAnonymous || isa(Storage) || isa(Storage) || - Storage->getType() == IGM.RefCountedPtrTy || !needsShadowCopy(Storage)) + !needsShadowCopy(Storage)) return Storage; // Emit a shadow copy. diff --git a/test/IRGen/builtins.swift b/test/IRGen/builtins.swift index 43adb03237981..e14cbc2e01deb 100644 --- a/test/IRGen/builtins.swift +++ b/test/IRGen/builtins.swift @@ -759,9 +759,10 @@ func generic_unsafeGuaranteed_test(_ 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 {