Issue |
91050
|
Summary |
[TableGen] llvm-tblgen crash error when using class as subroutine with recursion
|
Labels |
new issue
|
Assignees |
|
Reporter |
kychendev
|
When using class as subroutine with recursion, llvm-tblgen crashed in resolving references, as demonstrated by the following example.
```cpp
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)".
```cpp
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
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs