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
53
votes
8 answers

any C/C++ refactoring tool based on libclang? (even simplest "toy example" )

As I've pointed out - here - it seems clang's libclang should be great for implementing the hard task that is C/C++ code analysis and modifications (check out video presentation and slides). Do you know of any C/C++ refactoring tool based on…
Grzegorz Wierzowiecki
  • 10,545
  • 9
  • 50
  • 88
52
votes
4 answers

Enable OpenMP support in clang in Mac OS X (sierra & Mojave)

I am using Mac OS X Sierra, and I found that clang (LLVM version 8.1.0 (clang-802.0.38)) does not support OpenMP: when I run clang -fopenmp program_name.c, I got the following error: clang: error: unsupported option '-fopenmp' It seems that clang…
Starry
  • 673
  • 2
  • 7
  • 14
50
votes
3 answers

Why does iteration over an inclusive range generate longer assembly in Rust than in C++?

These two loops are supposed to be equivalent in C++ and Rust: #include std::uint64_t sum1(std::uint64_t n) { std::uint64_t sum = 0; for (std::uint64_t j = 0; j <= n; ++j) { sum += 1; } return sum; } pub fn…
user8143588
49
votes
2 answers

Why is the LLVM execution engine faster than compiled code?

I have a compiler which targets LLVM, and I provide two ways to run the code: Run it automatically. This mode compiles the code to LLVM and uses the ExecutionEngine JIT to compile it into machine code on-the-fly and run it without ever generating…
mgiuca
  • 20,958
  • 7
  • 54
  • 70
48
votes
5 answers

LLVM vs. GCC for iOS development

In latest iOS SDK, Apple provides three compiler options: GCC, LLVM with Clang and LLVM-GCC. I understand more or less what these 3 mean, what LLVM and Clang are, and so on. What I don't know is what this means in practice for iPhone developers.…
Kuba Suder
  • 7,587
  • 9
  • 36
  • 39
48
votes
10 answers

Why isn't there a good scheme/lisp on llvm?

There is Gambit Scheme, MIT Scheme, PLT Scheme, Chicken Scheme, Bigloo, Larceny, ...; then there are all the lisps. Yet, there's not (to my knowledge) a single popular scheme/lisp on LLVM, even though LLVM provides lots of nice things like: easier…
anon
  • 41,035
  • 53
  • 197
  • 293
47
votes
1 answer

Out-of-Line Virtual Method

What exactly is a out-of-line virtual method and why does it affect link times? LLVM Coding Standards says If a class is defined in a header file and has a vtable (either it has virtual methods or it derives from classes with virtual methods),…
Daniel Eggert
  • 6,665
  • 2
  • 25
  • 41
46
votes
4 answers

Is it possible to transform LLVM bytecode into Java bytecode?

I have heard that google app engine can run any programming language that can be transformed to Java bytecode via it's JVM. I wondered if it would be possible to convert LLVM bytecode to Java bytecode as it would be interesting to run languages…
Ben Page
  • 3,011
  • 4
  • 35
  • 37
45
votes
2 answers

How does clang generate non-looping code for sum of squares?

I admit the answer to this may be 'some very specific magic', but I'm kind of shocked by what I've observed here. I was wondering if anyone had insight to how these types of optimizations work. I find compiler design to be quite interesting, and I…
beeselmane
  • 1,111
  • 8
  • 26
45
votes
2 answers

How to use clang/llvm with Eclipse CDT

Is it possible to use Clang/LLVM with Eclipse CDT and if so, how is it configured to actually make it work?
Alexander Battisti
  • 2,178
  • 2
  • 19
  • 24
45
votes
4 answers

What are the greatest benefits of LLVM?

Does anyone have experience with LLVM, llvm-gcc, or Clang? The whole idea behind llvm seems very intriguing to me and I'm interested in seeing how it performs. I just don't want to dump a whole lot of time into trying the tools out if the tools are…
Kevin
  • 25,207
  • 17
  • 54
  • 57
45
votes
2 answers

Dynamic forwarding: suppress Incomplete Implementation warning

I have a class exposing some methods, whose implementation is provided by an inner object. I'm using forward invocation to dispatch at runtime the method calls to the inner object, but XCode is complaining since it cannot find an implementation of…
Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235
39
votes
2 answers

Having LLVM IR library how to crosscompile it to iOS, Android, Windows and Mac from Ubuntu?

I have representations of all my dependencies and my library in LLVM IR forms. How to cross-compile my library into a shared object for iOS, Android, Windows and Mac platforms from Linux ( Ubuntu for example )? Please provide a single example…
DuckQueen
  • 772
  • 10
  • 62
  • 134
39
votes
1 answer

Does libcxxabi makes sense under linux? What are the benefits?

I'm trying to determine if building and using libcxxabi from the llvm project under linux makes sense. My build of libcxxabi is linked to ldd libc++abi.so.1.0 linux-vdso.so.1 => (0x00007fff2e0db000) libpthread.so.0 =>…
user2485710
  • 9,451
  • 13
  • 58
  • 102
39
votes
1 answer

Xcode 3.2.1 GCC CLANG and LLVM demystification

The readme included with the new Xcode 3.2.1 this week says the following: Static code analysis is fully integrated within the Xcode IDE via the Build and Analyze option under the Build menu or via custom build settings GCC 4.2 is the default…
slf
  • 22,595
  • 11
  • 77
  • 101