Tapir-LLVM icon indicating copy to clipboard operation
Tapir-LLVM copied to clipboard

Can't demangle outlined function names

Open ehein6 opened this issue 5 years ago • 4 comments

During outlining, Tapir creates a new function name by concatenating the name of the original function with the name of the outlined block.

https://github.com/wsmoses/Tapir-LLVM/blob/681753321c1a53c248e3c957aa0835c25704b3fe/lib/Transforms/Tapir/Outline.cpp#L241

When compiling C++, the new name can no longer be demangled by tools like c++filt, the additional characters break the format.

$ echo "_ZN10hybrid_bfs36top_down_step_with_migrating_threadsEv" | c++filt
hybrid_bfs::top_down_step_with_migrating_threads()
$ echo "_ZN10hybrid_bfs36top_down_step_with_migrating_threadsEv_if.end.i.i.i.i20.i.i.otd1" | c++filt
_ZN10hybrid_bfs36top_down_step_with_migrating_threadsEv_if.end.i.i.i.i20.i.i.otd1

Not sure what the fix is here, perhaps we can demangle, append, and remangle?

ehein6 avatar Aug 09 '19 19:08 ehein6

Just noticed the related issue https://github.com/wsmoses/Tapir-LLVM/issues/78, I guess the current solution is to strip everything after .outline_ and then demangle?

ehein6 avatar Aug 09 '19 20:08 ehein6

That solution should do the trick, yes. Does that work for your case? I'm happy to take other suggestions.

neboat avatar Aug 09 '19 21:08 neboat

I'm torn. On the one hand, demangling via c++filt should "just work" without the need for additional tooling. On the other hand, fully qualified names and template instantiations make the demangled output pretty unreadable anyways, so adding one more layer of pre-processing is not a big deal.

ehein6 avatar Aug 12 '19 12:08 ehein6

LLVM does come with its own version of c++filt, in llvm-cxxfilt. Perhaps we can think about defining a scheme to mangle/demangle names of outlined functions for Cilk programs, and then extending Tapir/LLVM to implement that scheme in llvm-cxxfilt. I haven't investigated how hard this would be, but maybe it's not hard.

neboat avatar Aug 12 '19 12:08 neboat