swiftlang/swift

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

開放

#43,716 建立於 2016年3月29日

 (1 則留言) (0 個反應) (0 位負責人)Swift (10,719 個分叉)batch import
IRGenbugcompilergood first issue

倉庫指標

星標
 (69,989 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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.

貢獻者指南