llvm

Unknown package libcxx and libcxxabi when building Clang?

给你一囗甜甜゛ 提交于 2019-12-10 16:49:10
问题 I'm trying to build Clang with libc++ from sources. And I'm trying to drop libc++ in-tree while building it out-of-tree with the other components. The recipe I use is below. If I simply place libcxx and libcxxabi in-tree, then configure does not pick them up, and they are not built automatically. I placed them in llvm/projects per LLVM's libc++ Standard Library. Additionally, adding make cxx to the recipe does not work as advertised on the LLVM's libc++ Standard Library page. It results in:

Specifically what does a compiler do to aggressively optimize generated bytecode?

泪湿孤枕 提交于 2019-12-10 16:48:19
问题 I have been reading up on the functionality of various compilers and I've come across the term "aggressive optimization" that many compilers are reported to perform. LLVM, for example cites the following compile-time optimization features: Memory/pointer specific Loop transforms Data flow Arithmetic Dead code elimination Inlining What does this mean specifically? Say you had the following code snippet, how could you optimize the generated byte code to run any faster than what the compiler

Running LLVM file, generated with rustc, with clang

守給你的承諾、 提交于 2019-12-10 16:24:14
问题 I'm trying to run a .ll file with clang and getting linker errors. I have a file test.rs that simply includes a main function with a println! statement. I generate the LLVM IR with the command rustc --emit=llvm-ir --crate-type=bin test.rs . When I try to run the output test.ll file with clang test.ll I get a linker error: Undefined symbols for architecture x86_64: "std::io::stdio::_print::h178318b95760562a", referenced from: rust_test::main::h84a9713c734a1b45 in rust_test-9ea667.o "_main",

Mac OS 下的 gcc gdb

柔情痞子 提交于 2019-12-10 16:03:21
好久没有写c了,今天和老婆大人一起做了一下微软的网上编程题。发现忘了好多。 由于有运行时错误,所以想用gdb调试一下,发现没有gdb,遂使用homebrew安装,结果安装出错。后来发现错误的原因应该是找不到gcc!可是我一直用gcc编译程序的啊,好奇怪! 这两天vpn不稳定,只能百度,好不容易才发现了原因: 从Mac OS 10.9开始,安装Xcode5时不会再安装gcc了,而系统中的gcc实际上只是一个别名。 $ gcc -v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1 Apple LLVM version 7.0.0 (clang-700.0.72) Target: x86_64-apple-darwin14.5.0 Thread model: posix $ clang -v Apple LLVM version 7.0.0 (clang-700.0.72) Target: x86_64

compiler LLVM(zhuanzai)

隐身守侯 提交于 2019-12-10 15:49:23
Mac OS X 10.6即所谓的Snow Leopard操作系统已正式发售。一如既往,Apple产品光鲜的外表下凝聚了太多艰辛的劳作。ArsTechnic的John Siracusa以其独特的、专业的、全面的视角深入翔实地体验这款最新的操作系统。 Weiphone.com将对该综述进行翻译整理并独家连载。欢迎关注。 引用 译注:为了 帮助您更加顺畅地理解本文的内容,这里补充了文中一些相关概念的背景资料。 编译器(compiler) : 是一种能够将源代码(通常由高级别的程序语言编写而成)转换为低级别机器语言的程序。源码转换最重要的一个目的在于创建可执行文件。 详情请参考 wikipedia 。 LLVM(Low Level Virtual Machine,低级虚拟机) :是构架编译器(compiler)的框架系统,以C++编写而成,用于优化以任意程序语言编写的程序的编 译时间(compile-time)、链接时间(link-time)、运行时间(run-time)以及空闲时间(idle-time),对开发者保持 开放,并兼容已有脚本。LLVM计划启动于2000年,最初由University of Illinois at Urbana-Champaign的Chris Lattner主持开展。2006年Chris Lattner加盟Apple Inc

使用Flex Bison 和LLVM编写自己的编译器

