r/LLVM • • Sep 22 '17

Building the kernel with clang

Thumbnail
lwn.net
0 Upvotes

r/LLVM • • Sep 02 '26

interview question for ML Compiler role

0 Upvotes

[Need Help] Can you guys please suggest me some DSA questions and genral compiler questions in the interview, recently I have been getting lot of call for this

It would be very helpful if you can also share your interview experience

My background: working on hardware backend, for compute optimisation


r/LLVM • • Aug 23 '26

LLVM for the Rest of Us

Thumbnail
reddit.com
0 Upvotes

r/LLVM • • Feb 26 '20

kotlinx-llvm: LLVM Kotlin Style! Checkpoint #1

Thumbnail self.devblogs
0 Upvotes

r/LLVM • • Jun 03 '22

Sorry if a dumb question

0 Upvotes

I’m really new, yet really excited about llvm. Do any of the llvm libraries come pre installed on either android or Mac systems, or do they need to be manually do they need to be manually downloaded and configured?

Thanks for your help


r/LLVM • • Jan 07 '20

Can't find lli and lli

0 Upvotes

Why I can't find lli or llc tools in LLVM under windows?


r/LLVM • • Apr 14 '22

It's it possible to skip parsing C++ headers?

0 Upvotes

I hear a major amount of compiler time for LLVM and C++ is used re-parsing and re-checking all headers every time it starts compiling a new C++ file that uses them.

For example: "In the case of C++ templates, the header file doesn't contain an actual, e.g. 'vector', but instructions on how to build a vector. Every time we build a source file that #includes <vector>, the compiler has to build new vector code, perhaps multiple times if we are instantiating vectors with different template parameters."

In my particular situation, I'm creating my own compiler and can guarantee these are correct in advance.

Is it possible to simply not include header analysis when compiling a program using LLVM?


r/LLVM • • Dec 30 '22

DBT NSFW

0 Upvotes

Hello, are there any resources or documents related to actual combat projects for dynamic binary translation technology?


r/LLVM • • Sep 11 '26

Building a Java-like native language on LLVM: Ironwood

0 Upvotes

I have been working on a new language called Ironwood. The goal is to preserve the programming model Java developers are familiar with, including classes, interfaces, inheritance, generics, exceptions, packages, and ordinary references, while compiling ahead of time to native executables through LLVM.

It does not target JVM bytecode and does not carry a JVM, JIT, or garbage collector into the executable. It has its own frontend and IR, performs closed-world analysis, then lowers to LLVM IR for optimization and native code generation.

One of the more unusual parts is memory management. Ironwood uses explicit free, but the compiler only accepts a free operation when it can prove that no live alias can subsequently observe the object. There are no raw C-style pointers and no unsafe fallback.

The compiler itself is written in Java. I have used LLMs to help implement it, while the design, semantics, and architecture of the language are defined by me and documented in the project.

I am especially interested in feedback from people who know LLVM and compiler internals better than I do. I would like to know whether the overall approach makes sense, what I may be overlooking, and where the compiler could be improved. If anyone finds the project interesting and would like to help improve it, contributions would be very welcome.

GitHub: https://github.com/ironwood-lang/ironwood


r/LLVM • • Jul 23 '26

Compiling Js Syntax to LLVM IR

4 Upvotes

Hi LLVM friends!

My name is Jordan and I am one half of a two person lil lab we call Ohnrshyp. A few months ago, I got very curious if it was possible to create our own language that would replace the javascript we were writing for an audio supply chain solution we have open sourced.

What we ended up creating was a new programming language, and associated kernel, that takes parts of js syntax, but applies the memory strictness of a c, without too much mental overhead.

The language (ohnrscript) can compile either within the v8 engine, or via LLVM-IR as machine code. We even have a unikernel which can serve http that is testable in just a few minutes via docker.

Ohnrscript is self hosted, and turing complete, and now publically available on github for anyone to begin writing with! - https://github.com/Ohnrshyp/Ohnrscript

If anyone is curious in how to write with it, we have a full developer guide as well, and I am more than happy to answer questions :)


r/LLVM • • Jan 12 '21

