llvm

Generate LLVM C++ API code as backend

邮差的信 提交于 2019-11-28 06:58:07
The Online LLVM demo page had an option to generate LLVM C++ API code as backend from a source code. However, that demo page is now disabled. I was wondering how we can do it ourselves using the available LLVM tools. I tried the following clang++ -c -emit-llvm input.cpp -o input.ll llc -march=cpp -o input.ll.cpp input.ll which gives the following error llc: error: invalid target 'cpp'. I am using LLVM/Clang version 3.2. Eli Bendersky The LLVM C++ backend has to be enabled during configuration when building LLVM. It's enabled by default in the configure (autotools) build, but not in the CMake

Clang 3.1 and C++11 support status

天大地大妈咪最大 提交于 2019-11-28 06:51:34
From clang's C++11 support status website, http://clang.llvm.org/cxx_status.html , it says, "Initializer List" and "Lambda Expression" are all supported starting from version 3.1. However, using LLVM/Clang trunk (3.2), compiling against initializer list and lambda expression will yield error messages. Does anyone know if Clang >3.1 supports those features? By default, clang++ will not enable the C++11 features - you have to pass an additional flag during compilation . clang++ -std=c++11 [input files...] Or # enables some additional C++11 extensions GCC has clang++ -std=gnu++11 [input files...]

Best Compiler Destination

蹲街弑〆低调 提交于 2019-11-28 06:04:07
I've got a few languages I've been building as interpreters. When I'm ready to take "that next step", what options are best for non-native compiled formats... what are the pros and cons of each? I've been looking at compiling to CLR or LLVM, and contemplated C-midcompile a few times, but I'm not completely certain. A few features I'm hoping to be able to port are as follows: REPL - One of the languages I'm building supports block-level evaluation during runtime. Robust Macros - One of the languages I'm building requires the ability to filter through code seperately before tokenizing, and in

How to link object to libraries with LLVM >= 3.1 ? ( no GNU ld )

こ雲淡風輕ζ 提交于 2019-11-28 05:34:48
问题 How I can generate a working executable with the tools provided with Llvm/Clang ( version 3.3 (trunk 168461) ) ? I have compiled an object with clang++ -c [...] and i would like to try to link this object to 1 specific library and see if this can generate a working executable. I have noticed that from the 3.1 release llvm-ld it's been removed and llvm-link doesn't look like it has inherited all the options from llvm-ld , although it's marked as the alternative to llvm-ld on the official docs,

Any tutorial for embedding Clang as script interpreter into C++ Code?

萝らか妹 提交于 2019-11-28 05:28:49
I have no experience with llvm or clang, yet. From what I read clang is said to be easily embeddable Wikipedia-Clang , however, I did not find any tutorials about how to achieve this. So is it possible to provide the user of a c++ application with scripting-powers by JIT compiling and executing user-defined code at runtime? Would it be possible to call the applications own classes and methods and share objects? edit: I'd prefer a C-like syntax for the script-languge (or even C++ itself) I don't know of any tutorial, but there is an example C interpreter in the Clang source that might be

Integrate LLVM Clang 4.x.x / 5.x.x / 6.x.x into Visual Studio 2017

徘徊边缘 提交于 2019-11-28 04:47:41
The official LLVM 4.0 build for Windows integrates with Visual Studio up to Visual Studio 2015. Unfortunately it still doesn't support Visual Studio 2017. When you try to set the Platform Toolset of a project to LLVM-vs2014 , it pops up an error. Do you know any way to make it work? Update In 2018, LLVM 6.0 officially still doesn't support integration with Visual Studio 2017 (version 15.X.X), only with the Visual Studio 2015 (version 14.X.X) toolset. It requires some msbuild targets that only ship with the C++ v140 toolset, and VS 2017 only installs the v141 toolset by default. If you open the

Getting the original variable name for an LLVM Value

半腔热情 提交于 2019-11-28 04:45:22
The operands for an llvm::User (e.g. instruction) are llvm::Value s. After the mem2reg pass, variables are in SSA form , and their names as corresponding to the original source code are lost. Value::getName() is only set for some things; for most variables, which are intermediaries, its not set. The instnamer pass can be run to give all the variables names like tmp1 and tmp2 , but this doesn't capture where they originally come from. Here's some LLVM IR beside the original C code: I am building a simple html page to visualise and debug some optimisations I am working on, and I want to show the

LLVM vs. GCC for iOS development [closed]

a 夏天 提交于 2019-11-28 04:38:43
In latest iOS SDK, Apple provides three compiler options: GCC, LLVM with Clang and LLVM-GCC. I understand more or less what these 3 mean, what LLVM and Clang are, and so on. What I don't know is what this means in practice for iPhone developers. Which of these should I use at this point, as of January 2011? Is LLVM mature enough that I can use it safely without stumbling on bugs in it too often? Does switching to LLVM have any other disadvantages? If it does, then does the speed advantage outweigh them? Are there any other reasons to switch except speed? Update: Because people are still

Error when using CMake with LLVM

柔情痞子 提交于 2019-11-28 03:50:33
问题 So I'm trying to build a toy compiler using LLVM and I'd like to use CMake as my build system. I tried using the sample CMakeLists.txt from LLVM's website, but I encounter the following error when running cmake : CMake Error at /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:178 (include): include could not find load file: /usr/share/llvm/cmake/LLVMExports.cmake Call Stack (most recent call first): CMakeLists.txt:4 (find_package) CMake Error at /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:181

Confusing Template error

匆匆过客 提交于 2019-11-28 03:38:20
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 to a minimal example: template<typename T, typename U, int N> struct X { void f(T* t) { // expected-error{{use 'template' keyword to treat 'f0' as a dependent template name}} t->f0<U>(); } }; The error message yielded by clang: tpl.cpp:6:13: error: use 'template' keyword to treat 'f0' as a dependent template name t->f0<U>(); ^ template 1 error