|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | + |
| 3 | +// RUN: %target-swift-frontend -enable-llvm-vfe -internalize-at-link -emit-ir %s -o %t/ir.ll |
| 4 | +// RUN: %FileCheck --input-file %t/ir.ll %s --check-prefix=OBJC-BASE |
| 5 | +// RUN: %FileCheck --input-file %t/ir.ll %s --check-prefix=OBJC-DERIVED |
| 6 | +// RUN: %FileCheck --input-file %t/ir.ll %s --check-prefix=BASE |
| 7 | +// RUN: %FileCheck --input-file %t/ir.ll %s --check-prefix=DERIVED |
| 8 | +// RUN: echo '' > %t/used-symbols |
| 9 | +// RUN: %target-build-swift -emit-library -lto=llvm-full %lto_flags -Xfrontend -enable-llvm-vfe -Xfrontend -internalize-at-link -Xlinker -exported_symbols_list -Xlinker %t/used-symbols %s -o %t/main |
| 10 | +// RUN: %llvm-nm --defined-only %t/main | %FileCheck %s --check-prefix=NM |
| 11 | + |
| 12 | +// REQUIRES: objc_interop |
| 13 | +// REQUIRES: no_asan |
| 14 | +// UNSUPPORTED: remote_run |
| 15 | + |
| 16 | +// Tests that under -enable-llvm-vfe @objc virtual functions are not eligible for elimination |
| 17 | + |
| 18 | +import Foundation |
| 19 | + |
| 20 | +// Objective-C exposed types should have public vcall_visibility even under |
| 21 | +// -internalize-at-link |
| 22 | + |
| 23 | +@objc public class ObjCBase : NSObject { |
| 24 | + @objc public func foo() { print("ObjCBase.foo") } |
| 25 | + @objc public func bar() { print("ObjCBase.bar") } |
| 26 | +} |
| 27 | + |
| 28 | +// OBJC-BASE: @"$s2ir8ObjCBaseCMn" = {{.*}}!vcall_visibility ![[VCALL_VISIBILITY_METADATA_NODE:[0-9]+]] |
| 29 | +// OBJC-BASE: ![[VCALL_VISIBILITY_METADATA_NODE]] = !{i64 0 |
| 30 | + |
| 31 | +@objc public class ObjCDerived : ObjCBase { |
| 32 | + @objc override public func foo() { print("ObjCDerived.foo") } |
| 33 | + @objc override public func bar() { print("ObjCDerived.bar") } |
| 34 | +} |
| 35 | + |
| 36 | +// OBJC-DERIVED: @"$s2ir11ObjCDerivedCMn" = {{.*}}!vcall_visibility ![[VCALL_VISIBILITY_METADATA_NODE:[0-9]+]] |
| 37 | +// OBJC-DERIVED: ![[VCALL_VISIBILITY_METADATA_NODE]] = !{i64 0 |
| 38 | + |
| 39 | +// Regular Swift types should have linkage unit vcall_visibility |
| 40 | + |
| 41 | +public class Base { |
| 42 | + public func foo() { print("Base.foo") } |
| 43 | + public func bar() { print("Base.bar") } |
| 44 | +} |
| 45 | + |
| 46 | +// BASE: @"$s2ir4BaseCMn" = {{.*}}!vcall_visibility ![[VCALL_VISIBILITY_METADATA_NODE:[0-9]+]] |
| 47 | +// BASE: ![[VCALL_VISIBILITY_METADATA_NODE]] = !{i64 1 |
| 48 | + |
| 49 | +public class Derived : Base { |
| 50 | + override public func foo() { print("Derived.foo") } |
| 51 | + override public func bar() { print("Derived.bar") } |
| 52 | +} |
| 53 | + |
| 54 | +// DERIVED: @"$s2ir7DerivedCMn" = {{.*}}!vcall_visibility ![[VCALL_VISIBILITY_METADATA_NODE:[0-9]+]] |
| 55 | +// DERIVED: ![[VCALL_VISIBILITY_METADATA_NODE]] = !{i64 1 |
| 56 | + |
| 57 | +// NM: $s4main11ObjCDerivedC3baryyF{{$}} |
| 58 | +// NM: $s4main11ObjCDerivedC3fooyyF{{$}} |
| 59 | +// NM-NOT: $s4main4BaseC3baryyF{{$}} |
| 60 | +// NM-NOT: $s4main4BaseC3fooyyF{{$}} |
| 61 | +// NM-NOT: $s4main7DerivedC3baryyF{{$}} |
| 62 | +// NM-NOT: $s4main7DerivedC3fooyyF{{$}} |
| 63 | +// NM: $s4main8ObjCBaseC3baryyF{{$}} |
| 64 | +// NM: $s4main8ObjCBaseC3fooyyF{{$}} |
0 commit comments