swiftlang/swift

[SR-1103] Redundant metadata accesses when invoking ObjC protocol methods

Open

#43,716 opened on 2016年3月29日

GitHub で見る
 (1 comment) (0 reactions) (0 assignees)Swift (69,989 stars) (10,719 forks)batch import
IRGenbugcompilergood first issue

説明

Previous ID SR-1103
Radar None
Original Reporter @jckarter
Type Bug
Votes 0
Component/s Compiler
Labels Bug, IRGen, StarterBug
Assignee None
Priority Medium

md5: 970c1d7db6290aee45b5ecc9fd1e9432

Issue Description:

Protocol methods are modeled as functions generic on Self, so IRGen tries to get the type metadata to satisfy the formal type parameter, even though it's not used for an ObjC or C protocol method:

define void @invoke_protocol_methods(%objc_object*) #​0 {
entry:
  %.Type = call %swift.type* @swift_getObjectType(%objc_object* %0) #​2
  %1 = bitcast %objc_object* %0 to i8*
  call void @mutateSomeState(i8* %1)
  ret void
}

The call is marked readnone so gets optimized away, but we shouldn't emit it at all for the sake of unoptimized code.

コントリビューターガイド