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
30
votes
1 answer

Converting llvm .bc file to human readable .ll file

How can I generate human readable llvm bitcode (extension .ll) from the binary llvm bitcode (extension .bc) file?
pythonic
  • 20,589
  • 43
  • 136
  • 219
29
votes
2 answers

How do I get the return address of a function?

I am writing a Rust library containing an implementation of the callbacks for LLVM SanitizerCoverage. These callbacks can be used to trace the execution of an instrumented program. A common way to produce a trace is to print the address of each…
Elia Geretto
  • 387
  • 4
  • 10
29
votes
6 answers

Not using C++ exceptions by design, in llvm/clang

LLVM/Clang are considered good C++ code bases. I wonder why C++ exceptions are not used in them at all? Memory is managed using something like pools, and errors are reported with returned values and codes like in C. They are even wrapping operator…
zaharpopov
  • 16,882
  • 23
  • 75
  • 93
29
votes
1 answer

llvm OCaml bindings

I'm working on llvm OCaml bindings. I installed llvm package through opam (opam install llvm), when I use llvm in utop, I get the following error: #require "llvm";; Error: The external function 'llvm_global_succ' is not available. The opam llvm…
xysun
  • 1,995
  • 18
  • 18
29
votes
5 answers

"-Weverything" yielding "Comparing floating point with == or != is unsafe"

I have a string that I convert to a double like this: double d = [string doubleValue]; The documentation for doubleValue tells us that upon overflow, this method returns either HUGE_VAL or -HUGE_VAL. This is how I checked for this earlier: if (d ==…
NoobOverflow
  • 1,208
  • 3
  • 14
  • 19
28
votes
4 answers

LLVM vs. C-- ; how can LLVM fundamentally not be better for Haskell than C--?

I've been excited about LLVM being low enough to model any system, and saw it as promising that Apple was adopting it; but then again Apple doesn't specifically support Haskell; And, some think that Haskell would be better off with C--: That…
dr.addn
  • 423
  • 4
  • 7
28
votes
5 answers

Are llvm-gcc and clang binary compatible with gcc? - particularly mingw gcc on Windows

If I build a static library with llvm-gcc, then link it with a program compiled using mingw gcc, will the result work? The same for other combinations of llvm-gcc, clang and normal gcc. I'm interested in how this works out on Linux (using normal…
user180247
28
votes
2 answers

How can I find the size of a type?

I'm holding a Type* in my hand. How do I find out its size (the size objects of this type will occupy in memory) in bits / bytes? I see all kinds of methods allowing me to get "primitive" or "scalar" size, but that won't help me with aggregate…
Oak
  • 26,231
  • 8
  • 93
  • 152
27
votes
3 answers

Where is __dso_handle defined?

I have an unresolved symbol error when trying to compile my program which complains that it cannot find __dso_handle. Which library is this function usually defined in? Does the following result from nm on libstdc++.so.6 mean it contains that? I…
revit
  • 361
  • 1
  • 3
  • 10
27
votes
2 answers

What are canonical types in Clang?

I have a simple header parser based on clang and I get the typedefs from some source. struct _poire { int g; tomate rouge; }; typedef struct _poire kudamono; After parsing this I have a clang::TypedefDecl then I get the clang::QualType of the…
cedlemo
  • 3,205
  • 3
  • 32
  • 50
27
votes
4 answers

How to generate machine code with llvm

I'm currently working on a compiler project using llvm. I have followed various tutorials to the point where I have a parser to create a syntax tree and then the tree is converted into an llvm Module using the provided IRBuilder. My goal is to…
David Mason
  • 1,545
  • 2
  • 14
  • 14
26
votes
2 answers

How can I compile under C++11 standard in Ubuntu?

How may I compile a C++ program under the C++11 standard in Ubuntu 11.04 with the most up-to-date compiler, at best using compiler from the distribution, i.e., pre-built package.
tsaarni
  • 818
  • 1
  • 8
  • 18
26
votes
3 answers

What is LLVM and How is replacing Python VM with LLVM increasing speeds 5x?

Google is sponsoring an Open Source project to increase the speed of Python by 5x. Unladen-Swallow seems to have a good project plan Why is concurrency such a hard problem? Is LLVM going to solve the concurrency problem? Are there solutions other…
lprsd
  • 84,407
  • 47
  • 135
  • 168
26
votes
3 answers

llvm ir back to human-readable source language?

Is there an easy way of going from llvm ir to working source code? Specifically, I'd like to start with some simple C++ code that merely modifies PODs (mainly arrays of ints, floats, etc), convert it to llvm ir, perform some simple analysis and…
Dan
  • 33,953
  • 24
  • 61
  • 87
26
votes
1 answer

How to emulate thread_local in llvm-ir?

The following code is currently does not work in lli: //main.cpp extern thread_local int tls; int main() { tls = 42; return 0; } //clang++ -S -emit-llvm main.cpp && lli main.ll llvm-ir: ; ModuleID = 'main.cpp' target datalayout =…
Gaetano
  • 1,090
  • 1
  • 9
  • 25