private bool AnalyseCallAccessesInRegion(InstrumentationRegion region) { int preCount = 0; int afterCount = 0; foreach (var r in region.GetResourceAccesses()) { preCount = preCount + r.Value.Count; } foreach (var call in region.CallInformation.Keys) { var calleeRegion = this.AC.InstrumentationRegions.Find(val => val.Implementation().Name.Equals(call.callee)); if (calleeRegion.IsNotAccessingResources) { continue; } foreach (var r in calleeRegion.GetResourceAccesses()) { if (!region.ExternallyReceivedAccesses[call].ContainsKey(r.Key)) { region.ExternallyReceivedAccesses[call].Add(r.Key, new HashSet <Expr>()); } foreach (var a in r.Value) { if (region.ExternallyReceivedAccesses[call][r.Key].Contains(a)) { continue; } int index; if (a is NAryExpr) { index = this.TryGetArgumentIndex(call, calleeRegion, (a as NAryExpr).Args[0]); } else { index = this.TryGetArgumentIndex(call, calleeRegion, a); } if (index < 0) { continue; } if (!region.CallInformation[call].ContainsKey(index)) { continue; } var calleeExpr = region.CallInformation[call][index]; var computedExpr = this.ComputeExpr(calleeExpr.Item1, a); var id = this.PtrAnalysisCache[region].GetIdentifier(computedExpr); if (this.PtrAnalysisCache[region].IsAxiom(id)) { if (!this.AC.AxiomAccessesMap.ContainsKey(r.Key)) { this.AC.AxiomAccessesMap.Add(r.Key, new HashSet <Expr>()); } if (!this.AC.AxiomAccessesMap[r.Key].Any(val => val.ToString().Equals(computedExpr.ToString()))) { this.AC.AxiomAccessesMap[r.Key].Add(computedExpr); } } else { region.TryAddResourceAccess(r.Key, computedExpr); region.ExternallyReceivedAccesses[call][r.Key].Add(a); } } } if (WhoopCommandLineOptions.Get().OptimiseHeavyAsyncCalls&& (this.AC.GetNumOfEntryPointRelatedFunctions(this.EP.Name) > WhoopCommandLineOptions.Get().EntryPointFunctionCallComplexity)) { continue; } foreach (var pair in region.GetResourceAccesses()) { foreach (var access in pair.Value) { foreach (var index in region.CallInformation[call].Keys) { if (!region.CallInformation[call].ContainsKey(index)) { continue; } var calleeExpr = region.CallInformation[call][index]; var mappedExpr = this.ComputeMappedExpr(access, calleeExpr.Item1, calleeExpr.Item2); if (mappedExpr != null) { this.CacheMatchedAccesses(pair.Key, access, mappedExpr); if (calleeRegion.TryAddExternalResourceAccesses(pair.Key, mappedExpr)) { afterCount++; } } } } } } foreach (var r in region.GetResourceAccesses()) { afterCount = afterCount + r.Value.Count; } if (preCount != afterCount) { return(false); } else { return(true); } }