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
4
votes
2 answers

XCode 4.3/4.4 typeinfo is lost for class instantiated in a dynamically loaded shared library only if class overrides a method

I ran in to an issue using dynamic_cast on objects instantiated in a runtime loaded shared library but only if the class contains a method that overrides another method. I'm using Xcode 4.3 with the "Apple LLVM 3.1 Compiler" I've compiled the same…
clemahieu
  • 1,419
  • 9
  • 9
4
votes
2 answers

How to implement dynamic objects with LLVM?

Assuming a javascript-like language, how can we implement a system such as: a = {}; a.foo = {}; a.foo.bar = 42; print a.foo['bar']; using LLVM C++ API ? I didn't find any documentation about complexe data types (such as an HashMap heriting from…
Maël Nison
  • 7,055
  • 7
  • 46
  • 77
4
votes
2 answers

__block attribute on property declarations

I have to fix some existing code that builds just fine with LLVM (on iOS) so that it builds with llvm-gcc-4.2 too. I'm done with pretty much everything, except this pattern which is found at a few places: @property (nonatomic, retain) __block id…
user1530597
  • 43
  • 1
  • 3
4
votes
2 answers

Are there any tools that assist in porting F# to OCaml?

Unfortunately, due to .NET's lack of an incremental GC (either in the MS or Mono implementation), building soft real-time software such as games with F# is problematic. I've written a language in F# that, if - a) it doesn't perform adequately in the…
Bryan Edds
  • 1,696
  • 12
  • 28
4
votes
1 answer

Segfault when using GetElementPtrInst with an ArrayRef containing more than one Value

I'm trying to write a toy compiler with LLVM and C++. But whenever I try to create a GetElementPtrInst with more than one Index there is a Segfault. The documentation about this instruction didn't help me (API-Documentation…
4
votes
1 answer

Sqlite FTS doesn't work when compiling with LLVM on iOS

I've been developing an enterprise iPad app for a while now. Since the app development started almost 2 years ago, I needed to compile my own version SQLite from source, since the default SQLite library (the sqlite3.dylib) didn't have FTS enabled by…
Bruno Koga
  • 3,864
  • 2
  • 34
  • 45
4
votes
3 answers

Specifically what does a compiler do to aggressively optimize generated bytecode?

I have been reading up on the functionality of various compilers and I've come across the term "aggressive optimization" that many compilers are reported to perform. LLVM, for example cites the following compile-time optimization…
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
4
votes
0 answers

Compiler-RT CLANG LLVM

I have GCC 4.1.2 and like to build CLANG / LLVM using this GCC compiler version ony. I need source to source translation library so that I can modify my existing source code for some requirement. Initially I faced issues regarding…
Programmer
  • 8,303
  • 23
  • 78
  • 162
4
votes
0 answers

llvm JIT target assembly instruction count

I want to print the total number of NATIVE TARGET instructions executed while executing a program using the JIT. My plan was to add a instruction (which increment a variable in memory) after EVERY instruction of the just in time compiled assembly.…
Anay
  • 209
  • 2
  • 6
4
votes
0 answers

LLVM Value sign

I'm having some problems when loading values. Here's a simple example of the IR that my compiler generates to show the problem: define i32 @main() { entry: %a = alloca i32 ; [#uses=2] store i32 1, i32* %a %r =…
4
votes
1 answer

Is there a struct type isomorphism check in LLVM 3.0?

In LLVM-3.0, named structs are always unique and pointer equality with other structurally same structs does not work. From their blog entry on LLVM-3.0 types, the highlights are mine: Identified structures are the kind we are talking about: they…
Chetan
  • 448
  • 2
  • 10
4
votes
1 answer

Status of machine code generation in LLVM?

Recently I've been looking into LLVM as a back-end for a compiler project, which looks very promising. However, it seems that LLVM can JIT code (which is very cool!) or it can export assembly for the native platform, but it can't actually create…
user793587
3
votes
1 answer

Fix a variable to a register in LLVM IR

I'm writing an LLVM pass. For a particular variable I want to use a register (machine dependant register that is). Can I specify this in LLVM IR, so that LLVM backend use that register for the variable and does not use that register for other…
MetallicPriest
  • 29,191
  • 52
  • 200
  • 356
3
votes
1 answer

catch(...) swallowing all other catches in xcode llvm 3.0

I'm trying to get googletest to run on my c++ project, and part of this involves using EXPECT_THROW(statement, expected_exception);. I'm using XCode with the "Apple LLVM Compiler 3.0" selected. All this is on Snow Leopard 10.6.8, XCode 4.2. I could…
Soup
  • 1,699
  • 15
  • 30
3
votes
1 answer

Specifying multiple files when compiling from C++ to LLVM IR using clang

I compile my C++ program to LLVM IR using the following command. clang++ -O4 -emit-llvm program.cpp -c -o program.ll -S -pthread However, now I want to do the same for multiple files. How can I do that? I want to produce one IR file after the…
pythonic
  • 20,589
  • 43
  • 136
  • 219