Package org.apache.sysds.hops.ipa
Class FunctionCallGraph
java.lang.Object
org.apache.sysds.hops.ipa.FunctionCallGraph
-
Constructor Summary
ConstructorsConstructorDescriptionFunctionCallGraph(DMLProgram prog) Constructs the function call graph for all functions reachable from the main program.Constructs the function call graph for all functions reachable from the given statement block. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates if the function call graph, i.e., functions that are transitively reachable from the main program, contains a second-order builtin function call (e.g., eval, paramserv), which prohibits the removal of unused functions.getCalledFunctions(String fkey) Returns all functions called from the given function.getCalledFunctions(String fnamespace, String fname) Returns all functions called from the given function.getFunctionCalls(String fkey) Returns all function operators calling the given function.getFunctionCallsSB(String fkey) Returns all statement blocks that contain a function operator calling the given function.Returns all functions that are reachable either directly or indirectly form the main program, except the main program itself.getReachableFunctions(Set<String> excludeList) Returns all functions that are reachable either directly or indirectly form the main program, except the main program itself and the given exclude-list of function names.booleanisReachableFunction(String fkey) Indicates if the given function is reachable either directly or indirectly from the main program.booleanisReachableFunction(String fnamespace, String fname) Indicates if the given function is reachable either directly or indirectly from the main program.booleanisRecursiveFunction(String fkey) Indicates if the given function is either directly or indirectly recursive.booleanisRecursiveFunction(String fnamespace, String fname) Indicates if the given function is either directly or indirectly recursive.booleanIndicates if the given function is side effect free, i.e., has no prints, no persistent write, and includes no or only calls to side-effect-free functions.booleanisSideEffectFreeFunction(String fnamespace, String fname) Indicates if the given function is side effect free, i.e., has no prints, no persistent write, and includes no or only calls to side-effect-free functions.voidremoveFunctionCall(String fkey, FunctionOp fop, StatementBlock sb) Removes a single function call identified by target function name, and source function op and statement block.voidremoveFunctionCalls(String fkey) Removes all calls of the given function.voidreplaceFunctionCalls(String fkeyOld, String fkey) Replaces a function call to fkeyOld with a call to fkey, but using the function op and statement block from the old.
-
Constructor Details
-
FunctionCallGraph
Constructs the function call graph for all functions reachable from the main program.- Parameters:
prog- dml program of given script
-
FunctionCallGraph
Constructs the function call graph for all functions reachable from the given statement block.- Parameters:
sb- statement block (potentially hierarchical)
-
-
Method Details
-
getCalledFunctions
Returns all functions called from the given function.- Parameters:
fnamespace- function namespacefname- function name- Returns:
- set of function keys (namespace and name)
-
getCalledFunctions
Returns all functions called from the given function.- Parameters:
fkey- function key of calling function, null indicates the main program- Returns:
- set of function keys (namespace and name)
-
getFunctionCalls
Returns all function operators calling the given function.- Parameters:
fkey- function key of called function, null indicates the main program and returns an empty list- Returns:
- list of function call hops
-
getFunctionCallsSB
Returns all statement blocks that contain a function operator calling the given function.- Parameters:
fkey- function key of called function, null indicates the main program and returns an empty list- Returns:
- list of statement blocks
-
removeFunctionCalls
Removes all calls of the given function.- Parameters:
fkey- function key of called function, null indicates the main program, which has no affect
-
removeFunctionCall
Removes a single function call identified by target function name, and source function op and statement block.- Parameters:
fkey- function key of called functionfop- source function call operatorsb- source statement block
-
replaceFunctionCalls
Replaces a function call to fkeyOld with a call to fkey, but using the function op and statement block from the old.- Parameters:
fkeyOld- old function key of called functionfkey- new function key of called function
-
isRecursiveFunction
Indicates if the given function is either directly or indirectly recursive. An example of an indirect recursive function is foo2 in the following call chain: foo1 -> foo2 -> foo1.- Parameters:
fnamespace- function namespacefname- function name- Returns:
- true if the given function is recursive, false otherwise
-
isRecursiveFunction
Indicates if the given function is either directly or indirectly recursive. An example of an indirect recursive function is foo2 in the following call chain: foo1 -> foo2 -> foo1.- Parameters:
fkey- function key of calling function, null indicates the main program- Returns:
- true if the given function is recursive, false otherwise
-
isSideEffectFreeFunction
Indicates if the given function is side effect free, i.e., has no prints, no persistent write, and includes no or only calls to side-effect-free functions.- Parameters:
fnamespace- function namespacefname- function name- Returns:
- true if the given function is side-effect-free, false otherwise
-
isSideEffectFreeFunction
Indicates if the given function is side effect free, i.e., has no prints, no persistent write, and includes no or only calls to side-effect-free functions.- Parameters:
fkey- function key of calling function, null indicates the main program- Returns:
- true if the given function is side-effect-free, false otherwise
-
getReachableFunctions
Returns all functions that are reachable either directly or indirectly form the main program, except the main program itself.- Returns:
- set of function keys (namespace and name)
-
getReachableFunctions
Returns all functions that are reachable either directly or indirectly form the main program, except the main program itself and the given exclude-list of function names.- Parameters:
excludeList- list of function keys to exclude- Returns:
- set of function keys (namespace and name)
-
isReachableFunction
Indicates if the given function is reachable either directly or indirectly from the main program.- Parameters:
fnamespace- function namespacefname- function name- Returns:
- true if the given function is reachable, false otherwise
-
isReachableFunction
Indicates if the given function is reachable either directly or indirectly from the main program.- Parameters:
fkey- function key of calling function, null indicates the main program- Returns:
- true if the given function is reachable, false otherwise
-
containsSecondOrderCall
public boolean containsSecondOrderCall()Indicates if the function call graph, i.e., functions that are transitively reachable from the main program, contains a second-order builtin function call (e.g., eval, paramserv), which prohibits the removal of unused functions.- Returns:
- true if the function call graph contains a second-order builtin function call.
-