[Bug 36155] New: FastDemangle performance problem

Bug ID 36155
Summary FastDemangle performance problem
Product lldb
Version 6.0
Hardware PC
OS Linux
Status NEW
Severity enhancement
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter feishenniubi@gmail.com
CC llvm-bugs@lists.llvm.org

Here's a simple python program that generates a mangled string with size n:

def gen(n):                                                                     
    prefix = '_Z0'                                                              
    suffix = 'Mm0'                                                              
    content = 'M0' * (n-6)                                                      
    return prefix + content + suffix

lldb's FastDemangler exhibit quadratic behavior when demangling such a string.
On my laptop (2015 Thinkpad t440p Arch Linux), setting n to ~20000 will cause a
noticable slowdown, and ~50000 would just segfault the program.

The same inputs are rejected instantly by itaniumDemangle() as well as c++filt.