@@ -85,16 +85,20 @@ struct AliasAnalysis {
85
85
} ,
86
86
87
87
// isObjReleasedFn
88
- { ( bridgedCtxt: BridgedPassContext , bridgedObj: BridgedValue , bridgedInst: BridgedInstruction ) -> Bool in
88
+ { ( bridgedCtxt: BridgedPassContext , bridgedObj: BridgedValue , bridgedInst: BridgedInstruction , complexityBudget : Int ) -> Bool in
89
89
let context = FunctionPassContext ( _bridged: bridgedCtxt)
90
90
let inst = bridgedInst. instruction
91
91
let obj = bridgedObj. value
92
92
let path = SmallProjectionPath ( . anyValueFields)
93
93
if let apply = inst as? ApplySite {
94
- let effect = getOwnershipEffect ( of: apply, for: obj, path: path, context)
94
+ // Workaround for quadratic complexity in ARCSequenceOpts.
95
+ // We need to use an ever lower budget to not get into noticable compile time troubles.
96
+ let budget = complexityBudget / 10
97
+ let effect = getOwnershipEffect ( of: apply, for: obj, path: path, complexityBudget: budget, context)
95
98
return effect. destroy
96
99
}
97
- return obj. at ( path) . isEscaping ( using: EscapesToInstructionVisitor ( target: inst, isAddress: false ) , context)
100
+ return obj. at ( path) . isEscaping ( using: EscapesToInstructionVisitor ( target: inst, isAddress: false ) ,
101
+ complexityBudget: complexityBudget, context)
98
102
} ,
99
103
100
104
// isAddrVisibleFromObj
@@ -145,9 +149,10 @@ private func getMemoryEffect(of apply: ApplySite, for address: Value, path: Smal
145
149
return memoryEffects
146
150
}
147
151
148
- private func getOwnershipEffect( of apply: ApplySite , for value: Value , path: SmallProjectionPath , _ context: FunctionPassContext ) -> SideEffects . Ownership {
152
+ private func getOwnershipEffect( of apply: ApplySite , for value: Value , path: SmallProjectionPath ,
153
+ complexityBudget: Int , _ context: FunctionPassContext ) -> SideEffects . Ownership {
149
154
let visitor = SideEffectsVisitor ( apply: apply, calleeAnalysis: context. calleeAnalysis, isAddress: false )
150
- if let result = value. at ( path) . visit ( using: visitor, context) {
155
+ if let result = value. at ( path) . visit ( using: visitor, complexityBudget : complexityBudget , context) {
151
156
// The resulting effects are the argument effects to which `value` escapes to.
152
157
return result. ownership
153
158
} else {
0 commit comments