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

5517 questions
524
votes
5 answers

Does the C++ standard allow for an uninitialized bool to crash a program?

I know that an "undefined behaviour" in C++ can pretty much allow the compiler to do anything it wants. However, I had a crash that surprised me, as I assumed that the code was safe enough. In this case, the real problem happened only on a specific…
Remz
  • 2,899
  • 3
  • 5
  • 10
502
votes
7 answers

What exactly is LLVM?

I keep hearing about LLVM all the time. It's in Perl, then it's in Haskell, then someone uses it in some other language? What is it? What exactly distinguishes it from GCC (perspectives = safety etc.)?
bodacydo
  • 63,809
  • 83
  • 206
  • 303
290
votes
9 answers

Switching between GCC and Clang/LLVM using CMake

I have a number of projects built using CMake and I'd like to be able to easily switch between using GCC or Clang/LLVM to compile them. I believe (please correct me if I'm mistaken!) that to use Clang I need to set the following: SET…
Rezzie
  • 4,295
  • 6
  • 22
  • 30
268
votes
1 answer

How to affect Delphi XEx code generation for Android/ARM targets?

Update 2017-05-17. I no longer work for the company where this question originated, and do not have access to Delphi XEx. While I was there, the problem was solved by migrating to mixed FPC+GCC (Pascal+C), with NEON intrinsics for some routines…
Side S. Fresh
  • 2,964
  • 2
  • 13
  • 18
163
votes
5 answers

How to make clang compile to llvm IR

I want clang to compile my C/C++ code to LLVM bytecode rather than binary executable. How can I achieve that? And if I get the LLVM bytecode, how can I take it to further compile it to binary executable. Basically I want to add some of my own code…
pythonic
  • 18,049
  • 33
  • 112
  • 196
140
votes
3 answers

LLVM vs clang on OS X

I have a question concerning llvm, clang, and gcc on OS X. What is the difference between the llvm-gcc 4.2, llvm 2.0 and clang? I know that they all build on llvm but how are they different? Besides faster compiling, what is the advantage of llvm…
dominik
  • 5,313
  • 6
  • 30
  • 42
124
votes
4 answers

What languages can be compiled to WebAssembly (Wasm)?

What languages can be compiled to WebAssembly (Wasm)? I believe right now C, C++, and Rust (experimental) can be compiled to WebAssembly, with the llvm compiler backend, with languages like Java, Swift, and C# not currently being supported, but…
Jordan Stewart
  • 2,687
  • 3
  • 20
  • 32
109
votes
10 answers

clang: how to list supported target architectures?

Currently I am interested in ARM in general and specifically iphone/android targets. But I just want to know more about clang, since it feels to play important role in the years to come. I tried clang -cc1 --help|grep -i list clang -cc1 --help|grep…
exebook
  • 27,243
  • 27
  • 105
  • 196
108
votes
2 answers

Faster code-completion with clang

I am investigating potential code-completion speedups while using clang's code-completion mechanism. The flow described below is what I found in rtags, by Anders Bakken. Translation units are parsed by a daemon monitoring files for changes. This is…
Pradhan
  • 15,095
  • 3
  • 39
  • 56
94
votes
13 answers

LLVM C++ IDE for Windows

Is there some C/C++ IDE for Windows, which is integrated with the LLVM compiler (and Clang C/C++ analyzer), just like modern Xcode do. I have Dev-Cpp (it uses outdated GCC) and Code::Blocks (with some GCC). But GCC gives me very cryptic error…
osgx
  • 80,853
  • 42
  • 303
  • 470
94
votes
2 answers

What exactly PHI instruction does and how to use it in LLVM

LLVM has phi instruction with quite weird explanation: The 'phi' instruction is used to implement the φ node in the SSA graph representing the function. Typically it is used to implement branching. If I understood correctly, it is needed to make…
user730816
93
votes
4 answers

Confusing Template error

I've been playing with clang a while, and I stumbled upon "test/SemaTemplate/dependent-template-recover.cpp" (in the clang distribution) which is supposed to provide hints to recover from a template error. The whole thing can be easily stripped down…
user350814
80
votes
9 answers

View array in LLDB: equivalent of GDB's '@' operator in Xcode 4.1

I would like to view an array of elements pointed to by a pointer. In GDB this can be done by treating the pointed memory as an artificial array of a given length using the operator '@' as *pointer @ length where length is the number of elements I…
midinastasurazz
  • 1,217
  • 2
  • 10
  • 12
75
votes
4 answers

What are the differences between LLVM and java bytecode?

I dont understand the difference between LLVM and the java (bytecode), what are they? -edit- by 'what are they' i mean the differences between LLVM and java (bytecode) not what are LLVM and java.
user34537
72
votes
2 answers

How to call methods or execute code in LLDB debugger?

I know I can type print someFloatVariable when I set a breakpoint or po [self someIvarHoldingAnObject], but I can't do useful things like: [self setAlpha:1]; Then it spits out: error: '[self' is not a valid command. Weird thing is that I can call…
Proud Member
  • 38,700
  • 43
  • 143
  • 225
1
2 3
99 100