llvm

Is it possible to translate an assembly language to LLVM IR, optimize it and then recompile it to a different architecture?

倾然丶 夕夏残阳落幕 提交于 2019-12-05 00:54:05
Is it possible to translate an assembly language to LLVM IR, optimize it and then recompile it to a different architecture? How would you handle "push"es and "pop"s on the stack in the IR? This is the simplest objection I found, but I'm sure that there're tons like this. I'm planning to build a dynamic recompiler, and it seems that this would be an excellent solution, since LLVM would automatically optimize my code for the new architecture. Is all this possible with LLVM? Thanks Richard Pennington This is a similar question: Recompile a x86 code with LLVM to some faster one x86 The answer is

gcc vs. clang: symbol stripping

半城伤御伤魂 提交于 2019-12-05 00:46:12
gcc and AMD Open64 opencc both have a -s option to "strip symbol table and relocation information". So far I haven't been able to find the same option in Clang/LLVM. Does it exist? You can use a strip utility from binutils. Actually, a llvm-ld has this options http://llvm.org/cmds/llvm-ld.html -strip-all, -s Strip all debug and symbol information from the executable to make it smaller. -strip-debug, -S Strip all debug information from the executable to make it smaller. opt have something too: -strip-debug This option causes opt to strip debug information from the module before applying other

Possible to auto-generate llvm c++ api code from LLVM-IR?

心不动则不痛 提交于 2019-12-04 22:15:15
问题 The clang 3.0 online demo page http://llvm.org/demo/index.cgi provides an option to output LLVM C++ API code" representing the LLVM-IR for the input program. Is "produce LLVM C++ API code" output a clang option (and if so, what is it)? Or is it an llvm tool option (which one)? Is it possible to do the same thing but from LLVM-IR input? Basically I'd like to see the proper llvm c++ api calls needed to produce a particular given llvm-ir sequence. I'd like to learn backwards by example rather

How to change LLVMPass long opt command to a simple Command

霸气de小男生 提交于 2019-12-04 20:59:53
I am working on LLVM obfuscation project. I have written a llvm pass(lets say flow flattening pass) which i am running on source (test.c) with following command: clang -emit-llvm test.c -c -o test.bc opt -load ../../.. LLVMFlattening.so -fla <test.bc>/dev/null But i have seen that in O-LLVM project they achieved same thing using: clang -emit-llvm test.c -c -o test.bc -mllvm -fla Can someone tell me what is -mllvm here and how this changed to a simple command? Kun Ling -mllvm means Additional arguments to forward to LLVM's option processing . Therefore -mllvm -fla will pass -fla to the LLVM's

llvm dependencies alloca-load

旧时模样 提交于 2019-12-04 20:58:50
I have some problems of finding dependencies. I want to get the corresponding Alloca from every Load (corresponding from the point of view of the variable used, meaning that the Load is using a variable based/dependent on the Alloca or Allocas). Hence, I have a chain like : Alloca -> Load(1) -> ... -> Computation where the variable might be changed -> Store(new_var) -> ... -> Load(n) "Computation where the variable is changed" means that : I might have Alloca(a), c=a+7000*b[32], Load(c) . First, I tried to use methods from AliasAnalysis class. The plan was the following: after I get all the

Libclang API to get function definitions defined in a different file

99封情书 提交于 2019-12-04 20:53:19
Suppose I have two files main.c and func.c func.c is called from main.c's main function. Normally, I would generate main.o and func.o and linker would find definition of func and tie it up to it's call in main .c Now, I want to do same thing through libclang APIs. This is for a Doxygen type code browsing utility I am making. I am able to parse the two files. From here, I don't know how to proceed. Should I generate *.o files and make clang link them? Thanks, I hope I am clear in asking the question No, there is no need for actually compiling your code to object files. The link between symbols

Meaning of the LLVM Optimization Levels

↘锁芯ラ 提交于 2019-12-04 19:41:38
问题 I recently started working with Clang/LLVM and would like to know if there is any particular documentation on what the -Ox optimization levels do? I couldn't find much on the LLVM documentation page. Can someone share a few links? Thanks. 回答1: Clang's command-line options documentation is indeed very poor, and in particular you are correct that there's almost no explanation of what the optimizations level do. FreeBSD, however, does add a man page with a useful summary: -O0 -O1 -O2 -Os -Oz -O3

OpenCL LLVM IR generation from Clang

邮差的信 提交于 2019-12-04 19:23:48
I am using the following command line for clang: clang -Dcl_clang_storage_class_specifiers -isystem $LIBCLC/generic/include -include clc/clc.h -target nvptx--nvidiacl -x cl some_kernel.cl -emit-llvm -S -o some_kernel.ll the result is: ; ModuleID = 'kernel.cl' target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64" target triple = "nvptx--nvidiacl" ; Function Attrs: noinline nounwind define void @vector_add(float addrspace(1)* nocapture %vec1, float addrspace(1)* nocapture %vec2, float addrspace(1)*

GCC toolchain for LLVM

血红的双手。 提交于 2019-12-04 19:17:15
问题 I am running on an RHEL 6.x box, which of course has GCC 4.4 installed. I wish to have LLVM running on this machine. In order to do so, I must compile it from source. In order to do that , I need a more modern version of GCC. So, following the instructions, I have built GCC 4.8.2: [snip] % $PWD/../gcc-4.8.2/configure --prefix=$HOME/toolchains --enable-languages=c,c++ % make -j$(nproc) % make install I'm logged in as root, so $HOME/toolchains resolves to /root/toolchains . After satisfying

Any tutorial on libclang? [closed]

冷暖自知 提交于 2019-12-04 18:23:53
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I've been looking for some easy to understand guide into libclang. I've seen some threads either here or other forums but the only recommended sources of information were libclang source/doxygen doc, clang complete plugin for vim or Thinking Beyond the Compiler presentation. However, none of them provide