Skip to content

Commit 36c951d

Browse files
authored
Revert "[DebugInfo] Ignore noescape bit for all @convention(c) pointers"
1 parent 0213f2d commit 36c951d

22 files changed

+83
-83
lines changed

include/swift/AST/ExtInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ class ASTExtInfoBuilder {
358358

359359
constexpr Representation getRepresentation() const {
360360
unsigned rawRep = bits & RepresentationMask;
361+
assert(rawRep <= unsigned(Representation::Last) &&
362+
"unexpected SIL representation");
361363
return Representation(rawRep);
362364
}
363365

lib/AST/ASTContext.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "swift/AST/DiagnosticsSema.h"
2525
#include "swift/AST/DistributedDecl.h"
2626
#include "swift/AST/ExistentialLayout.h"
27-
#include "swift/AST/ExtInfo.h"
2827
#include "swift/AST/FileUnit.h"
2928
#include "swift/AST/ForeignAsyncConvention.h"
3029
#include "swift/AST/ForeignErrorConvention.h"
@@ -3682,16 +3681,6 @@ FunctionType *FunctionType::get(ArrayRef<AnyFunctionType::Param> params,
36823681
auto properties = getFunctionRecursiveProperties(params, result, globalActor);
36833682
auto arena = getArena(properties);
36843683

3685-
if (info.hasValue()) {
3686-
// Canonicalize all thin functions to be escaping (to keep compatibility
3687-
// with generic parameters). Note that one can pass SIL-level representation
3688-
// here, so we need additional check for maximum non-SIL value.
3689-
Representation rep = info.getValue().getRepresentation();
3690-
if (rep <= FunctionTypeRepresentation::Last &&
3691-
isThinRepresentation(rep))
3692-
info = info->withNoEscape(false);
3693-
}
3694-
36953684
llvm::FoldingSetNodeID id;
36963685
FunctionType::Profile(id, params, result, info);
36973686

@@ -4109,10 +4098,6 @@ CanSILFunctionType SILFunctionType::get(
41094098
ext = ext.intoBuilder().withClangFunctionType(nullptr).build();
41104099
}
41114100

4112-
// Canonicalize all thin functions to be escaping (to keep compatibility
4113-
// with generic parameters)
4114-
if (isThinRepresentation(ext.getRepresentation()))
4115-
ext = ext.intoBuilder().withNoEscape(false);
41164101

41174102
llvm::FoldingSetNodeID id;
41184103
SILFunctionType::Profile(id, genericSig, ext, coroutineKind, callee, params,

test/AutoDiff/SILOptimizer/activity_analysis.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,13 +552,14 @@ func testTryApply(_ x: Float) -> Float {
552552
// CHECK: bb0:
553553
// CHECK: [ACTIVE] %0 = argument of bb0 : $Float
554554
// CHECK: [NONE] // function_ref closure #1 in testTryApply(_:)
555-
// CHECK: [NONE] %3 = thin_to_thick_function %2 : $@convention(thin) () -> () to $@noescape @callee_guaranteed () -> ()
556-
// CHECK: [NONE] %4 = convert_function %3 : $@noescape @callee_guaranteed () -> () to $@noescape @callee_guaranteed () -> @error Error
555+
// CHECK: [NONE] %3 = convert_function %2 : $@convention(thin) () -> () to $@convention(thin) @noescape () -> ()
556+
// CHECK: [NONE] %4 = thin_to_thick_function %3 : $@convention(thin) @noescape () -> () to $@noescape @callee_guaranteed () -> ()
557+
// CHECK: [NONE] %5 = convert_function %4 : $@noescape @callee_guaranteed () -> () to $@noescape @callee_guaranteed () -> @error Error
557558
// CHECK: [NONE] // function_ref rethrowing(_:)
558559
// CHECK: bb1:
559-
// CHECK: [NONE] %7 = argument of bb1 : $()
560+
// CHECK: [NONE] %8 = argument of bb1 : $()
560561
// CHECK: bb2:
561-
// CHECK: [NONE] %9 = argument of bb2 : $Error
562+
// CHECK: [NONE] %10 = argument of bb2 : $Error
562563

563564
//===----------------------------------------------------------------------===//
564565
// Coroutine differentiation (`begin_apply`)

test/IRGen/objc_retainAutoreleasedReturnValue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public func test(_ dict: NSDictionary) {
3131
// CHECK: notail call i8* @llvm.objc.retainAutoreleasedReturnValue
3232
// CHECK: ret void
3333

34-
// OPT-LABEL: define {{.*}}swiftcc void @"$s34objc_retainAutoreleasedReturnValue10useClosureyySo12NSDictionaryC_yADXEtF09$s34objc_bcd16Value4testyySo12H10CFyADXEfU_Tf1nc_n"(%TSo12NSDictionaryC* %0)
34+
// OPT-LABEL: define {{.*}}swiftcc void @"$s34objc_retainAutoreleasedReturnValue4testyySo12NSDictionaryCFyADXEfU_"(%TSo12NSDictionaryC* %0)
3535
// OPT: entry:
3636
// OPT: call {{.*}}@objc_msgSend
3737
// OPT: notail call i8* @llvm.objc.retainAutoreleasedReturnValue

test/PrintAsObjC/blocks.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ typealias MyBlockWithNoescapeParam = (() -> ()) -> Int
101101
) {
102102
}
103103

104-
// CHECK-NEXT: - (void (* _Nonnull)(NSInteger (* _Nonnull)(NSInteger, NSInteger)))returnsFunctionPointerThatTakesFunctionPointer SWIFT_WARN_UNUSED_RESULT;
104+
// CHECK-NEXT: - (void (* _Nonnull)(SWIFT_NOESCAPE NSInteger (* _Nonnull)(NSInteger, NSInteger)))returnsFunctionPointerThatTakesFunctionPointer SWIFT_WARN_UNUSED_RESULT;
105105
@objc func returnsFunctionPointerThatTakesFunctionPointer() ->
106106
@convention(c) (_ comparator: @convention(c) (_ x: Int, _ y: Int) -> Int) -> Void {
107107
fatalError()

test/PrintAsObjC/cdecl-imports.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Foundation
1818
public func fwdDeclaresBee() -> Bee { fatalError() }
1919

2020
// CHECK: @class Hive;
21-
// CHECK-LABEL: void fwd_declares_hive(Hive * _Nonnull (* _Nonnull bzzz)(Bee * _Nonnull));
21+
// CHECK-LABEL: void fwd_declares_hive(SWIFT_NOESCAPE Hive * _Nonnull (* _Nonnull bzzz)(Bee * _Nonnull));
2222

2323
@_cdecl("fwd_declares_hive")
2424
public func fwdDeclaresHive(bzzz: @convention(c) (Bee) -> Hive) { fatalError() }

test/PrintAsObjC/cdecl.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public func block_recurring_nightmare(x: @escaping @convention(block) (@conventi
2626
@_cdecl("foo_bar")
2727
func foo(x: Int, bar y: Int) {}
2828

29-
// CHECK-LABEL: SWIFT_EXTERN double (* _Nonnull function_pointer_nightmare(float (* _Nonnull x)(NSInteger)))(char) SWIFT_WARN_UNUSED_RESULT;
29+
// CHECK-LABEL: SWIFT_EXTERN double (* _Nonnull function_pointer_nightmare(SWIFT_NOESCAPE float (* _Nonnull x)(NSInteger)))(char) SWIFT_WARN_UNUSED_RESULT;
3030
@_cdecl("function_pointer_nightmare")
3131
func function_pointer_nightmare(x: @convention(c) (Int) -> Float)
3232
-> @convention(c) (CChar) -> Double { return { _ in 0 } }
3333

34-
// CHECK-LABEL: SWIFT_EXTERN double (* _Nonnull function_pointer_recurring_nightmare(float (* _Nonnull x)(NSInteger (* _Nonnull)(double))))(char (* _Nonnull)(unsigned char)) SWIFT_WARN_UNUSED_RESULT;
34+
// CHECK-LABEL: SWIFT_EXTERN double (* _Nonnull function_pointer_recurring_nightmare(float (* _Nonnull x)(SWIFT_NOESCAPE NSInteger (* _Nonnull)(double))))(SWIFT_NOESCAPE char (* _Nonnull)(unsigned char)) SWIFT_WARN_UNUSED_RESULT;
3535
@_cdecl("function_pointer_recurring_nightmare")
3636
public func function_pointer_recurring_nightmare(x: @escaping @convention(c) (@convention(c) (Double) -> Int) -> Float)
3737
-> @convention(c) (@convention(c) (CUnsignedChar) -> CChar) -> Double {

test/SIL/clang-function-types-nonwindows.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ import ctypes
77

88
public func f(g: @convention(c, cType: "void (*)(size_t)") (Int) -> ()) { g(0) }
99

10-
// CHECK: sil @$s4main1f1gyySiXzC9_ZTSPFvmE_tF : $@convention(thin) (@convention(c, cType: "void (*)(unsigned long)") (Int) -> ()) -> () {
11-
// CHECK: bb0(%0 : $@convention(c, cType: "void (*)(unsigned long)") (Int) -> ()):
12-
// CHECK: debug_value %0 : $@convention(c, cType: "void (*)(unsigned long)") (Int) -> (), let, name "g", argno 1 // id: %1
10+
// CHECK: sil @$s4main1f1gyySiXzC9_ZTSPFvmE_tF : $@convention(thin) (@convention(c, cType: "void (*)(unsigned long)") @noescape (Int) -> ()) -> () {
11+
// CHECK: bb0(%0 : $@convention(c, cType: "void (*)(unsigned long)") @noescape (Int) -> ()):
12+
// CHECK: debug_value %0 : $@convention(c, cType: "void (*)(unsigned long)") @noescape (Int) -> (), let, name "g", argno 1 // id: %1

test/SILGen/async_builtins.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public func usesWithUnsafeContinuation() async {
4343
let _: Int = await Builtin.withUnsafeContinuation { c in }
4444

4545
// CHECK: [[FN:%.*]] = function_ref @$s4test26usesWithUnsafeContinuationyyYaFyBcXEfU_ : $@convention(thin) (Builtin.RawUnsafeContinuation) -> ()
46-
// CHECK: [[CLOSURE:%.*]] = thin_to_thick_function [[FN]]
46+
// CHECK: [[TMP:%.*]] = convert_function [[FN]] : $@convention(thin) (Builtin.RawUnsafeContinuation) -> () to $@convention(thin) @noescape (Builtin.RawUnsafeContinuation) -> ()
47+
// CHECK: [[CLOSURE:%.*]] = thin_to_thick_function [[TMP]]
4748
// CHECK: [[BOX:%.*]] = alloc_stack $Int
4849
// CHECK: [[CC:%.*]] = get_async_continuation_addr Int, [[BOX]] : $*Int
4950
// CHECK: apply [[CLOSURE]]([[CC]]) : $@noescape @callee_guaranteed (Builtin.RawUnsafeContinuation) -> ()
@@ -57,7 +58,8 @@ public func usesWithUnsafeContinuation() async {
5758
let _: String = await Builtin.withUnsafeContinuation { c in }
5859

5960
// CHECK: [[FN:%.*]] = function_ref @$s4test26usesWithUnsafeContinuationyyYaFyBcXEfU0_ : $@convention(thin) (Builtin.RawUnsafeContinuation) -> ()
60-
// CHECK: [[CLOSURE:%.*]] = thin_to_thick_function [[FN]]
61+
// CHECK: [[TMP:%.*]] = convert_function [[FN]] : $@convention(thin) (Builtin.RawUnsafeContinuation) -> () to $@convention(thin) @noescape (Builtin.RawUnsafeContinuation) -> ()
62+
// CHECK: [[CLOSURE:%.*]] = thin_to_thick_function [[TMP]]
6163
// CHECK: [[BOX:%.*]] = alloc_stack $String
6264
// CHECK: [[CC:%.*]] = get_async_continuation_addr String, [[BOX]] : $*String
6365
// CHECK: apply [[CLOSURE]]([[CC]]) : $@noescape @callee_guaranteed (Builtin.RawUnsafeContinuation) -> ()
@@ -72,7 +74,8 @@ public func usesWithUnsafeContinuation() async {
7274
let _: Any = await Builtin.withUnsafeContinuation { c in }
7375

7476
// CHECK: [[FN:%.*]] = function_ref @$s4test26usesWithUnsafeContinuationyyYaFyBcXEfU1_ : $@convention(thin) (Builtin.RawUnsafeContinuation) -> ()
75-
// CHECK: [[CLOSURE:%.*]] = thin_to_thick_function [[FN]]
77+
// CHECK: [[TMP:%.*]] = convert_function [[FN]] : $@convention(thin) (Builtin.RawUnsafeContinuation) -> () to $@convention(thin) @noescape (Builtin.RawUnsafeContinuation) -> ()
78+
// CHECK: [[CLOSURE:%.*]] = thin_to_thick_function [[TMP]]
7679
// CHECK: [[BOX:%.*]] = alloc_stack $Any
7780
// CHECK: [[CC:%.*]] = get_async_continuation_addr Any, [[BOX]] : $*Any
7881
// CHECK: apply [[CLOSURE]]([[CC]]) : $@noescape @callee_guaranteed (Builtin.RawUnsafeContinuation) -> ()
@@ -91,7 +94,8 @@ public func usesWithUnsafeThrowingContinuation() async throws {
9194
let _: Int = try await Builtin.withUnsafeThrowingContinuation { c in }
9295

9396
// CHECK: [[FN:%.*]] = function_ref @$s4test34usesWithUnsafeThrowingContinuationyyYaKFyBcXEfU_ : $@convention(thin) (Builtin.RawUnsafeContinuation) -> ()
94-
// CHECK: [[CLOSURE:%.*]] = thin_to_thick_function [[FN]]
97+
// CHECK: [[TMP:%.*]] = convert_function [[FN]] : $@convention(thin) (Builtin.RawUnsafeContinuation) -> () to $@convention(thin) @noescape (Builtin.RawUnsafeContinuation) -> ()
98+
// CHECK: [[CLOSURE:%.*]] = thin_to_thick_function [[TMP]]
9599
// CHECK: [[BOX:%.*]] = alloc_stack $Int
96100
// CHECK: [[CC:%.*]] = get_async_continuation_addr [throws] Int, [[BOX]] : $*Int
97101
// CHECK: apply [[CLOSURE]]([[CC]]) : $@noescape @callee_guaranteed (Builtin.RawUnsafeContinuation) -> ()

test/SILGen/auto_closures.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ func test_auto_closure_with_capture(_ x: Bool) -> Bool {
2525
// CHECK-LABEL: sil hidden [ossa] @$s13auto_closures05test_A24_closure_without_capture{{[_0-9a-zA-Z]*}}F
2626
func test_auto_closure_without_capture() -> Bool {
2727
// CHECK: [[CLOSURE:%.*]] = function_ref @$s13auto_closures05test_A24_closure_without_capture
28-
// CHECK: [[THICK:%.*]] = thin_to_thick_function [[CLOSURE]] : $@convention(thin) () -> Bool to $@noescape @callee_guaranteed () -> Bool
28+
// CHECK: [[CVT:%.*]] = convert_function [[CLOSURE]]
29+
// CHECK: [[THICK:%.*]] = thin_to_thick_function [[CVT]] : $@convention(thin) @noescape () -> Bool to $@noescape @callee_guaranteed () -> Bool
2930
// CHECK: [[RET:%.*]] = apply {{%.*}}([[THICK]])
3031
// CHECK: return [[RET]]
3132
return call_auto_closure(false_)

0 commit comments

Comments
 (0)