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

stringstream sgetn returns NULL on iOS 5.1

i have a code that copies contents of std::stringstream to char * dest static size_t copyStreamData(std::stringstream & ss, char * const & source, char * dest) { ss.str(""); ss.clear(); ss << source; size_t…
Alkimake
  • 1,797
  • 14
  • 30
3
votes
3 answers

Running a program compiled from clang+llvm on another machine

I am compiling a program through clang+llvm (version 3.1) and trying to run it on a computer which also has the same clang+llvm version. I'm compiling on Ubuntu 10, but the other computer where I'm trying to run has CentOS 5. There (in CentOS), I…
pythonic
  • 20,589
  • 43
  • 136
  • 219
3
votes
1 answer

Compatibility between GCC and LLVM

I'm working on a project that is cross platform, and on OS X one section must be built with clang/llvm because it creates a Cocoa window, the rest of the project is built with GCC. This is compiled into a static library which is linked into the…
grivescorbett
  • 1,605
  • 1
  • 21
  • 29
3
votes
1 answer

Replacing instructions in LLVM

I want to replace the call to malloc with call to cumemhostalloc function. float *h_A=(float *)malloc(size); should be replaced with cuMemHostAlloc((void **)&h_A,size,2); I use the following code for this, *if (dyn_cast (j)) { …
user1203259
  • 95
  • 1
  • 6
3
votes
1 answer

llvm g++ and boost function

I'm trying to dertermine if the time overhead introduced by boost::function to evaluate mathematical functions is negligeable versus using function templates. The code for the benchmark I use is bellow. With traditionnal g++, overhead with…
user744629
  • 1,961
  • 1
  • 18
  • 27
3
votes
1 answer

Identify array type in IR

I have been trying to identify array access in IR by making use of following code: for (BasicBlock::iterator ii = BB->begin(), ii2; ii != BB->end(); ii++) { Instruction *I=ii; if(GetElementPtrInst *getElePntr =…
shashikiran
  • 369
  • 1
  • 5
  • 17
3
votes
1 answer

Error linking LLVM

Whenever I create two separate libraries with LLVM 3.0 and link them together. I always get the following stack trace on exit. Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address:…
srossross
  • 1,353
  • 11
  • 16
3
votes
1 answer

Unbalanced stack warnings from LLVM bindings

After weeks of effort I have managed to write F# programs that use LLVM for JIT compilation. However, whenever I run my programs in Visual Studio 2010 with the debugger attached (i.e. by pressing F5) I get the following warning: Now, I get this…
J D
  • 48,105
  • 13
  • 171
  • 274
3
votes
2 answers

Is the Phoenix compiler tools project still alive?

I'm looking around for a modern tool chain to help in developing a small programming language/DSL. I would like to explore Phoenix from MS Research, but it looks like a dead project. Is that the case, and should I be looking elsewhere? I'd like to…
Andrew Matthews
  • 3,006
  • 2
  • 29
  • 42
3
votes
1 answer

Crash at any optimization level other than -o0 in iOS

The following two pieces of code works fine when optimization level is -o0. But, when the optimization level is anything other than -o0, the first code crashes at some point, but the seconds does not crash. could you please explain why? 1. unsigned…
Erik Sapir
  • 23,209
  • 28
  • 81
  • 141
3
votes
1 answer

'main' function not found in module when using llvm bindings with Haskell

I'm trying to use Haskell's LLVM bindings to create a very simple 'hello world' standalone app. The idea is, when I run my Haskell application, it will spit out some bytecode that can in turn be run and will output "hello world!" -- hellofunc prints…
Vlad the Impala
  • 15,572
  • 16
  • 81
  • 124
3
votes
2 answers

Check for sgt in icmp instruction

%4 = icmp sgt i32 %2, %3 For the above instruction, how can I check whether the icmp instruction contains sgt or slt?
Adarsh Konchady
  • 2,577
  • 5
  • 30
  • 50
3
votes
1 answer

CUDA support in clang

I am trying to convert a simple CUDA program to LLVM IR using Clang 3.0. The program is as follows, #include #include __global__ void kernfunc(int *a) { //kernel definition *a = threadIdx.x +…
user1203259
  • 95
  • 1
  • 6
3
votes
1 answer

How to link elf static libs in llvm?

I have a lib (*.a) file, created with armcc in the elf format. There is no possibility to recompile it with llvm or gcc. (It's assembler written for armcc). Linking it with the gnu ld works fine on Linux, but I have problems doing it on Mac, with…
Sam
  • 19,708
  • 4
  • 59
  • 82
3
votes
2 answers

Cannot build LLVM and Clang

I have tried to compile clang and llvm using the clang getting started manual. However, at step 5, when I do make, I get the following error. Any idea what is going on here, and how to fix it? Note that I am using Ubuntu 10.04 on a 64 bit x86…
MetallicPriest
  • 29,191
  • 52
  • 200
  • 356