question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

support the ParseIRFile API in llvmlite

See original GitHub issue

Feature request

Here is the thing. I wrote some C++ code for a new Numba type and its operations. At first, I compiled the C++ code into a pythonic .so file, and using ir.FunctionType to declare the C++ function, then generate the call IR to call the underlying C++ function. But awfully, I have to call this C++ functions frequently and switch the context from jitted function to .so, and back and forth many times. Thus this hurts the performance.

After a discussion with @gmarkall , I have to compile the C++ code to generate LLVM IR (say, from a foo.cpp to a foo.ll), read and convert it as a llvmlite IR module (during Numba compilation process, I guess this is kind of similar with @cuda.jit(link=[foo.cu]), then link it in the jitted IR module (the main module). Thus, LLVM can do some tricks about function inlining to avoid creating a new stack frame, switch registers, etc, to save much time.

But, llvmlite doesn’t provide this kind of interface/wrapper for the LLVM ParseIRFile API (I guess the corresponding API in nvptx is nvrtcCreateProgram). Say, I can use clang to convert a C++ file to the corresponding IR file (e.g., from foo.cpp to foo.ll), and stuck in this place.

So, I think this is a feature request. And I want to contribute a wrapper for this specific API in llvmlite. Or maybe we can discuss an alternative way to fulfill my goal.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
esccommented, Sep 14, 2022

@dlee992 thank you for opening this. I have labelled this as a feature request and we probably ought to discuss this during the developer meeting next week. 👍

0reactions
esccommented, Sep 14, 2022

Oh, yes, I could do this by using parse_assembly after reading the ll file into a string. Many thanks! Very awkward, I guess I’m just frightened by these magic things, and forgot the basic process to do this.

Awesome! OK to close this issue again?

Read more comments on GitHub >

github_iconTop Results From Across the Web

IR layer—llvmlite.ir - Read the Docs
The llvmlite.ir module contains classes and utilities to build the LLVM intermediate representation (IR) of native functions.
Read more >
numba/llvmlite: A lightweight LLVM python binding ... - GitHub
The IR builder is pure Python code and decoupled from LLVM's frequently-changing C++ APIs. Materializing a LLVM module calls LLVM's IR parser which...
Read more >
How do I parse LLVM IR - Stack Overflow
I have LLVM IR code in text format. What I wanna do is to be able to parse it and modify that code....
Read more >
llvmlite Documentation - Read the Docs
A lightweight LLVM-Python binding for writing JIT compilers llvmlite provides a Python binding to LLVM for use in Numba.
Read more >
llvmlite - PyPI
A Lightweight LLVM Python Binding for Writing JIT Compilers · A small C wrapper around the parts of the LLVM C++ API we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found