llvm-ir

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 JIT-compiled program cannot find external functions

北战南征 提交于 2019-12-01 09:21:41
My program which JIT compiles a LLVM IR module and calls a function foo defined therein fails at runtime if foo uses an externally-defined function: LLVM ERROR: Program used external function 'glutInit' which could not be resolved! My program: // foo1.cpp #include <GL/glut.h> extern "C" void foo() { glutInit(0,0); } // foo2.cpp #include <iostream> #include <fstream> #include <string> #include <llvm/Support/raw_ostream.h> #include <llvm/LLVMContext.h> #include <llvm/Support/TargetSelect.h> #include <llvm/Support/IRReader.h> #include <llvm/ExecutionEngine/ExecutionEngine.h> #include <llvm

Building and using a pass for LLVM 3.8 on OSX

笑着哭i 提交于 2019-12-01 07:44:04
I'm trying to build and apply a pass on OSX using llvm 3.8. I installed llvm 3.8 using brew with this formula: $brew install llvm38 Inside the pass I have the following: static RegisterPass<SwiftPass> X("pass", "My Pass"); My Makefile to build the pass looks like this: LIB_NAME = pass$(SUFIX) LDFLAGS = $(shell $(LLVM_PATH)llvm-config --ldflags) CXXFLAGS = -g -Wall -fno-rtti -fPIC -std=c++11 -shared -dynamiclib $(shell $(LLVM_PATH)llvm-config --cxxflags --system-libs --libs core executionengine interpreter mc support nativecodegen) COMPILER = clang++ all: $(LIB_NAME) $(LIB_NAME): $(OBJ) $

LLVM JIT-compiled program cannot find external functions

女生的网名这么多〃 提交于 2019-12-01 07:06:02
问题 My program which JIT compiles a LLVM IR module and calls a function foo defined therein fails at runtime if foo uses an externally-defined function: LLVM ERROR: Program used external function 'glutInit' which could not be resolved! My program: // foo1.cpp #include <GL/glut.h> extern "C" void foo() { glutInit(0,0); } // foo2.cpp #include <iostream> #include <fstream> #include <string> #include <llvm/Support/raw_ostream.h> #include <llvm/LLVMContext.h> #include <llvm/Support/TargetSelect.h>

Execute LLVM IR code generated from Rust/Python source code

和自甴很熟 提交于 2019-12-01 06:06:45
When I generate LLVM IR Code from C++, I can use the console command clang++ -emit-llvm –S test.cpp to get a test.ll file which is the LLVM IR I want. To get an executable these are the steps to follow: llvm-as test.ll -> gives me the test.bc file. llc test.bc --o test.s -> gives me the test.s file. clang++ test.s -o test.native -> gives me a native file that i can execute. For C++ this works just fine. In theory, should the same steps apply when I write Rust or Python Code? I take my Rust code and get the LLVM IR by typing rustc test.rs --emit llvm-ir . This gives me the test.ll file again.

Building and using a pass for LLVM 3.8 on OSX

不想你离开。 提交于 2019-12-01 04:56:47
问题 I'm trying to build and apply a pass on OSX using llvm 3.8. I installed llvm 3.8 using brew with this formula: $brew install llvm38 Inside the pass I have the following: static RegisterPass<SwiftPass> X("pass", "My Pass"); My Makefile to build the pass looks like this: LIB_NAME = pass$(SUFIX) LDFLAGS = $(shell $(LLVM_PATH)llvm-config --ldflags) CXXFLAGS = -g -Wall -fno-rtti -fPIC -std=c++11 -shared -dynamiclib $(shell $(LLVM_PATH)llvm-config --cxxflags --system-libs --libs core

How to write a custom intermodular pass in LLVM?

左心房为你撑大大i 提交于 2019-11-30 08:50:15
I've written a standard Analysis pass in LLVM, by extending the FunctionPass class. Everything seems to make sense. Now what I'd like to do is write a couple of intermodular passes, that is, passes that allows me to analyze more than one module at a time. The purpose of one such pass is to construct a call graph of the entire application. The purpose of the other such pass is that I have an idea for an optimization involving function calls and their parameters. I know about interprocedural passes in LLVM, via extending the ModulePass class, but that only allows analysis within a single module.

Adding Metadata to Instructions in LLVM IR

血红的双手。 提交于 2019-11-28 21:16:14
问题 First up, I am a newbie to LLVM passes. I am trying to add metadata to instructions in LLVM after a transformation pass (with the C++ API). I intend to store this information for use by another tool in a tool chain. I have two questions regarding this. I expect the information I store as metadata to feed into another tool which works on the LLVM IR. So is metadata a good idea ? I intend to store strings as metadata with some instructions. If metadata is the right way to go here, I need some

Call LLVM Jit from c program

偶尔善良 提交于 2019-11-28 16:53:29
I have generated a bc file with the online compiler on llvm.org, and I would like to know if it is possible to load this bc file from a c or c++ program, execute the IR in the bc file with the llvm jit (programmatically in the c program), and get the results. How can I accomplish this? Here's some working code based on Nathan Howell's: #include <string> #include <memory> #include <iostream> #include <llvm/LLVMContext.h> #include <llvm/Target/TargetSelect.h> #include <llvm/Bitcode/ReaderWriter.h> #include <llvm/ExecutionEngine/ExecutionEngine.h> #include <llvm/ModuleProvider.h> #include <llvm

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