llvm

How to make clang compile to llvm IR

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want clang to compile my C/C++ code to LLVM bytecode rather than binary executable. How can I achieve that? And if I get the LLVM bytecode, how can I take it to further compile it to binary executable. Basically I want to add some of my own code to the LLVM bytecode before compiling to binary executable. 回答1: Given some C/C++ file foo.c : > clang -S -emit-llvm foo.c Produces foo.ll which is an LLVM IR file. The -emit-llvm option can also be passed to the compiler front-end directly, and not the driver by means of -cc1 : > clang -cc1 foo.c

Run LLVM pass with opt

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have just started to work with LLVM. I have wrote my own Hello pass, which worked fine. Now I want to run opt with the stack protector pass, from StackProtector.cpp, but I am having trouble with that. When I look at the source code, it looks like I should use the flag -stack-protector: INITIALIZE_PASS(StackProtector, "stack-protector", "Insert stack protectors", false, false) But this flag is not recognized by opt. I am not sure which file to "load", as it is not as simple as loading my own LLVMHello.so file and I could not find a

LLVM Backend : Replacing indirect jmps for x86 backend

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to replace indirect jmp *(eax) instructions in the code to mov *(eax),ebx; jmp *ebx for the x86 executables. Before implementing this, i would like to make LLVM compiler, log an output every time it detects a jmp *(eax) instruction by adding some print statements. Then i want to move on to replacing the indirect sequence. From what i have seen from google searches and articles, i can probably achieve this by modifying the x86asmprinter in the llvm backend. But i am not sure how to go about it. Any help or reading would be appreciated.

Xcode 4 automatically generates iVars when using @property,where can I find the official doc for this feature?

﹥>﹥吖頭↗ 提交于 2019-12-03 08:53:21
I have read "What's new in Xcode",but I can't find the official explanation for this feature. Where can I find the official explanation? Which documentation? Thanks. You can find this in the Apple documentation in Objective-C Programming Language: Declared Properties under "Property Implementation Directives". Whether or not an ivar is synthesized automatically depends on what runtime you are using: There are differences in the behavior of accessor synthesis that depend on the runtime (see also “Runtime Difference”): For the legacy runtimes, instance variables must already be declared in the

How can I print to a string in LLVM

匿名 (未验证) 提交于 2019-12-03 08:52:47
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to print an instruction in LLVM to a string instead of the screen. I use I->print( errs() ) to print to the screen. How can I instead put the instruction in a string? 回答1: Like this, std::string str; llvm::raw_string_ostream rso(str); I->print(rso); 文章来源: How can I print to a string in LLVM

Hades:移动端静态分析框架

风流意气都作罢 提交于 2019-12-03 08:46:37
只有通过别人的眼睛,才能真正地了解自己 ——《云图》 背景 作为全球最大的互联网 + 生活服务平台,美团点评近年来在业务上取得了飞速的发展。为支持业务的快速发展,移动研发团队规模也逐渐从零星的小作坊式运营,演变为千人级研发军团协同作战。 在公司蓬勃发展的大背景下,移动项目架构也有了全新的演进方向:需要支持高效的集成策略,支持研发流程自动化等等,最终提升研发效能,加速产品迭代和交付能力。 虽然高效的研发交付体系帮助 App 项目缩短了迭代周期,但井喷式的模块发版和频繁的项目集成,使得纯人工的项目维护和质量保证变得“独木难支”。 上图漫画中,列举了大型项目在持续优化和维护过程中较为常见的几类需求。这些需求主要包括以下几个方面: 在 CI 流程中加入静态准入检查,避免繁琐的人工 Review 以及减少人工 Review 可能带来的失误。 为了推进项目的优化过程,需要方法数监控、宏定义分析等代码分析报表和监控。 零 PV 报表、依赖分析和头文件引用规范、无用代码分析等项目优化方案。 不难发现,这些需求的本质是:借助代码静态分析能力,提升项目可持续发展所需要的自动化水平。针对 C/Objective-C 主流的静态分析开源项目包括:Static Analyzer、Infer、OCLint 等。但是,这些分析工具对我们而言存在一些问题: 开发成本高,收益有限,研发参与积极性不够。

-emit-llvm in Linux

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am a newbie to LLVM and try to generate a human readable .ll file on Linux. I installed llvm-gcc but as I see it can generate only assembly code (-S option). Is there any way to get something like what is generated by llvm online compiler ? That's what I get with -S -emit-llvm on Linux: .file "hello.c" .ident "GCC: (Ubuntu/Linaro 4.5.1-7ubuntu2) 4.5.1 LLVM: " .text .globl main .align 16, 0x90 .type main,@function main: pushl %ebp movl %esp, %ebp subl $8, %esp movl $.L.str, 4(%esp) movl $1, (%esp) call __printf_chk xorl %eax, %eax addl $8,

LLVM&Clang support of C++11

天大地大妈咪最大 提交于 2019-12-03 08:40:29
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? You will need Xcode 4.2. In your build settings, search for "c++0x" and set the "C++ Language Dialect to C++0x [-std=c++0x]". Then search for "libc++" and set the "C++ Standard Library" to "libc++". Not all C++11

LLVM 3.5 fails to link

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When compiling with the experimental LLVM3.5 libraries link the following link errors appear: /usr/lib/llvm-3.5/lib/libLLVMSupport.a(Process.o): In function llvm::sys::Process::FileDescriptorHasColors(int)': (.text+0x85b): undefined reference to setupterm' /usr/lib/llvm-3.5/lib/libLLVMSupport.a(Process.o): In function llvm::sys::Process::FileDescriptorHasColors(int)': (.text+0x87a): undefined reference to tigetnum' /usr/lib/llvm-3.5/lib/libLLVMSupport.a(Process.o): In function llvm::sys::Process::FileDescriptorHasColors(int)': (.text+0x888):

OpenCL LLVM IR generation from Clang

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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,