@@ -27,13 +27,6 @@ struct ExceptionOrPassPatternElimination {
27
27
28
28
private:
29
29
bool isExceptionOrPassNode (Node* n) {
30
- // / Check if this Node hosts a pattern like so:
31
- // / = prim::If(%5958)
32
- // / block0():
33
- // / = prim::RaiseException(%45)
34
- // / -> ()
35
- // / block1():
36
- // / -> ()
37
30
if (n->blocks ().size () != 2 ) {
38
31
return false ;
39
32
}
@@ -46,15 +39,44 @@ struct ExceptionOrPassPatternElimination {
46
39
}
47
40
48
41
auto arm1_start = arm1->nodes ().begin ();
42
+ auto arm2_start = arm2->nodes ().begin ();
49
43
50
- if ((*arm1_start)->kind () != prim::RaiseException && (*(++arm1_start))->kind () != prim::Return) {
51
- // Make sure that block0 is solely just the exception and the return
52
- return false ;
44
+ // / Check if this Node hosts a pattern like so:
45
+ // / = prim::If(%5958)
46
+ // / block0():
47
+ // / = prim::RaiseException(%45)
48
+ // / -> ()
49
+ // / block1():
50
+ // / -> ()
51
+ if ((*arm1_start)->kind () == prim::RaiseException) {
52
+ if ((*(++arm1_start))->kind () != prim::Return) {
53
+ // Make sure that block0 is solely just the exception and the return
54
+ return false ;
55
+ }
56
+
57
+ if ((*(arm2_start))->kind () != prim::Return) {
58
+ // Make sure that block1 is solely the return
59
+ return false ;
60
+ }
53
61
}
54
62
55
- if ((*(arm2->nodes ().begin ()))->kind () != prim::Return) {
56
- // Make sure that block1 is solely the return
57
- return false ;
63
+ // / Check if this Node hosts a pattern like so:
64
+ // / = prim::If(%5958)
65
+ // / block0():
66
+ // / -> ()
67
+ // / block1():
68
+ // / = prim::RaiseException(%45)
69
+ // / -> ()
70
+ if ((*arm2_start)->kind () == prim::RaiseException) {
71
+ if ((*(++arm2_start))->kind () != prim::Return) {
72
+ // Make sure that block1 is solely just the exception and the return
73
+ return false ;
74
+ }
75
+
76
+ if ((*(arm1_start))->kind () != prim::Return) {
77
+ // Make sure that block0 is solely the return
78
+ return false ;
79
+ }
58
80
}
59
81
60
82
return true ;
0 commit comments