mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
MandatoryPerformanceOptimization: don't recursive into referenced functions if they are not called
Fixes a false compiler error when referencing a function from a global with a section attribute. rdar://154332540
This commit is contained in:
@@ -535,7 +535,24 @@ fileprivate struct FunctionWorklist {
|
||||
for inst in function.instructions {
|
||||
switch inst {
|
||||
case let fri as FunctionRefInst:
|
||||
pushIfNotVisited(fri.referencedFunction)
|
||||
// In embedded swift all reachable functions must be handled - even if they are not called,
|
||||
// e.g. referenced by a global.
|
||||
if context.options.enableEmbeddedSwift {
|
||||
pushIfNotVisited(fri.referencedFunction)
|
||||
}
|
||||
case let apply as ApplySite:
|
||||
if let callee = apply.referencedFunction {
|
||||
pushIfNotVisited(callee)
|
||||
}
|
||||
case let bi as BuiltinInst:
|
||||
switch bi.id {
|
||||
case .Once, .OnceWithContext:
|
||||
if let fri = bi.operands[1].value as? FunctionRefInst {
|
||||
pushIfNotVisited(fri.referencedFunction)
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
case let alloc as AllocRefInst:
|
||||
if context.options.enableEmbeddedSwift {
|
||||
addVTableMethods(forClassType: alloc.type, context)
|
||||
|
||||
Reference in New Issue
Block a user