Questions tagged [llvm]

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. The llvm tag is mostly for writing C++ code (or another language via the C bindings) to interface with the LLVM library, not about any of the (growing amount of) tools that have LLVM under the hood. See the `llvm-codegen` tag for questions about machine code generated by LLVM.

Welcome to the LLVM Project.

The LLVM Core libraries provide a modern source- and target-independent optimizer, along with code generation support for many popular CPUs (as well as some less common ones!).

These libraries are built around a well specified code representation known as the LLVM intermediate representation ("LLVM IR").

The LLVM Core libraries are well documented, and it is particularly easy to invent your own language (or port an existing compiler) to use LLVM as an optimizer and code generator.

As much as everything else, LLVM has a broad and friendly community of people who are interested in building great low-level tools. If you are interested in getting involved, a good first place is to skim the LLVM Blog and to sign up for the LLVM Developer mailing list.

What not to ask: user-level questions about XCode are off-topic, please only use the tag for those. The tag is mostly for writing C++ code (or another language via the C bindings) to interface with the LLVM library, not about any of the (growing amount of) tools that have LLVM under the hood.

Books

6394 questions
23
votes
4 answers

Getting the original variable name for an LLVM Value

The operands for an llvm::User (e.g. instruction) are llvm::Values. After the mem2reg pass, variables are in SSA form, and their names as corresponding to the original source code are lost. Value::getName() is only set for some things; for most…
Will
  • 73,905
  • 40
  • 169
  • 246
23
votes
3 answers

How to check the LLVM compiler version Xcode is using?

I'm using Xcode 4.5.2 on OS X 10.8.2. How do I know which version of LLVM compiler Xcode is using?
4ae1e1
  • 7,228
  • 8
  • 44
  • 77
23
votes
2 answers

Clang 3.1 and C++11 support status

From clang's C++11 support status website, http://clang.llvm.org/cxx_status.html , it says, "Initializer List" and "Lambda Expression" are all supported starting from version 3.1. However, using LLVM/Clang trunk (3.2), compiling against initializer…
will
  • 589
  • 1
  • 7
  • 15
22
votes
2 answers

How to use clang with mingw-w64 headers on windows

I have clang 3.9 from http://llvm.org/releases/3.9.0/LLVM-3.9.0-win32.exe clang version 3.9.0 (branches/release_39) Target: i686-pc-windows-msvc Thread model: posix InstalledDir: C:\Program Files\LLVM\bin And gcc 6.2.0 (Mingw-w64) gcc…
Konrad
  • 6,385
  • 12
  • 53
  • 96
22
votes
7 answers

Creating a VHDL backend for LLVM?

LLVM is very modular and allows you to fairly easily define new backends. However most of the documentation/tutorials on creating an LLVM backend focus on adding a new processor instruction set and registers. I'm wondering what it would take to…
aneccodeal
  • 8,531
  • 7
  • 45
  • 74
22
votes
4 answers

LLVM jit and native

I don't understand how LLVM JIT relates to normal no JIT compilation and the documentation isn't good. For example suppose I use the clang front end: Case 1: I compile C file to native with clang/llvm. This flow I understand is like gcc flow - I…
zaharpopov
  • 16,882
  • 23
  • 75
  • 93
22
votes
5 answers

Force a function to be inline in Clang/LLVM

Is there a way to force an inline function in Clang/LLVM? AFAIK, the following is just a hint to the compiler but it can ignore the request. __attribute__((always_inline)) I don’t mind that the compilation will fail if it can’t inline the function.
DavidS
  • 2,160
  • 1
  • 19
  • 22
22
votes
3 answers

Call LLVM Jit from c program

I have generated a bc file with the online compiler on llvm.org, and I would like to know if it is possible to load this bc file from a c or c++ program, execute the IR in the bc file with the llvm jit (programmatically in the c program), and get…
Damien
  • 221
  • 1
  • 2
  • 4
21
votes
5 answers

Is it possible to compile LLVM libraries to android/ARM

I'm fascinated by the Pure algebraic/functional language. The Pure interpreter uses the LLVM JIT compiler as its backend. I would like to compile Pure so that it runs on Android(ARM). Pure has a dependency on the LLVM JIT. So I need to compile LLVM…
Sid Kshatriya
  • 4,965
  • 3
  • 25
  • 29
21
votes
3 answers

Why does clang still need libgcc.a to compile my code?

int main(int argc, char **argv) { return 0; } I cross compile (host= linux x86_64, target= linux aarch64) /path/to/clang --target=aarch64-linux-gnu -v main.cpp -o main -fuse-ld=lld -L./libs -lc -lc_nonshared -Xlinker -Map=a.map In the -L./libs…
robor
  • 2,969
  • 2
  • 31
  • 48
21
votes
2 answers

How do I compile with "ffast-math"?

I'm trying to benchmark some Rust code, but I can't figure out how to set the "ffast-math" option. % rustc -C opt-level=3 -C llvm-args='-enable-unsafe-fp-math' unrolled.rs rustc: Unknown command line argument '-enable-unsafe-fp-math'. Try: 'rustc…
yong
  • 3,583
  • 16
  • 32
21
votes
1 answer

How to properly insert a function call using LLVM?

I'm trying to set up a pass that will insert a couple of global variables as well as a couple of function calls at the beginning of main. However, I believe I have an issue with setting up the function description correctly. My code compiles, but…
Josh
  • 681
  • 2
  • 6
  • 16
21
votes
3 answers

Dump IR after each LLVM optimization (each pass), both LLVM IR passes and backend debugging

I want to find some debugging options for Clang/LLVM which work like GCC's -fdump-tree-all-all, -fdump-rtl-all, and -fdump-ipa-all-all. Basically, I want to have an LLVM IR dump before and after each optimization pass. Also, it can be useful to have…
osgx
  • 90,338
  • 53
  • 357
  • 513
21
votes
1 answer

Why do byte spills occur and what do they achieve?

What is a byte spill? When I dump the x86 ASM from an LLVM intermediate representation generated from a C program, there are numerous spills, usually of a 4 byte size. I cannot figure out why they occur and what they achieve. They seem to "cut"…
d0rmLife
  • 4,112
  • 7
  • 24
  • 33
21
votes
2 answers

LLVM bitcode cross-platform

Just to be sure: Is LLVM bitcode cross-platform? By which I mean, can the generated IR (".bc") file be distrubuted and interpreted/JITed over various platforms? If so, how does Clang convert C++ into platform independend code? While in the C++…
Tim
  • 5,521
  • 8
  • 36
  • 69