@@ -56,16 +56,20 @@ struct AliasAnalysis {
56
56
} ,
57
57
58
58
// isObjReleasedFn
59
- { ( bridgedCtxt: BridgedPassContext , bridgedObj: BridgedValue , bridgedInst: BridgedInstruction ) -> Bool in
59
+ { ( bridgedCtxt: BridgedPassContext , bridgedObj: BridgedValue , bridgedInst: BridgedInstruction , complexityBudget : Int ) -> Bool in
60
60
let context = FunctionPassContext ( _bridged: bridgedCtxt)
61
61
let inst = bridgedInst. instruction
62
62
let obj = bridgedObj. value
63
63
let path = SmallProjectionPath ( . anyValueFields)
64
64
if let apply = inst as? ApplySite {
65
- let effect = getOwnershipEffect ( of: apply, for: obj, path: path, context)
65
+ // Workaround for quadratic complexity in ARCSequenceOpts.
66
+ // We need to use an ever lower budget to not get into noticable compile time troubles.
67
+ let budget = complexityBudget / 10
68
+ let effect = getOwnershipEffect ( of: apply, for: obj, path: path, complexityBudget: budget, context)
66
69
return effect. destroy
67
70
}
68
- return obj. at ( path) . isEscaping ( using: EscapesToInstructionVisitor ( target: inst, isAddress: false ) , context)
71
+ return obj. at ( path) . isEscaping ( using: EscapesToInstructionVisitor ( target: inst, isAddress: false ) ,
72
+ complexityBudget: complexityBudget, context)
69
73
} ,
70
74
71
75
// isAddrVisibleFromObj
@@ -159,9 +163,10 @@ private func getMemoryEffect(ofBuiltin builtin: BuiltinInst, for address: Value,
159
163
}
160
164
}
161
165
162
- private func getOwnershipEffect( of apply: ApplySite , for value: Value , path: SmallProjectionPath , _ context: FunctionPassContext ) -> SideEffects . Ownership {
166
+ private func getOwnershipEffect( of apply: ApplySite , for value: Value , path: SmallProjectionPath ,
167
+ complexityBudget: Int , _ context: FunctionPassContext ) -> SideEffects . Ownership {
163
168
let visitor = SideEffectsVisitor ( apply: apply, calleeAnalysis: context. calleeAnalysis, isAddress: false )
164
- if let result = value. at ( path) . visit ( using: visitor, context) {
169
+ if let result = value. at ( path) . visit ( using: visitor, complexityBudget : complexityBudget , context) {
165
170
// The resulting effects are the argument effects to which `value` escapes to.
166
171
return result. ownership
167
172
} else {
0 commit comments