[llvm-bugs] [Bug 46708] New: Tablegen segmentation fault when using foreach loop + sequence for pattern matching

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 13 11:42:24 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46708

            Bug ID: 46708
           Summary: Tablegen segmentation fault when using foreach loop +
                    sequence for pattern matching
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: TableGen
          Assignee: unassignedbugs at nondot.org
          Reporter: aidanrbwood at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 23724
  --> https://bugs.llvm.org/attachment.cgi?id=23724&action=edit
the file containing the code that caused the segfault

Hi,

I'm currently writing a backend for a VLIW-like processor for my fourth year
design project. I was messing around with Tablegen trying to using foreach
loops to generate all of my numbered register as well as using sequences to
match those registers into RegisterClasses. I tried parsing the input with
table gen and the program segfaulted and requested I file a bug so here I am.

Below is the stack output of tablegen upon the seg fault occurring:

Included from fwipSchedule.td:8:                                                
  2 fwipRegisterInfo.td:62:12: error: Unknown token when parsing a value        
  3     def FU#in : FWIPStatReg<4,i,1,"n">;                                     
  4            ^                                                                
  5  #0 0x00005627f420c96e llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/arbwood/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:568:3
  6  #1 0x00005627f420a9e4 llvm::sys::RunSignalHandlers()
/home/arbwood/llvm/llvm-project/llvm/lib/Support/Signals.cpp:68:20            
  7  #2 0x00005627f420b035 SignalHandler(int)
/home/arbwood/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:396:31        
  8  #3 0x00007f4b2bb323c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)                                 
  9  #4 0x00005627f42473c8 llvm::TypedInit::classof(llvm::Init const*)
/home/arbwood/llvm/llvm-project/llvm/include/llvm/TableGen/Record.h:437:46
 10  #5 0x00005627f42473c8 llvm::isa_impl<llvm::TypedInit, llvm::Init,
void>::doit(llvm::Init const&)
/home/arbwood/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:58:23
 11  #6 0x00005627f42473c8 llvm::isa_impl_cl<llvm::TypedInit, llvm::Init
const*>::doit(llvm::Init const*)
/home/arbwood/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:105:36
 12  #7 0x00005627f42473c8 llvm::isa_impl_wrap<llvm::TypedInit, llvm::Init
const*, llvm::Init const*>::doit(llvm::Init const* const&)
/home/arbwood/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:131:40
 13  #8 0x00005627f42473c8 llvm::isa_impl_wrap<llvm::TypedInit, llvm::Init*
const, llvm::Init const*>::doit(llvm::Init* const&)
/home/arbwood/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:122:60
 14  #9 0x00005627f42473c8 bool llvm::isa<llvm::TypedInit,
llvm::Init*>(llvm::Init* const&)
/home/arbwood/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:142:74
 15 #10 0x00005627f42473c8 llvm::cast_retty<llvm::TypedInit,
llvm::Init*>::ret_type llvm::dyn_cast<llvm::TypedInit, llvm::Init>(llvm::Init*)
/home/arbwood/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:339:16
 16 #11 0x00005627f42473c8 llvm::TGParser::ParseValue(llvm::Record*,
llvm::RecTy*, llvm::TGParser::IDParseMode) (.localalias)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:2242:34
 17 #12 0x00005627f424c187 llvm::TGParser::ParseObjectName(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:522:26
 18 #13 0x00005627f424c187 llvm::TGParser::ParseObjectName(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:505:7
 19 #14 0x00005627f424e225 llvm::TGParser::ParseDef(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:2708:3
 20 #15 0x00005627f424f16d llvm::TGParser::ParseObject(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:3329:40
 21 #16 0x00005627f424f981 llvm::TGParser::ParseObjectList(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:3356:5
 22 #17 0x00005627f4250690 llvm::TGParser::ParseForeach(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:2844:5
 23 #18 0x00005627f424f175 llvm::TGParser::ParseObject(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:3330:48
 24 #19 0x00005627f424f981 llvm::TGParser::ParseObjectList(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:3356:5
 25 #20 0x00005627f424fffc llvm::TGParser::ParseFile()
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:3364:3           
 26 #21 0x00005627f4216a02 llvm::TableGenMain(char const*, bool
(*)(llvm::raw_ostream&, llvm::RecordKeeper&))
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/Main.cpp:102:3
 27 #22 0x00005627f3fd991a main
/home/arbwood/llvm/llvm-project/llvm/utils/TableGen/TableGen.cpp:269:22         
 28 #23 0x00007f4b2b5d70b3 __libc_start_main
/build/glibc-YYA7BZ/glibc-2.31/csu/../csu/libc-start.c:342:3                    
 29 #24 0x00005627f3fdc70e _start
(/home/arbwood/llvm/obj/bin/llvm-tblgen+0x1770e)                                
 30 PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace.                                               
 31 Stack dump:                                                                 
 32 0.      Program arguments: /home/arbwood/llvm/obj/bin/llvm-tblgen
fwipSchedule.td                                                   
 33 Segmentation fault (core dumped)

Attached is the file fwipRegisterInfo.tb which contained the offending code,
let me know if you have any questions/require additional info.

Thanks!

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200713/f57dfe49/attachment-0001.html>


More information about the llvm-bugs mailing list