Why we need LLVM?,What it can do that GCC can't do?,Why it's matter ? and How is that make a big difference ?.

7 Upvotes

I wondering what llvm is capable of i read some stuff on internet but im wondering my above questions i cant find any answers for that. I know about the IR but hows that matter, like what clang could do that GCC cant and why it's matter.


r/LLVM • • Apr 03 '26

How do I contribute to llvm ?

4 Upvotes

I know cpp and would like to get better at it by working llvm how do I actually contribute?


r/LLVM • • May 19 '19

GitHub - pdziepak/codegen: Experimental wrapper over LLVM for generating and compiling code at run-time.

Thumbnail
github.com
3 Upvotes

r/LLVM • • Feb 02 '19

Optimizing Rust's RangeInclusive external iteration.

3 Upvotes

Hello,

For the past few week-ends I have been banging my head trying to get LLVM to optimize the external iteration of Rust RangeInclusive. The idea of RangeInclusive is simple, given two values start and end, iterate over [start, end]. The difficulty lies in the fact that unless with the semi-exclusive range [start, end) denoting the "end" of the iteration is relatively difficult.

My goal has been to:

  1. Have LLVM understand the loop structure, optimizing it out (closed form solution) when possible.

  2. When LLVM fails to do so, have a single conditional jump in the "hot" loop.

Note: the current implementation succeeds at (1), my implementation succeeds at (2), I am looking for an implementation which succeeds at both in order to be optimal whether LLVM succeeds to optimize out the loop or not.

You can follow my progress on r/Compilers; and notice that it stalled, unfortunately.

In case you prefer C++ code, it can be found on godbolt; I invite you to play with it, but reproduced it below in full for those not wishing to follow the link.

I am looking for clues:

  • in either a better implementation of RangeInclusive,

  • or a way to better understand why LLVM fails to optimize, and how to solve the issue.

I have played with -print-after-all, which is what enabled me to come this far by comparing the output at various stages for various implementations which succeeded at one or the other goal, but honestly it was not principled at all... and even sleeping on it I've run out of ideas.

I think the key to it all would be to get LLVM to realize that iterating over [start, end] is really iterating over [start, end) and then using end, which is what the internal iteration (range.for_each([&](int j) { count +=j; });) does and which produces optimal code. Unfortunately, I have not managed to replicate this with external iteration.


Full code in C++.

The "full sugar" version assumes an imaginary RangeInclusive::next method returning std::optional<T>, allowing to write:

int triangle(int n) {
    int count = 0;
    auto range = RangeInclusive<int>(0, n);
    while (auto j = range.next()) { count += j; }
    return count;
}

I have managed to find a "fully inlined" implementation which succeeds in generating optimal code:

int triangle_inlined(int n) {
    int count = 0;
    {
        int start = 0;
        bool is_done = false;

        while (true) {
            if (start < n) {
                count += start;
                start += 1;
                continue;
            }

            if (!is_done && start == n) {
                count += start;
                is_done = true;
                continue;
            }

            break;
        }
    }
    return count;
}

Generating the following assembly (beautiful, no?):

triangle_inlined(int):                  # @triangle_inlined(int)
    xor     ecx, ecx
    test    edi, edi
    cmovns  ecx, edi
    lea     eax, [rcx - 1]
    imul    rax, rcx
    shr     rax
    add     eax, ecx
    ret

Unfortunately, applying the minimum amount of "de-inlining" as possible -- computing std::optional<int> prior to using it, rather than inlining the operation -- foils LLVM:

int triangle_barely_sugared(int n) {
    int count = 0;
    {
        int start = 0;
        bool is_done = false;

        while (true) {
            bool is_set;
            int next;
            
            //  start RangeInclusive::next
            if (start < n) {
                int result = start;
                start += 1;
                //  return from RangeInclusive::next
                next = result;
                is_set = true;
            } else if (!is_done && start == n) {
                is_done = true;
                //  return from RangeInclusive::next
                next = start;
                is_set = true;
            } else {
                //  return from RangeInclusive::next
                is_set = false;
            }

            if (is_set) {
                count += next;
                continue;
            }

            break;
        }
    }
    return count;
}

