llvm

Understanding branches in gcov files

杀马特。学长 韩版系。学妹 提交于 2019-12-09 12:02:50
问题 I'm trying to understand the output of the gcov tool. Running it with no options makes sense, but I'm wanting to try and understand the branch coverage options. Unfortunately it's hard to make sense of what the branches do and why they aren't taken. Below is the output for a method (compile using the latest LLVM/Clang build). function -[TestCoverageAppDelegate loopThroughArray:] called 5 returned 100% blocks executed 88% 5: 30:- (NSInteger)loopThroughArray:(NSArray *)array { 5: 31: NSInteger

架构编译器框架系统 LLVM 使用简介

房东的猫 提交于 2019-12-09 11:48:08
LLVM 是什么 LLVM 是 low level virtual machine(底层虚拟机)的简称,它是一个开源的编译器架构,已经被成功应用到多个应用领域。LLVM 的主要作用是它可以作为多种语言的后端,它可以提供可编程语言无关的优化和针对很多种CPU的代码生成功能。LLVM 核心库提供了与编译器相关的支持,可以作为多种语言编译器的后台来使用。能够进行程序语言的编译期优化、链接优化、在线编译优化、代码生成。LLVM的项目是一个模块化和可重复使用的编译器和工具技术的集合。LLVM是伊利诺伊大学的一个研究项目,提供一个现代化的,基于SSA的编译策略能够同时支持静态和动态的任意编程语言的编译目标。自那时以来,已经成长为LLVM的主干项目,由不同的子项目组成,其中许多正在生产中使用的各种 商业和开源的项目,以及被广泛用于学术研究。 LLVM 常用命令工具 llvm-as 将可读的 .ll 文件汇编成字节代码 llvm-dis 将字节代码文件反编成可读的 .ll 文件 opt 在一个字节代码文件上运行一系列的 LLVM 到 LLVM 的优化 llc 为一个字节代码文件生成本机器代码 lli 直接运行使用 JIT 编译器或者解释器编译成字节代码的程序 llvm-link 将几个字节代码文件连接成一个 llvm-ar 打包字节代码文件 llvm-ranlib 为 llvm-ar

What is the sanctioned way to build libc++ for clang on Linux?

喜欢而已 提交于 2019-12-09 10:32:26
问题 Edit/Update/Note: Just let clang use libstdc++. Has been working really well for me so far. =============================== In the past I have been able to succeed by doing something with cmake , but just now I discovered a buildit script inside the lib directory of the http://llvm.org/svn/llvm-project/libcxx/trunk project tree. This buildit script appears to not make use of libsupc++ which is what the cmake approach that I took earlier used. For instance, this guide shows one cmake

What is an exception handling personality function?

大憨熊 提交于 2019-12-09 08:41:05
问题 I've looked at the documentation for the LLVM EH intrinsics, and also the Itanium ABI, and I'm stumped on a few things. What is an exception personality function? What jobs does it perform? How would I go about creating one? 回答1: I had exactly the same question. I've just found these articles which thoroughly explains how it works, the full exception handling process, including the exact purpose of the personality function and a step-by-step implementation. For the sake of having an answer on

VSTS Build Generation throwing Invalid bitcode version error

我的未来我决定 提交于 2019-12-09 08:32:19
问题 To generate builds to testers we use VSTS in our project. When we checkout and run the branch in our mac with xcode, it works fine. But when i try to release a build through VSTS it throws error as below and the build fails. ld: could not reparse object file in bitcode bundle: 'Invalid bitcode version (Producer: '902.0.39.2_0' Reader: '900.0.39.2_0')', using libLTO version 'LLVM version 9.0.0, (clang-900.0.39.2)' for architecture arm64 I understand that the issue might be because of the fact

LLVM&Clang support of C++11

旧时模样 提交于 2019-12-09 07:12:33
问题 I have some code written by me for MS VC++10. I use C++11 and, in particular, expressions like std::function<int (int)> f =...; auto it = v.begin(); for_each(it1, it2,[&](int& i) { ++i;}); Now I'm trying out MacOS and XCode with llvm&clang and my code can't be compiled! The question is why? Perhaps, I shall specify an option to use c++11. In this case, where can I fix it in xcode? 回答1: You will need Xcode 4.2. In your build settings, search for "c++0x" and set the "C++ Language Dialect to C+

Integrating LLVM passes

你说的曾经没有我的故事 提交于 2019-12-09 06:46:17
问题 This maybe a rookie question but is there a way to integrate my LLVM modulepass to be called by default during the transformation phase? Right now I am using this syntax to load my pass and register it ~/llvm/llvm/build/Debug+Asserts/bin/clang -Xclang -load -Xclang ~/llvm/llvm/build/Debug+Asserts/lib/SOMEPASSLIB.so (The problem is when I want to build some package with this pass, the compiler accepts it when I say, pass the loading part as CFLAGS env variable, but some makefiles use CFLAGS

Using LLVM Clang 2.6 with Xcode 3.2

↘锁芯ラ 提交于 2019-12-09 05:14:11
问题 So, I've just downloaded the LLVM Clang (2.6) binaries. Mac OS X 10.6 comes with Clang 1.0. Do you know how to integrate a later version of Clang with the Xcode 3.2.x IDE? Just overwriting files seems a little bit risky. 回答1: First off – you're referring to clang 1.0 based on LLVM 2.6. There is no clang 2.6, only a clang 1.0 based on LLVM 2.6. The clang issued with LLVM 2.6 is the same as the one with Xcode 3.2. (see Wikipedia: "On October 23, 2009 Clang 1.0 was released along with LLVM 2.6

Is there BNF-like grammar to describe LLVM IR?

放肆的年华 提交于 2019-12-09 04:39:10
问题 I am wondering that whether there is a BNF-grammar to describe LLVM IR? like C BNF grammar describing C language, etc. 回答1: There isn't a published BNF grammar, but there is a polygen grammer file which is partially maintained, and used for exactly the purpose of randomly generating inputs to use to test the LLVM IR parser and lexer. You can see the current version of the grammar here: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/llvm.grm?revision=112427&view=markup 回答2: My parser for

writing module to .bc bitcode file

匆匆过客 提交于 2019-12-08 23:59:46
问题 i've assumed that dumping a .bc file from a module was a trivial operation, but now, first time i have to actually do it from code, for the life of me i can't find one missing step in the process: static void WriteModule ( const Module * M, BitstreamWriter & Stream ) http://llvm.org/docs/doxygen/html/BitcodeWriter_8cpp.html#a828cec7a8fed9d232556420efef7ae89 to write that module, first i need a BistreamWriter BitstreamWriter::BitstreamWriter (SmallVectorImpl< char > &O) http://llvm.org/docs