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

Why compiling this Haskell program with -fllvm produces a different result?

Compiling the following program: main = print (sqrt (-7)) On OSX Yosemite, LLVM version 3.4.2, target x86_64-apple-darwin14.0.0, GHC 7.8.4 produces two different results, depending on llvm use: apple1$ ghc -fforce-recomp a.hs -o a; ./a [1 of 1]…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
24
votes
1 answer

Clang - Compiling a C header to LLVM IR/bitcode

Say I have the following trivial C header file: // foo1.h typedef int foo; typedef struct { foo a; char const* b; } bar; bar baz(foo*, bar*, ...); My goal is to take this file, and produce an LLVM module that looks something like…
Kyle Lacy
  • 2,278
  • 1
  • 21
  • 29
24
votes
2 answers

LLVM equivalent of gcc -D macro definition on commandline

I am looking for LLVM (or clang) equivalent of gcc's -D flag which enables macro definition at commandline. Any pointers would be great.
shrm
  • 1,112
  • 2
  • 8
  • 20
24
votes
1 answer

Adding Metadata to Instructions in LLVM IR

First up, I am a newbie to LLVM passes. I am trying to add metadata to instructions in LLVM after a transformation pass (with the C++ API). I intend to store this information for use by another tool in a tool chain. I have two questions regarding…
ash
  • 1,170
  • 1
  • 15
  • 24
23
votes
2 answers

Clang on Windows

First of all, I've followed "Getting Started: Building and Running Clang". In particular, I've built it according to "Using Visual Studio" section. In other words, I've built it using Visual Studio 2010. Secondly, I've manually set include and…
Alexander Shukaev
  • 16,674
  • 8
  • 70
  • 85
23
votes
3 answers

What does SCC stand for, with respect to LLVM?

I was reading through this document http://llvm.org/docs/WritingAnLLVMPass.html, where in I came across CallGraphSCCPass. I searched for SCC abbreviation, but wasn't able to find one. What does SCC stand for? Where can I read more about it?
Chethan Ravindranath
  • 2,001
  • 2
  • 16
  • 28
23
votes
4 answers

Is there any Javascript engine that emits LLVM bytecode?

I've been searching for a while now, but I could not find any engine that emits LLVM bytecode. But somehow I cannot belief there is no such engine :)
manuels
  • 1,511
  • 3
  • 14
  • 26
23
votes
2 answers

How to make a clean clang front-end?

I'm working on a C++ source analyzer project and it seems that clang is nice candidate for the parsing work. The problem is that clang heavily depends on the infrastructure "llvm" project, How do I configure it to get a clean front-end without any…
Haiyuan Li
  • 377
  • 2
  • 10
23
votes
2 answers

how to use llvm+clang to compile for stm32

Has someone infos how to build a llvm+clang toolchain using binutils and newlib and how to use it? host: Linux, AMD64 target: cortex-m3, stm32 c-lib: newlib assembler: gnu as
wermut
23
votes
1 answer

Hesitating between C/C++, OCaml, and F# for my compiler

I want to start working on a little compiler and to build it I am hesitating between several different languages. My requirements are simple, I want to be able to emit LLVM-IR code cause I have a LLVM backend I would like to reuse to target a…
Thibault Imbert
  • 433
  • 3
  • 7
23
votes
2 answers

Towards understanding CodeGen* in the Haskell LLVM bindings

Background: I am writing a toy Lisp interperter/compiler in Haskell for my own amusement/edification. I am trying to add the ability to compile to LLVM bytecode. Context: I have been reading the documentation for LLVM.Core and a code example (here)…
John F. Miller
  • 26,961
  • 10
  • 71
  • 121
23
votes
1 answer

How to replace browser javascript engine with LLVM?

As a proof of concept, I would like to get a browser to be able to run LLVM IR. The basic idea would be that any language with an LLVM compiler, would be able to work as a first class citizen on the net. (Which is why I don't want to go the LLVM IR…
Heptic
  • 3,076
  • 4
  • 30
  • 51
23
votes
1 answer

How to print dependencies from llvm / clang (equivalent of gcc -MD)?

Our build system is using gcc to generate source file's header dependencies to *.d files, when compiling: gcc -MD -MF foo.d -c foo.o foo.cc However, I can't figure out how to produce similar output with llvm clang.
Teemu Kurppa
  • 4,779
  • 2
  • 32
  • 38
23
votes
2 answers

"uses of target_link_libraries must be either all-keyword or all-plain"

I managed to build llvm and clang and now I am trying to create a ClangTool according to clang docs. But I am getting the following error when I am trying to build it: CMake Error at tools/clang/tools/loop-convert/CMakeLists.txt:6…
Horatiu Vultur
  • 265
  • 2
  • 6
23
votes
2 answers

LLVM: difference between "uses" and "user" in Instruction or Value classes

I am new in LLVM and have checked Value and Instruction classes. I see that both of these classes have the methods uses and user. What are the differences between them? Also, regarding this post, can I use these methods to determine if an…
Carlos
  • 411
  • 1
  • 3
  • 11