And gives the following assembly:

triangle_barely_sugared(int):           # @triangle_barely_sugared(int)
    xor     edx, edx
    xor     ecx, ecx
    xor     eax, eax
    cmp     edx, edi
    jge     .LBB0_3
    jmp     .LBB0_2
.LBB0_5:
    add     eax, edx
    mov     edx, esi
    cmp     edx, edi
    jge     .LBB0_3
.LBB0_2:
    lea     esi, [rdx + 1]
    jmp     .LBB0_5
.LBB0_3:
    jne     .LBB0_6
    mov     esi, edi
    mov     edx, edi
    test    cl, cl
    mov     cl, 1
    je      .LBB0_5
.LBB0_6:
    ret

This succeeds at the second goal: the hot loop (.LBB0_3 <-> .LBB0_5) has a single conditional jump. Unfortunately, since there's a hot loop, it means LLVM failed to optimize it out.


r/LLVM • • Feb 14 '19

How to modify llvm to achieve obfuscation instructions

1 Upvotes

What part of the code i need to modify and what I need to pay attention


r/LLVM • • Oct 06 '21

Here are LLVM 13 and Clang 13 compiled release binaries for Ubuntu 16.04, if anyone needs them!

Thumbnail
github.com
1 Upvotes

r/LLVM • • Nov 11 '24

Implement a side-channel attack using LLVM on branch predictor

0 Upvotes

Hi guys! Any idea on how can I implement a side-channel attack using LLVM?

It can be any known attack, I just want to do it using LLVM to be able to log the information.

P.S.: I just started LLVM and I'm an absolute beginner.


r/LLVM • • Jan 03 '19

Failed to use LLVM libraries on Windows

1 Upvotes

I've been using the LLVM release build from here https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows. When I build a simple cpp file that references to LLVM library, the compiler crashes. I'm using x64 cl as the compiler.

The command I'm using is roughly: cl -I <llvm include directory> main.cpp %libs% /link /LIBPATH:<llvm lib directory>

The %libs% variable is set to be the output of llvm-config --libnames all --system-libs

I'm new to using LLVM, please help if you know what's gone wrong.


r/LLVM • • Jan 05 '26

I just made an OCaml to LLVM IR compiler front-end đŸȘ Will this help me get a Compiler job?

Thumbnail
github.com
1 Upvotes

r/LLVM • • Sep 08 '25

Need help in regards to building my own deep learning compiler

1 Upvotes

i am on a mission of building our own deep learning compiler. but the thing is whenever i search for resources to study about the deep learning compiler, only the inference deep learning compiler is being talked about. i need to optimize my training process, ie build my own training compiler , then go on to build my inference compiler. it would be great of you , if you could guide me towards resources and any roadmap , that would help our mission. point to any resources for learning to build my own deep learning training compiler. i also have a doubt if there lies any difference between training and interference compiler , or they are the same. i search r/Compilers , but every good resources is like being gatekept.


r/LLVM • • Jul 01 '21

Tempted to exclude LLVM from the Hutter Prize for Lossless Compression of Human Knowledge

0 Upvotes

UPDATE: llvm.org is back up.

My Ryzen 3700X segfaults upon executing the recent entries to the Hutter Prize (for which I am a judge) apparently because, starting with STARLIT, those recent entries are generated by LLVM to compile. (NB: Compilation itself doesn't segfault.) Report a bug? Nope. http://llvm.org doesn't work and their github repo directs there.


r/LLVM • • May 11 '21

Speedbuilding LLVM/Clang in 5 minutes

Thumbnail
cambus.net
5 Upvotes

r/LLVM • • Oct 31 '16

Finding bugs in the code of LLVM project with the help of PVS-Studio

Thumbnail
viva64.com
2 Upvotes

r/LLVM • • Jan 10 '22

Why does clang fail with error: reference to local binding 'a' declared in enclosing function 'f'

2 Upvotes

This testcase fails in clang-13 and I don't understand why:

#include <tuple>

std::tuple<int,int> x() {
	return {1,2};
}

void f() {
    auto [a, b] = x();
    auto l = [&]() {
        return a+b;
    };
}

Why does it fail?