llvm

llinking @_Znam and @_Znwm

♀尐吖头ヾ 提交于 2019-12-02 03:51:38
问题 I'm new to c++ programming and currently working on an llvm front-end development project. When I link the object files created by llc, my linker cannot locate the following functions. I know that these are standard c++ library functions but using -lstdc++ doesn't work. Now my question is that where are these functions defined and how can I link them with my object files, and actually what do they do? declare noalias i8* @_Znam(i64) declare noalias i8* @_Znwm(i64) 回答1: These functions are

LLVM/Clang On Windows 2013_09

◇◆丶佛笑我妖孽 提交于 2019-12-02 03:32:42
好吧,很久没有写博客了,最近LLVM/Clang的主干版本取得了很大的进步,便在这里汇报下分析心得。 我非常建议研究LLVM/Clang的朋友在自己电脑上安装TortoiseSVN 并且将LLVM的源代码Clone下来,LLVM的svn地址: http://llvm.org/svn/llvm-project/ 在这个页面有LLVM组织绝大部分项目的源代码。 克隆LLVM:svn co http://llvm.org/svn/llvm-project/llvm YourDir/LLVM 克隆Clang:svn co http://llvm.org/svn/llvm-project/cfe YourDir/clang 如何在Windows上构建LLVM/Clang,以前的博客有说过,目前在Windows上能够构建LLVM/Clang的有: Visual Studio 2010 Visual Studio 2012 Mingw Mingw64 Cygwin 特别指出,VisualStudio 2013暂时构建LLVM/Clang虽然能构建成功,但是Clang无法编译文件,这是clang内部支持没有更新,在clang的drive(WindowsToolChain.cpp)的源文件中,目前仍没有完善VS11的支持。而Cygwin64暂时无法通过编译,configure过程便已经失败

compiling nested functions with clang versus gcc

橙三吉。 提交于 2019-12-02 03:27:01
I have a c file that I can compile with no problem using GCC like below: gcc foo.c however using the same file I am receiving error of having defined functions inside main using clang : clang foo.c foo:230:1: error: function definition is not allowed here { ^ foo.c:241:1: error: function definition is not allowed here { ^ foo.c:253:1: error: function definition is not allowed here these instances of errors are the definitions of a new function inside the main section of the code. I want to know why GCC doesn't get bothered with this yet clang does? Functions defined within functions are an

Creating local variable in function LLVM

徘徊边缘 提交于 2019-12-02 02:56:31
In llvm::Module there are 2 interesting fields: typedef SymbolTableList<Function> FunctionListType; typedef SymbolTableList<GlobalVariable> GlobalListType; GlobalListType GlobalList; ///< The Global Variables in the module FunctionListType FunctionList; ///< The Functions in the module So, if we will define some functions or global variables, we will be able to use them from any other places of our program just asking our module for them. But what about function local variables? How to define them? Local variables are allocated via alloca at runtime. To create AllocaInst you need to llvm:

Run default optimization pipeline using modern LLVM

三世轮回 提交于 2019-12-02 02:43:04
问题 I'm using LLVM 7 and I have an llvm::Module that I'd like to optimize using the standard optimization pipeline. Unfortunately, there isn't a llvm::runDefaultOptimizations function that I can call. There seems to be a bajillion ways to optimize a module in LLVM. My searches on this topic have found many old/depreciated APIs and some examples that don't work on my system. I want to run all of the standard optimizations at -O3 with the least amount of hassle possible. I don't want to manually

How to attach metadata to LLVM IR using the C++ API?

我们两清 提交于 2019-12-02 01:54:27
Can anyone point me to a concrete example of attaching metadata to llvm-ir using the c++ api? I've read this page http://llvm.org/docs/SourceLevelDebugging.html . Thanks The above answer is not quite correct (or complete). You can also create metadata at the module level with just MDNode::get(...) which takes a context and an array of values to create metadata from. Named metadata is very heavyweight and you should only use it as an anchor for top level metadata values. For attaching to instructions you do want to use the setMetadata call on the Instruction to set any particular metadata,

Error in Compiling haskell .ll file with llvm backend

…衆ロ難τιáo~ 提交于 2019-12-02 01:15:47
I want to compile haskell using ghc front-end and llvm back-end. I have following code in my haskell hello.hs file: main = putStrLn "Hello World!" I compile hello.hs with ghc using following command ghc -fllvm -keep-llvm-files -force-recomp -hello.hs which generate a hello.ll file along with other files. I then try to compile this .ll file into a .bc file. llvm-as hello.ll -o hello.bc and then this .bc file to executable file llc hello.bc -o hello which generate an executable file. The problem is when I run this file I found the following error ./hello: line 1: .file: command not found ./hello

what does machine value type “other” mean in llvm SDnodes

喜夏-厌秋 提交于 2019-12-02 00:26:20
I am trying to understand more deeply the instruction selection process in llvm and for that I am debuging step-by-step the CodeGenAndEmitDAG function. I have printed a small function (see below) just before the combine step - the first step in the above function. In the graph I see blue lines and it seems that they are always pointing at "ch" , which I think means "other" machine value type. What I don't understand is the meaning of the blue lines... what is this dependency ? And, am I right about the meaning of "ch" ? is it "other" ? Dashed blue arrows represent non-dataflow dependencies

LLVM insertvalue bad optimized?

ε祈祈猫儿з 提交于 2019-12-01 18:37:19
问题 Should I avoid using the 'insertvalue' instruction combined with load and store when I emit LLVM code? I always get bad optimized native code when I use it. Look at the following example: ; ModuleID = 'mod' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-pc-linux-gnu" %A = type { i64, i64, i64, i64, i64, i64, i64, i64 } @aa = external global %A* define

LLVM insertvalue bad optimized?

纵然是瞬间 提交于 2019-12-01 18:19:05
Should I avoid using the 'insertvalue' instruction combined with load and store when I emit LLVM code? I always get bad optimized native code when I use it. Look at the following example: ; ModuleID = 'mod' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-pc-linux-gnu" %A = type { i64, i64, i64, i64, i64, i64, i64, i64 } @aa = external global %A* define void @func() { entry: %a1 = load %A** @aa %a2 = load %A* %a1 %a3 = insertvalue %A %a2, i64 3, 3 store %A