@@ -56,16 +56,20 @@ struct AliasAnalysis {
5656 } ,
5757
5858 // isObjReleasedFn
59- { ( bridgedCtxt: BridgedPassContext , bridgedObj: BridgedValue , bridgedInst: BridgedInstruction ) -> Bool in
59+ { ( bridgedCtxt: BridgedPassContext , bridgedObj: BridgedValue , bridgedInst: BridgedInstruction , complexityBudget : Int ) -> Bool in
6060 let context = FunctionPassContext ( _bridged: bridgedCtxt)
6161 let inst = bridgedInst. instruction
6262 let obj = bridgedObj. value
6363 let path = SmallProjectionPath ( . anyValueFields)
6464 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)
6669 return effect. destroy
6770 }
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)
6973 } ,
7074
7175 // isAddrVisibleFromObj
@@ -159,9 +163,10 @@ private func getMemoryEffect(ofBuiltin builtin: BuiltinInst, for address: Value,
159163 }
160164}
161165
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 {
163168 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) {
165170 // The resulting effects are the argument effects to which `value` escapes to.
166171 return result. ownership
167172 } else {
0 commit comments