llvm

Xcode warning: … is a GNU extension

◇◆丶佛笑我妖孽 提交于 2019-12-05 15:09:34
I use a C++ library for an iOS app. With Apple LLVM 3.1 compiler configured (default), I get a lot of warnings for this C++ code, most of them saying: ... is a GNU extension The introduction of clang's user manual says: The Clang driver and language features are intentionally designed to be as compatible with the GNU GCC compiler as reasonably possible, easing migration from GCC to Clang. In most cases, code "just works". So, is it save to just look for a switch to disable this warnings (btw. how to?) or should I better get this lib rid of all GNU extensions? You can suppress the warnings

Generate call to intrinsic using LLVM C API

霸气de小男生 提交于 2019-12-05 14:13:38
I'm working on some code that uses the LLVM C API. How do I use intrinsics, such as llvm.cos.f64 or llvm.sadd.with.overflow.i32 ? Whenever I try to do it by generating a global with LLVMAddGlobal (with the correct type signature), I just get this error message during the JIT linking stage: LLVM ERROR: Could not resolve external global address: llvm.cos.f64 I'm not using the LLVM C++ interface , so the advice in LLVM insert intrinsic function Cos does not seem to apply. I presume I need something like Intrinsic::getDeclaration , but I can't seem to find it. Am I missing something obvious? No

llvm JIT add library to module

不想你离开。 提交于 2019-12-05 14:07:50
I am working on a JIT that uses LLVM. The language has a small run-time written in C++ which I compile down to LLVM IR using clang clang++ runtime.cu --cuda-gpu-arch=sm_50 -c -emit-llvm and then load the *.bc files, generate additional IR, and execute on the fly. The reason for the CUDA stuff is that I want to add some GPU acceleration to the runtime. However, this introduces CUDA specific external functions which gives errors such as: LLVM ERROR: Program used external function 'cudaSetupArgument' which could not be resolved! As discussed here , this is usually solved by including the

Getting actual value of local variables in llvm

空扰寡人 提交于 2019-12-05 13:55:58
If I have this example: int a=0, b=0; a and b are local variables and make any modifications in their values, such as: a++; b++; I need to get the value in this line code during running MCJIT. I mean by value not Value class, but the actual integer or any type value. You need to return the value from a JITed LLVM function in order to retrieve it from the code invoking MCJIT. Check out this Kaleidoscope example . The relevant code is in HandleTopLevelExpression(): if (FunctionAST *F = ParseTopLevelExpr()) { if (Function *LF = F->Codegen()) { // JIT the function, returning a function pointer.

七天LLVM零基础入门(Linux版本)------第三天

馋奶兔 提交于 2019-12-05 13:53:51
作者: snsn1984 第二天的任务中的LLVM IR的文档( http://llvm.org/docs/LangRef.html ) 对于初学者来说,看起来一定很费劲,内容繁杂,找不到头绪,看了后边的忘记了前面的,这些都是很正常的。但是,这里需要注意的是,不管多烦躁,一定要硬着 头皮先把这个文档通读一遍,在读的同时,可以自己写一个小程序,根据前面学习的使用clang的命令将该程序转换成.ll格式的,然后在阅读文档的同时, 对照.ll格式的文件,去实际的看一看,到底说的是什么样的东西,然后这样才能加深印象,才能让阅读文档变得不那么艰难。 下面开始今天的学习任务: 第一步:复习LLVM IR的文档( http://llvm.org/docs/LangRef.html ) 复习该文档的时候,略微有些侧重点,就是该文档从开始的部分,一直到 http://llvm.org/docs/LangRef.html#other-values 这个部分之前,都要仔细复习一遍。后面的内容,大致的过一遍,以后要用到的时候,可以找到地方就行。 第二步:阅读文档 ( http://llvm.org/docs/ProgrammersManual.html ) 这个文档从名字就可以看出来是干什么用的,这个就是LLVM的编程指引,相对来说这个文档没那么长,但是里面的东西很重要,希望在阅读的过程中 认真阅读。同时

LLVM 3.5 fails to link

 ̄綄美尐妖づ 提交于 2019-12-05 13:19:33
问题 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:

LLVM and the future of optimization

我是研究僧i 提交于 2019-12-05 12:44:21
问题 I realize that LLVM has a long way to go, but theoretically, can the optimizations that are in GCC/ICC/etc. for individual languages be applied to LLVM byte code? If so, does this mean that any language that compiles to LLVM byte code has the potential to be equally as fast? Or are language specific optimizations (before the LLVM bytecode stage) going to always play a large part in optimizing any specific program. I don't know much about compilers or optimizations (only enough to be dangerous

Create local string using LLVM

不打扰是莪最后的温柔 提交于 2019-12-05 11:04:36
I'm trying to create a local variable using LLVM to store strings, but my code is currently throwing a syntax error. lli: test2.ll:8:23: error: constant expression type mismatch %1 = load [6 x i8]* c"hello\00" My IR code that allocates and store the string: @.string = private constant [4 x i8] c"%s\0A\00" define void @main() { entry: %a = alloca [255 x i8] %0 = bitcast [255 x i8]* %a to i8* %1 = load [6 x i8]* c"hello\00" %2 = bitcast [6 x i8]* %1 to i8* %3 = tail call i8* @strncpy(i8* %0, i8* %2, i64 255) nounwind %4 = getelementptr inbounds [6 x i8]* %a, i32 0, i32 0 %5 = call i32 (i8*, ...)

LLVM tail call optimization

早过忘川 提交于 2019-12-05 10:58:22
Here is my understanding of things: A function "f" is tail recursive when calling itself is its last action. Tail-recursion can be significantly optimized by forming a loop instead of calling the function again; the function's parameters are updated in place, and the body is ran again. This is called recursive tail call optimization. LLVM implements recursive tail call optimization when using fastcc, GHC, or the HiPE calling convention. http://llvm.org/docs/CodeGenerator.html#tail-call-optimization I have some questions: Let's consider the silly example: int h(int x){ if (x <= 0) return x;

Reducing GCC target EXE code size?

走远了吗. 提交于 2019-12-05 08:36:46
When I compiled a no-op program: int main(void) { return 0; } with various compilers: GCC (similar result to LLVM as well): Gave a 10-KiB executable (compiled with -s ) Sections: .CRT , .bss , .data , .idata , .rdata , .text , .tls Depends on msvcrt.dll and kernel32.dll MSVC 2010: Gave a 5.5 KiB executable (compiled with /MD /Ox ) Sections: .data , .rdata , .reloc , .text Depends on msvcr100.dll and kernel32.dll Could have been further reduced by merging .rdata with .text Windows Driver Kit 7.1: Gave a 6.5 KiB executable (compiled with /MD /Ox , linked with msvcrt_winxp.obj to allow it to run