Open
Description
When using class as subroutine with recursion, llvm-tblgen crashed in resolving references, as demonstrated by the following example.
class A <int a, int b, int s> {
int n = !add(a, s, -1);
list<string> ret =
!if(!le(n, b),
!listconcat([a#"-"#n],
A<!add(a, 1), b, s>.ret),
[]);
}
def RecordA : A<0, 3, 2>;
Link to failed case: https://godbolt.org/z/5rTGo7TdK
The issue can be worked around by revising the class definition as follows. The only difference is substituting the use of variable "n" at line 4 with the expression "!add(a, s, -1)".
class A <int a, int b, int s> {
int n = !add(a, s, -1);
list<string> ret =
!if(!le(!add(a, s, -1), b),
!listconcat([a#"-"#n],
A<!add(a, 1), b, s>.ret),
[]);
}
def RecordA : A<0, 3, 2>;
Link to working case: https://godbolt.org/z/zhYGo6Ea3