llvm

__block attribute on property declarations

只谈情不闲聊 提交于 2019-12-03 20:40:16
I have to fix some existing code that builds just fine with LLVM (on iOS) so that it builds with llvm-gcc-4.2 too. I'm done with pretty much everything, except this pattern which is found at a few places: @property (nonatomic, retain) __block id myProperty; I suspect the intent here is to allow access to the property from inside a block without retaining self . How can I remove the __block attribute, which gcc doesn't support here, but still achieve the same effect? I'll suggest you've found a compiler bug, the declaration: @property (nonatomic, retain) __block id myProperty; is meaningless.

How to force clang to use some library by default?

試著忘記壹切 提交于 2019-12-03 20:35:16
问题 I build clang by clang against libc++ , libc++abi , compiler-rt in the following steps: To download (and update) llvm and sub-projects I use the following script: svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm cd llvm/tools svn co http://llvm.org/svn/llvm-project/cfe/trunk clang svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk clang/tools/extra svn co http://llvm.org/svn/llvm-project/lldb/trunk lldb svn co http://llvm.org/svn/llvm-project/lld/trunk lld svn co http:/

LLVM C++ IDE for Windows

微笑、不失礼 提交于 2019-12-03 18:18:26
问题 Is there some C/C++ IDE for Windows, which is integrated with the LLVM compiler (and Clang C/C++ analyzer), just like modern Xcode do. I have Dev-Cpp (it uses outdated GCC) and Code::Blocks (with some GCC). But GCC gives me very cryptic error messages. I want to get some more user-friendly error messages from the Clang frontend. Yes, Clang was not able to be used with complex C++ code, but trunk Clang already can compile LLVM itself. So I wonder if is there any of LLVM IDEs in development or

How to replace llvm-ld with clang?

青春壹個敷衍的年華 提交于 2019-12-03 17:47:32
问题 Summary: llvm-ld has been removed from the LLVM 3.2 release. I am trying to figure out how to use clang in its place in my build system. Note that I figured out the answer to my own question while writing it but I am still posting it in case it is useful to anyone else. Alternative answers are also welcome. Details : I have a build process which first generates bitcode using clang++ -emit-llvm . Then I take the bitcode files and link them together with llvm-link . Then I apply some standard

Generate assembly from C code in memory using libclang

为君一笑 提交于 2019-12-03 17:28:21
I need to implement a library that compiles C code to eBPF bytecode using LLVM/Clang as backend. The codes will be read from memory and I need to get the resultant assembly code in memory too. Until now, I have been able to compile to LLVM IR using the following code: #include <string> #include <vector> #include <clang/Frontend/CompilerInstance.h> #include <clang/Basic/DiagnosticOptions.h> #include <clang/Frontend/TextDiagnosticPrinter.h> #include <clang/CodeGen/CodeGenAction.h> #include <clang/Basic/TargetInfo.h> #include <llvm/Support/TargetSelect.h> using namespace std; using namespace

Calling fsincos instruction in LLVM slower than calling libc sin/cos functions?

大憨熊 提交于 2019-12-03 17:15:25
问题 I am working on a language that is compiled with LLVM. Just for fun, I wanted to do some microbenchmarks. In one, I run some million sin / cos computations in a loop. In pseudocode, it looks like this: var x: Double = 0.0 for (i <- 0 to 100 000 000) x = sin(x)^2 + cos(x)^2 return x.toInteger If I'm computing sin/cos using LLVM IR inline assembly in the form: %sc = call { double, double } asm "fsincos", "={st(1)},={st},1,~{dirflag},~{fpsr},~{flags}" (double %"res") nounwind this is faster than

LLVM cpp backend, does it replace c backend?

百般思念 提交于 2019-12-03 17:14:42
My question is regarding the CPP backend, does it serve the same purposes as the C backend? The C backend was one of my favorite LLVM features, and I'm very upset it was removed. Whats the real differences? I' most appreciative of any help. Reference: The LLVM 3.1 Release Notes "The C backend has been removed ..." The CPP backend creates LLVM API calls to create an AST that represent the equivalent of the LLVM assembly. You can try the CPP backend at http://llvm.org/demo/ by selecting the "LLVM C++ API code" Target . The C backend creates C code that execute the semantics of the LLVM assembly.

Which libraries do you need to link against for a clang program using blocks

不想你离开。 提交于 2019-12-03 17:00:31
I've discovered (below) that I need to use -fblocks when compiling code which uses blocks. What library do I need to link against to let the linker resolve _NSConcreteStackBlock? (On Ubuntu 9.10 AMD64.) chris@chris-desktop:~$ clang ctest.c ctest.c:3:25: error: blocks support disabled - compile with -fblocks or pick a deployment target that supports them void call_a_block(void (^blockptr)(int)) { ^ ctest.c:11:19: error: blocks support disabled - compile with -fblocks or pick a deployment target that supports them call_a_block( ^(int y) { ^ 2 diagnostics generated. chris@chris-desktop:~$ clang

Why is LLVM segfaulting when I try to emit object code?

扶醉桌前 提交于 2019-12-03 16:58:43
I'm trying to follow along with the LLVM tutorial on compiler implementation, but my code segfaults when I try to emit object code. Here's a minimal example that attempts to compile a function func . To keep things simple, func is a function that does nothing. #include <iostream> #include <llvm/ADT/Optional.h> #include <llvm/IR/BasicBlock.h> #include <llvm/IR/DerivedTypes.h> #include <llvm/IR/Function.h> #include <llvm/IR/IRBuilder.h> #include <llvm/IR/LLVMContext.h> #include <llvm/IR/LegacyPassManager.h> #include <llvm/IR/Module.h> #include <llvm/IR/Type.h> #include <llvm/IR/Verifier.h>

Generating LLVM Code from Java

雨燕双飞 提交于 2019-12-03 16:27:20
问题 I want to use the LLVM code generation Framework from Java. I.e., I do not want to compile Java code into LLVM. I simply want an LLVM library for code generation that I can call from Java. The usual LLVM library is C, so I cannot use it. Are there any Java ports? If no, what would be the easiest way to do it anyway? Wrap the API into JNI? 回答1: A quick search for llvm java api bindings turned out several projects that seem like a good fit: LLVM-J JLLVM LAJ All of those libraries use JNI to