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
20
votes
6 answers

STL/Boost equivalent of LLVM SmallVector?

I have been trying to see if I can optimize the case when having many small vectors of data. In my use case there may be 100,000+ of these vectors so the size of the vector storage is critical. Each may only have 1 or 2 elements at times but may…
Crog
  • 1,112
  • 8
  • 16
20
votes
1 answer

Compile unsafe Haskell

It seems that Haskell tries to be a safe language, and tries to help the programmer from mistakes. For example, pred/succthrows error if outside, and div 1 0 also throws. What are these safe Haskell computations, and what overhead do they cause? Is…
telephone
  • 1,131
  • 1
  • 10
  • 29
20
votes
1 answer

LLVM and compiler nomenclature

I am looking into the LLVM system and I have read through the Getting Started documentation. However, some of the nomenclature (and the wording in the clang example) is still a little confusing. The following terms and commands are all part of the…
Ephemera
  • 8,672
  • 8
  • 44
  • 84
19
votes
2 answers

Instrumenting C/C++ codes using LLVM

I just read about the LLVM project and that it could be used to do static analysis on C/C++ codes using the analyzer Clang which the front end of LLVM. I wanted to know if it is possible to extract all the accesses to memory(variables, local as well…
Himanshu Shekhar
  • 437
  • 1
  • 5
  • 16
19
votes
1 answer

Maturity of Scala-LLVM?

I'd like to know how mature the llvm-backend for Scala currently is and whether it is used in any open source project that I could have a look at.
Kim Stebel
  • 41,826
  • 12
  • 125
  • 142
19
votes
2 answers

Testing a Code-Generator Optimization

I have written a low-level optimization for the LLVM code-generator backend. Basically, the optimization will reorder assembly instructions at the basic block level to allow a later (existing) optimization to more efficiently optimize the resultant…
Zeke
  • 1,974
  • 18
  • 33
19
votes
1 answer

How to instruct clang-format to add EOL-character at file's end?

Maybe I miss something, but still didn't find such a setting. Formally speaking clang-format doesn't produce proper UNIX text files, since last lines always lack EOL-character.
ababo
  • 1,490
  • 1
  • 10
  • 24
19
votes
3 answers

Linking LLVM JIT code to external C++ functions

I'm writing a LLVM scripting engine that JIT compiles scripting code in a custom language. My problem is that I'm unable to call external functions (even the C99 erf() function is failing). For example if I extern "C" the erf function, extern "C"…
anton skvorts
  • 441
  • 1
  • 4
  • 11
19
votes
4 answers

If clang is the front end of a compiler, then why it can produce executable file?

One thing I really don't understand is about the function of clang, if clang is the front end part of the compiler, it should just do the parser work for the source code, the the remain work will be done by LLVM. But clang can produce executable…
storen
  • 1,025
  • 10
  • 22
19
votes
1 answer

Running Haskell on Xeon-Phi

Is there a way to compile Haskell to run on the Xeon Phi coprocessor? Some researchers at Intel have recently reported on the Haskell Research Compiler (that is not publicly available, which makes their results essentially irreproducible) and…
jev
  • 2,023
  • 1
  • 17
  • 26
19
votes
2 answers

LLVM 3.5 fails to link

When compiling with the experimental LLVM3.5 libraries link the following link errors appear: /usr/lib/llvm-3.5/lib/libLLVMSupport.a(Process.o): In function llvm::sys::Process::FileDescriptorHasColors(int)': (.text+0x85b): undefined reference…
Sean
  • 60,939
  • 11
  • 97
  • 136
19
votes
2 answers

Enable debug output for optimization passes from clang

I am trying to understand an existing pass in LLVM and thus trying to print the nicely written debug messages in the pass. I am doing so by using clang -debug -some-other-flags. However while compiling it says: clang: warning: argument unused during…
shrm
  • 1,112
  • 2
  • 8
  • 20
19
votes
1 answer

What is LLVM Context?

What is actually the LLVM Context? Is it the environment such as bitsize in which the code runs? What are the mwmbers of LLVMContext class? I went through http://llvm.org/docs/doxygen/html/classllvm_1_1LLVMContext.html . But Couldn't understand…
ViG
  • 455
  • 5
  • 8
19
votes
1 answer

pragma pack(1) nor __attribute__ ((aligned (1))) works

My code used to work in the past, but now the struct size suddenly is 16 bytes. It used to be 13 bytes. I recently upgraded from Xcode 4.2 to Xcode 4.3.1 (4E1019). #pragma pack(1) struct ChunkStruct { uint32_t width; uint32_t height; …
neoneye
  • 50,398
  • 25
  • 166
  • 151
18
votes
6 answers

Why am I getting the error: command 'llvm-gcc-4.2' failed with exit status 1

I am setting up os X 10.7. I am using the default install of Python: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ I use a Python based package manager called easy_install. Easy_install seems to not be able to find the…
BryanWheelock
  • 12,146
  • 18
  • 64
  • 109