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

Xcode 4/LLVM 3.0 -- make it a little smarter about "no known instance method for selector" errors?

The following code is perfectly safe, yet Xcode 4 gives me an error for it: if ([self respondsToSelector: @selector(foo)]) [self foo]; I am aware that I can get around it with a dummy protocol, but I use this pattern pretty often, and…
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
3
votes
1 answer

What is the entry point file in LLVM and Clang?

I have setup a debugger with my Clang & LLVM projects. I want to make sure that it is working. So I want to put a breakpoint at a place where it will surely hit when I execute below command : clang -S -emit-llvm foo.c Please help me with the…
Darshan Bhat
  • 245
  • 1
  • 11
3
votes
1 answer

Clang: how to see the effect of loop flattening pass?

Clang has loop flattening pass to transform from nested loops: for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) f(A[i*M+j]); into one loop: for (int i = 0; i < (N*M); ++i) f(A[i]); However, I cannot find how to enable this loop…
pmor
  • 5,392
  • 4
  • 17
  • 36
3
votes
2 answers

How do you build all of LLVM?

I recently built and installed llvm to my system with the expectation that this would be what is neccessary to build qtcreator: https://paste.ubuntu.com/p/23GCCS5xxS/ Based on what I saw there, I set the variable as such: ➜ qt6.2 git:(6.2) ✗ echo…
Anon
  • 2,267
  • 3
  • 34
  • 51
3
votes
2 answers

Using Clang to compile for RISC-V

I am trying to build a hello world program using Clang (version 12.0.1) for RISC-V architecture. I have installed it with LLVM (version 12.0.1) with the following setup: cmake -G "Unix Makefiles" \ …
3
votes
1 answer

How to get clang-tidy to disable coloured output

A recent change to run-clang-tidy.py means that the underlying clang-tidy command is now always run with -use-color. The question is how to disable that. I use this script with the Sonarqube Community C++ plugin and this cannot handle the extra…
johnfo
  • 1,676
  • 2
  • 17
  • 28
3
votes
2 answers

How does LLVM avoid generating redundant native code for the `br` IR instruction?

For the following C code void foo() { int forty_two = 42; if (forty_two == 42) { } } clang -S -emit-llvm foo.c emits this IR code: define dso_local void @foo() #0 { %1 = alloca i32, align 4 store i32 42, i32* %1, align 4 %2 = load…
Myk
  • 1,520
  • 16
  • 19
3
votes
0 answers

clang compiler is not working for 'opt' command

opt command not working for CLANG compiler, installed CLANG and LLVM, after I ran clang++ -emit-llvm -S test.cpp -o prog.ll it is working well and good but once I tried running the 'opt' opt --dot-cfg prog.ll I am getting the error as 'opt' is not…
Anand
  • 37
  • 3
3
votes
1 answer

error: implicit instantiation of undefined template 'llvm::yaml::MissingTrait

I am working on a project which uses the LLVM YAML I/O library. This is the documentation/tutorial that I am following: https://www.llvm.org/docs/YamlIO.html I am trying to replicate the example where you define a specialization on…
Galaxy
  • 2,363
  • 2
  • 25
  • 59
3
votes
0 answers

Why does LLVM have a vector type and an array type?

I am trying to understand why LLVM has the concept of a "vector type". Could LLVM have been designed without one and could vectorization/SIMD be implemented on top of the array type? It seems to me that a [8 x float] could be mapped to a vector…
3
votes
0 answers

When calling FFI C functions from LLVM code, when is an `sret` return pointer necessary?

It appears that C functions which return structs sometimes use a magic hidden return argument carrying a pointer to some memory to be overwritten with the return value of the function. For example, a C function declared like: MyBuffer…
trbabb
  • 1,894
  • 18
  • 35
3
votes
0 answers

how to reserve a CPU register in armclang for AARCH64

I am looking to do an experiment where in I can reserve ARM CPU register, say X25 to be not used by the compiler. Looking at the armclang reference document that says, Syntax -ffixed-rN Parameters N specifies the register number, which can be any…
Thomas
  • 489
  • 1
  • 8
  • 13
3
votes
1 answer

How to match major version only in cmake

I am trying to build a project that requires LLVM 11 as a dependency. They bundle a copy of LLVM 11.0.1. I want to build it against the system version, which is LLVM 11.1.0. In the cmake build files, they have: find_package(LLVM 11.0 CONFIG) If…
matoro
  • 181
  • 1
  • 13
3
votes
1 answer

cmake/config-ix.cmake:401 (get_host_triple) error when trying to build LLVM with CMake on Windows

I want to set up a debugger for Visual Studio Code so I tried to build LLVM environment so as to have LLDB on my computer. But the build fails with following output: CMake Warning at cmake/modules/GetHostTriple.cmake:28 (message): unable to…
Vlad Tkach
  • 63
  • 6
3
votes
1 answer

Not able to build LLVM from its source code

I am referring to https://llvm.org/docs/GettingStarted.html to build the LLVM from its source code. I am using Ubuntu 18.04. $ cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo ../llvm $ cmake --build . Below are the errors: [2978/2994] Linking CXX…
Praveer Kumar
  • 912
  • 1
  • 12
  • 25
1 2 3
99
100