Skip to content

Commit ae1fe78

Browse files
authored
Merge pull request swiftlang#70815 from zoecarver/perf-annotation-ns-direct-exception
2 parents 2dfa350 + 0815ca8 commit ae1fe78

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

lib/SIL/Utils/InstructionUtils.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include "swift/SIL/SILBuilder.h"
2525
#include "swift/SIL/SILVisitor.h"
2626

27+
#include "clang/AST/DeclObjC.h"
28+
2729
using namespace swift;
2830

2931
SILValue swift::lookThroughOwnershipInsts(SILValue v) {
@@ -915,7 +917,17 @@ RuntimeEffect swift::getRuntimeEffect(SILInstruction *inst, SILType &impactType)
915917
auto as = ApplySite(inst);
916918

917919
switch (as.getSubstCalleeType()->getRepresentation()) {
918-
case SILFunctionTypeRepresentation::ObjCMethod:
920+
case SILFunctionTypeRepresentation::ObjCMethod: {
921+
if (auto *callee = as.getCalleeFunction()) {
922+
if (auto *clangDecl = callee->getClangDecl()) {
923+
if (auto clangMethodDecl = dyn_cast<clang::ObjCMethodDecl>(clangDecl)) {
924+
if (clangMethodDecl->isDirectMethod()) {
925+
break;
926+
}
927+
}
928+
}
929+
}
930+
}
919931
case SILFunctionTypeRepresentation::Block:
920932
rt |= RuntimeEffect::ObjectiveC | RuntimeEffect::MetaData;
921933
break;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %target-swift-frontend -emit-ir -verify -I %t/Inputs %t/test.swift
5+
6+
// REQUIRES: objc_interop
7+
8+
//--- Inputs/header.h
9+
10+
@interface Interface
11+
12+
- (void)test __attribute__((objc_direct)) __attribute__((swift_attr("@_noObjCBridging")));
13+
14+
@end
15+
16+
17+
//--- Inputs/module.modulemap
18+
19+
module ObjCModule {
20+
header "header.h"
21+
export *
22+
}
23+
24+
//--- test.swift
25+
26+
import Foundation
27+
import ObjCModule
28+
29+
@_noObjCBridging
30+
func test(i: Interface) {
31+
i.test()
32+
}

0 commit comments

Comments
 (0)