swiftlang/swift
[SR-1103] Redundant metadata accesses when invoking ObjC protocol methods
开放
#43,716 创建于 2016年3月29日
IRGenbugcompilergood first issue
仓库指标
- 星标
- (69,989 个星标)
- PR 合并指标
- (平均合并 8天 17小时) (30 天内合并 510 个 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.