旧巷老猫 提交于 2019-12-10 15:37:38
1、介绍 我总是对编译器和语言非常感兴趣,但是兴趣并不会让你走的更远。大量的编译器的设计概念可以搞的任何一个程序员迷失在这些概念之中。不用说,我也曾 今尝试过,但是并没有取得太大的成功,我以前的尝试都停留在语义分析阶段。本文的灵感主要来源于我最近一次的尝试,并且在这一次中我取得一点成就。 幸运的是,最近的几年,我参加了一些项目,这些项目给了我在建立编译器上很多有用的经验和观点。另外一件事是,我非常幸运得到 LLVM 的帮助。对于这个工具,我不知道改怎么去形容它,但是他给我的这个编译器的确带来非常大的帮助。 1.1、你为什么要阅读本文 你也许想看看我正在做的事情,但是更有可能的是,你也是和我一样对编译器和语言非常感兴趣,并且也可能遇到了一些在探索的过程中遇到了一些难题,你 可能正打算解决这些难题,但是却没有发现好的资源。本文的目标就是提供这些资源,并以一种手把手的方式教你从头到尾的去创建一个具有基本功能的语言编译 器。 在本文,我不会去解释一些编译器基本理论,所以你要在开始本文前去了解什么是 BNF语法 ,什么是 抽象语法树数据结构 AST data structure ,什么是基础 编译器流水线 complier pipline 。就是说,我会把本文描述的尽量简单。本文的目的就是以一种简单易懂的方式来介绍相关编译器资源的方式来帮助那些从来没有编译器经验的人。 1.2、达到的成果

Get operand name of a LLVM getelementptr in

狂风中的少年 提交于 2019-12-10 14:51:08
问题 I am trying to get the name of an array that a getelementptr instruction is referencing. This seems to work when the array is indexed into using an intermediate variable in the actual c code like so int a = 0; i[a] = 3; In this case, i get the following bitcode %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* @i, i64 0, i64 %idxprom store i32 3, i32* %arrayidx, align 4 In this case I can iterate over the operands of the getelementptr instruction and find the name of the array(i)

linking against llvm libraries

北战南征 提交于 2019-12-10 14:48:08
问题 I'm developing a llvm-based compiler and when I try to generate executable file the following error occurs: ./bin/llvmcode.s:35: undefined reference to `operator new[](unsigned long)' Note that in the generated IR, the function '@_Znam' is called which is located in one of llvm libraries. So, I should have linked the generated assembly file with that library. Here is the code I used to do that: llvm-as ./bin/llvmcode.ll llc ./bin/llvmcode.bc g++ -g ./bin/llvmcode.s \`llvm-config --cppflags -

LLVM每日谈之十 LLVM Test简介

女生的网名这么多〃 提交于 2019-12-10 14:13:56
作者: snsn1984 就像很多优秀的软件都有自己的测试框架一样,LLVM也有自己的测试框架。LLVM的测试主要分为两 部分:regression tests 和 whole programs。其中, regression tests 主要位于LLVM源码/test目录下,主要是 用来测试LLVM的一些特性或者是用来测试一些bug的。我们在平时的工作中,一般使用的就是这个类型的test。 whole programs这个类型的测试,不在LLVM的源码中,在SVN库上有自己的单独目录,一般称之为test-suit, 它的测试范围要广的多,因为我们目前这里不涉及,所以这里不做过多介绍。 运行regression tests的方法比较简单,但是必须有已经编译好的LLVM源码。在build目录下,运行make check, 这样就可以运行所有的LLVM源码/test目录下的regression tests。如果已经编译好的LLVM源码下还包含了Clang,也 就是说在编译LLVM之前,已经将Clang的远方放置到LLVM源码/tools目录下了,那么在编译成功之后,就可以使用 make check-all,这样可以运行LLVM和Clang的所有的regression tests。 如果需要运行单个的测试用例,可以使用llvm-lit工具。直接使用llvm-lit工具

Map between LLVM IR instruction and line of source

荒凉一梦 提交于 2019-12-10 13:52:38
问题 How can i store the map between LLVM IR instruction and line of source code if llvm-gcc or dragonegg are used? 回答1: Inside LLVM IR debug information should be used for this purpose. See http://llvm.org/docs/SourceLevelDebugging.html for more info. llvm-gcc (and DragonEgg) will generate everything for you provided that the same information is available on GIMPLE level. 来源: https://stackoverflow.com/questions/5190139/map-between-llvm-ir-instruction-and-line-of-source