[llvm-tblgen] Two issues: crash case and mysterious double-inclusion case

Dear all,

I need your help to understand weird llvm-tblgen behavior. Please take your favourite version of llvm-tblgen and use it in the root directory of the archive attached in both bug reports:

http://llvm.org/bugs/show_bug.cgi?id=15188
http://llvm.org/bugs/show_bug.cgi?id=15189

Dear all,

I need your help to understand weird llvm-tblgen behavior. Please take your
favourite version of llvm-tblgen and use it in the root directory of the
archive attached in both bug reports:

http://llvm.org/bugs/show_bug.cgi?id=15188
http://llvm.org/bugs/show_bug.cgi?id=15189

$ llvm-tblgen --version
LLVM (http://llvm.org/):
  LLVM version 3.1
  Optimized build.
  Built Oct 17 2012 (19:26:30).
  Default target: amd64-portbld-freebsd8.3
  Host CPU: core2

====
1) First test case: crashing

$ ./llvm-tblgen -gen-tgt-intrinsic NVPTX1.td

assert(iid <= Intrinsic::0 llvm-tblgen 0x00000000005c56b6
1 llvm-tblgen 0x00000000005c54b2
2 libpthread.so.0 0x00007fc734644a10
3 libstdc++.so.6 0x00007fc7345bba5e std::string::_M_data() const + 12
4 libstdc++.so.6 0x00007fc7345bba9c std::string::_M_rep() const + 24
5 libstdc++.so.6 0x00007fc7345bba4c std::string::length() const + 24
6 llvm-tblgen 0x000000000042507f
7 llvm-tblgen 0x000000000051efd9
8 llvm-tblgen 0x000000000051be22
9 llvm-tblgen 0x000000000054f4f9
10 llvm-tblgen 0x000000000055ce65
11 llvm-tblgen 0x000000000054fb50
12 libc.so.6 0x00007fc73426ca76 __libc_start_main + 370
13 llvm-tblgen 0x00000000004071f9
Stack dump:
0. Program arguments: ./llvm-tblgen -gen-tgt-intrinsic NVPTX1.td
Segmentation fault (core dumped)

$ llvm-tblgen -gen-tgt-intrinsic NVPTX1.td
Included from NVPTX1.td:18:
NVPTXRegisterInfo.td:32:14: error: Value list is not of list type
foreach i = 0-395 in {
             ^
Included from NVPTX1.td:18:
NVPTXRegisterInfo.td:32:14: error: expected declaration in for
foreach i = 0-395 in {
             ^

====
2) Second test case: double inclusion of file, that is definitely included
once:

$ ./llvm-tblgen -gen-tgt-intrinsic NVPTX2.td
Included from NVPTX2.td:20:
NVPTXIntrinsics.td:10:1: error: def 'immFloat0' already defined
def immFloat0 : PatLeaf<(fpimm), [{
^

$ llvm-tblgen -gen-tgt-intrinsic NVPTX2.td
Included from NVPTX2.td:18:
NVPTXRegisterInfo.td:32:14: error: Value list is not of list type
foreach i = 0-395 in {
             ^
Included from NVPTX2.td:18:
NVPTXRegisterInfo.td:32:14: error: expected declaration in for
foreach i = 0-395 in {
             ^

NVPTX1.td differs from NVPTX2.td just in one line:

include "NVPTXIntrinsics.td"

Regards,
chenwj

Hi Chen,

Thanks for trying!

Your favorite llvm-tblgen 3.1 is too old. Here we need 3.2svn, should be also reproducible with TOT.

  • D.

2013/2/7 陳韋任 (Wei-Ren Chen) <chenwj@iis.sinica.edu.tw>

Includes are transitive, so it was being included more than once. With r174582
we now diagnose double inclusions and point you at the previous include
location.

-- Sean Silva

Hi Sean,

Thank you, great catch! Strange, how I missed it with grep… However, this means question 1) becomes more interesting, because it is now clear intrinsics table is included in there, but somehow llvm-lblgen crashes.

Best,

  • D.

2013/2/7 Sean Silva <silvas@purdue.edu>

The issue might be isTarget not being set anywhere. See LoadIntrinsics in
utils/TableGen/CodeGenTarget.cpp (it is called in your case with
`TargetOnly==true`)