[SR-8097] Improve error handling infra in Graph Lowering #50630
Labels
compiler
The Swift compiler in itself
good first issue
Good for newcomers
improvement
SILOptimizer
Area → compiler: SIL optimization passes
swift for tensorflow
Additional Detail from JIRA
md5: 139afabcce0b72ca2e6014cb5ccb90b5
Issue Description:
Currently the graph lowering pass uses the following member field to track if error has occurred:
bool errorOccurred = false;
swift/lib/SILOptimizer/Mandatory/TFLowerGraph.cpp
Line 234 in d9d16ef
It must be set at the lowest level of any call stack (e.g.
https://github.com/apple/swift/blob/d9d16ef9fbadcb5f1b0a73e632176121ae0945a5/lib/SILOptimizer/Mandatory/TFLowerGraph.cpp#L266), and at other places we must check for the error (e.g.
https://github.com/apple/swift/blob/d9d16ef9fbadcb5f1b0a73e632176121ae0945a5/lib/SILOptimizer/Mandatory/TFLowerGraph.cpp#L498). If the check statement is missed, graph lowering can incorrectly proceed despite of encoutering errors, leading to bugs in the code.
The code might be cleaner and less error prone if each function call returns a bool indicating whether something has failed (the LLVM/swift convention is to return true on error). This general "design pattern" of error handling could be to return a util::Status type of object, but returning a bool is probably sufficient for now.
The text was updated successfully, but these errors were encountered: