Syed Ahmed via llvm-dev
2019-Oct-28 22:36 UTC
[llvm-dev] Function name demangle on clang vs clang++
Hi all, I'm a LLVM newbie and am working on a LLVM 3.5 code base. The project ( https://github.com/zhguanw/lin-analyzer) makes use of clang and reads C code. I'm trying to make it read C++ code. When I compile a kernel written in C with clang++, I get the following difference in the IR for a function declaration: When compiled with clang: declare void @convolution3d(float*, float*) #1 When compiled with clang++: declare void @_Z13convolution3dPfS_(float*, float*) #2 The project breaks if I compile with clang++ because it expects the function name to not have the @_Z13*PfS. Does anyone know how I can get the function name in the IR generated by clang++ to not have the mangled characters? Once again, this is in LLVM 3.5. Best, Syed Ahmed PhD Student Implementation of Computation Group UPenn -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191028/977f5bca/attachment.html>
David Blaikie via llvm-dev
2019-Oct-28 22:44 UTC
[llvm-dev] Function name demangle on clang vs clang++
This is more of a general C and C++ question than one suitable to the LLVM discussion list, I think? You can modify the source itself - https://en.cppreference.com/w/cpp/language/language_linkage - discusses the extern "C" directive and how it can be used to expose C-linkage functions from C++ translation units (so, if you have a function with C API, but an implementation written in C++, this is how to do that) On Mon, Oct 28, 2019 at 3:37 PM Syed Ahmed via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi all, > > I'm a LLVM newbie and am working on a LLVM 3.5 code base. The project ( > https://github.com/zhguanw/lin-analyzer) makes use of clang and reads C > code. I'm trying to make it read C++ code. When I compile a kernel written > in C with clang++, I get the following difference in the IR for a function > declaration: > > When compiled with clang: > declare void @convolution3d(float*, float*) #1 > > When compiled with clang++: > declare void @_Z13convolution3dPfS_(float*, float*) #2 > > The project breaks if I compile with clang++ because it expects the > function name to not have the @_Z13*PfS. Does anyone know how I can get > the function name in the IR generated by clang++ to not have the mangled > characters? Once again, this is in LLVM 3.5. > > Best, > > Syed Ahmed > PhD Student > Implementation of Computation Group > UPenn > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191028/82764b26/attachment.html>
Joerg Sonnenberger via llvm-dev
2019-Oct-28 22:45 UTC
[llvm-dev] Function name demangle on clang vs clang++
On Mon, Oct 28, 2019 at 06:36:45PM -0400, Syed Ahmed via llvm-dev wrote:> I'm a LLVM newbie and am working on a LLVM 3.5 code base. The project ( > https://github.com/zhguanw/lin-analyzer) makes use of clang and reads C > code. I'm trying to make it read C++ code. When I compile a kernel written > in C with clang++, I get the following difference in the IR for a function > declaration:clang++ will implicitly force C++ mode for all input. If you really want to use it to compile C code and not have mangled names, you need to add the appropiate extern "C" markers. Joerg
Syed Ahmed via llvm-dev
2019-Oct-28 22:49 UTC
[llvm-dev] Function name demangle on clang vs clang++
Thank you David and Joerg! Best, Syed On Mon, Oct 28, 2019 at 6:45 PM Joerg Sonnenberger via llvm-dev < llvm-dev at lists.llvm.org> wrote:> On Mon, Oct 28, 2019 at 06:36:45PM -0400, Syed Ahmed via llvm-dev wrote: > > I'm a LLVM newbie and am working on a LLVM 3.5 code base. The project ( > > https://github.com/zhguanw/lin-analyzer) makes use of clang and reads C > > code. I'm trying to make it read C++ code. When I compile a kernel > written > > in C with clang++, I get the following difference in the IR for a > function > > declaration: > > clang++ will implicitly force C++ mode for all input. If you really want > to use it to compile C code and not have mangled names, you need to add > the appropiate extern "C" markers. > > Joerg > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191028/e5bcd9ac/attachment.html>