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

Detect nuw and nsw in LLVM IR

Please let me know how to detect the presence of instructions with nsw and nuw flags set on them in the LLVM IR.
Adarsh Konchady
  • 2,577
  • 5
  • 30
  • 50
3
votes
1 answer

Generating python.cc.js using emscripten

I am reading through the tutorial for emscripten here - https://github.com/kripken/emscripten/wiki/Tutorial as well as checking out some of the demo projects in the source on my local machine. So far, I have downloaded the source and set my…
Calvin Cheng
  • 35,640
  • 39
  • 116
  • 167
3
votes
1 answer

How to build a multifile c++ project for llvm (lli) using clang++?

I have a multifile c++ project, built with help of Makefile. CC and CXX were gcc and g++ relatively. Now I need to try this project under llvm (lli). I have replaced CC = gcc CXX = g++ LD = ld with CC = clang CXX = clang++ LD = clang++ and added…
ASten
  • 766
  • 1
  • 7
  • 23
3
votes
1 answer

Get a function declaration from another llvm::Module

In my application i have 2 LLVM modules - the runtime one (which contains void foo(int * a) function definition) and executable one (which i'm creating using LLVM C++ API). In my executable module i create int main(int argc, char ** argv) and want…
arrowd
  • 33,231
  • 8
  • 79
  • 110
3
votes
2 answers

GDB not displaying some values in eclipse

When I try to display the values of certain data structures(including STL and certain LLVM types like Instruction *) using Eclipse, it only gives me the address and not their contents. My eclipse is integrated with GDB. Please help.
Adarsh Konchady
  • 2,577
  • 5
  • 30
  • 50
3
votes
1 answer

Convert GCC makefile script to LLVM 3.0 Compiler

I'm working on an open source project for the iPhone, and have converted the project to use ARC and the Apple LLVM 3.0 compiler. However, the project relies on an external library built using a makefile as it is written in C. Currently, it uses GCC…
Riley Testut
  • 431
  • 1
  • 8
  • 22
3
votes
1 answer

Floating point status transfer on ARM7 Cortex A8

There is a comparison: if( val0 > val1 ) where val0 and val1 are double variables. The code generated by the Apple LLVM compiler is +0x184 vcmpe.f64 d17, d16 +0x188 vmrs APSR_nzcv, fpscr <-- FP…
Alex
  • 9,891
  • 11
  • 53
  • 87
3
votes
3 answers

How do I get code coverage for tests and build for iPhone in Xcode 4?

I have a couple of projects with unit tests where I want to measure coverage. So I follow the instructions detailed in the How-to for CoverStory and elsewhere on the web. I add -fprofile-arcs and -ftest-coverage to my test target and the target…
ageektrapped
  • 14,482
  • 7
  • 57
  • 72
3
votes
2 answers

How should I link to LLVM libraries?

When I use command "gcc .. ../../*.so", there are the following error messages: /usr/bin/ld: /home/demonwnb/build/src/*.so: error: undefined reference to 'llvm::raw_ostream::operator<<(void const*)' /usr/bin/ld: /home/demonwnb/build/src/*.so: error:…
kunou
  • 91
  • 1
  • 2
  • 3
3
votes
2 answers

App crashes on Apple LLVM 3.0 but works OK on LLVM GCC 4.2

I have a very strange crash when using the Apple LLVM 3.0 compiler. So there is some code, that uses Assimp to load assets and create the scene (I've excluded all my code and even then it crashes): aiScene* ai_scene =…
Max
  • 16,679
  • 4
  • 44
  • 57
3
votes
2 answers

What does "lifelong program analysis" as in LLVM description mean?

LLVM description (for example, here says it is a framework for lifelong program analysis and transformation. What does lifelong mean in this context?
sharptooth
  • 167,383
  • 100
  • 513
  • 979
3
votes
1 answer

How to load pass plugin in new pass manager?

I have written a pass-plugin for obfuscation and I would like to load this plugin using clang instead of opt in Windows. However, when I use the command .\bin\clang++.exe -O1 -Xclang -fpass-plugin='./BronyaObfus.dll' -passes=bogus-control-flow…
I3r0nya
  • 33
  • 2
3
votes
2 answers

what compiler optimizations would be needed to optimize out this recursive call?

Here are two versions of a trivial arithmetic expression evaluator (playground link: https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=d3da06b0077b29e0e3ac85720c567dd8) The second version uses a recursive call to reuse some…
ajp
  • 1,723
  • 14
  • 22
3
votes
1 answer

Why does the correct implementation of std::addressof require compiler support?

From possible implementation of std::addressof on https://en.cppreference.com/w/cpp/memory/addressof, it states that "correct implementation of std::addressof require compiler support". Why is it the case? I tried out the implementation on…
cpp
  • 265
  • 1
  • 6
3
votes
0 answers

Explain the alignment of an array in LLVM IR

Consider the following .c file: #include int main() { int a[2][3] = { 0 }; int i = 1, j = 2; int c = 10, d = 20; d = c + a[i][j]; printf("%d\n", d); return 0; } In its LLVM IR form @ Compiler Explorer, the alignment…
hengxin
  • 1,867
  • 2
  • 21
  • 42