コード例 #1
0
        private static (string Name, ControlFlowGraph Cfg) _GetCodeOfMethod(MethodDeclarationSyntax method, SemanticModel semanticModel)
        {
            var methodName = method.Identifier.Text;

            try {
                var code      = ThreeAddressCodeFactory.Create(CodeFactory.CreateMethod(method, semanticModel));
                var optimized = OptimizationRunner.Optimize(code);

                Debug.WriteLine($"got optimized code for {methodName}");
                return(methodName, ControlFlowGraphFactory.Create(optimized.Code, methodName, true));
            } catch (UnsupportedSyntaxException e) {
                Debug.WriteLine($"method '{methodName}' cannot be utilized in interprocedural anaylsis: {e.Message}");
            }

            return(null, null);
        }
コード例 #2
0
            public void Scan(TLoopStatementSyntax loopStatement, SyntaxNode body, string loopIndex, Location location)
            {
                var code             = ThreeAddressCodeFactory.Create(CodeFactory.Create(body, _semanticModel));
                var variableAccesses = VariableAccesses.Collect(code);

                if (!WriteAccessVerifier.HasNoWriteAccessToSharedVariables(variableAccesses))
                {
                    Debug.WriteLine("the loop contains write accesses to shared variables");
                    return;
                }

                if (_HasConflictingArrayAccesses(loopStatement, loopIndex, code, variableAccesses))
                {
                    Debug.WriteLine("the loop contains loop carried dependencies");
                    return;
                }

                _ReportLoopForParallelization(loopStatement, location);
            }
コード例 #3
0
 /// <summary>
 /// Creates a three address code from the given source syntax.
 /// </summary>
 /// <returns></returns>
 public static Code CreateThreeAddressCode(string body)
 {
     return(ThreeAddressCodeFactory.Create(CreateCode(body)));
 }