llvm

How to figure out if particular LLVM instruction depends on the other?

▼魔方 西西 提交于 2019-12-12 12:11:55
问题 I'm trying to write an LLVM optimization pass. And I need a way to determine if one LLVM instruction affects the other (or depends on the other). These dependencies can have different nature: first instruction creates a value, the other uses it as operand first instructions writes to memory location, the other reads from there other possibilities? In short, first instruction must always be executed before the other in order to preserve code correctness. Three-way answer (depends, may depend,

How to convert javascript to LLVM IR?

拟墨画扇 提交于 2019-12-12 12:08:19
问题 Is there any LLVM backend for javascript? If not, other tools that convert dynamic language(similar to javascript) to LLVM IR will also be okay. Because I am writing a dynamic language compiler and such tools can help me find out how some features are implemented. 回答1: FTL JIT (JavaScriptCore) uses LLVM as a backend. Other VMs for dynamic languages using LLVM MCJIT: Pyston HHVM LLILC Julia The list goes on 回答2: I think you can have a look at Emscripten. It's a llvm-backend for asm.js. But

How to get the arguments of a function pointer from a CallExpr in Clang?

浪尽此生 提交于 2019-12-12 11:33:26
问题 I am trying to analyse C source code with function calls within them. I am able to analyse normal function calls to get their arguments without problem using the source code below where ce is a CallExpr object: 1. if(ce != NULL) { 2. QualType q = ce->getType(); 3. const Type *t = q.getTypePtrOrNull(); 4. 5. if (t != NULL) { 6. llvm::errs() << "TYPE: " << t->isFunctionPointerType() << " " << q.getAsString() << " " << t->isPointerType() << "\n"; 7. } else { 8. llvm::errs() << "FUNCTION CE HAS

How does JIT compilation actually execute the machine code at runtime?

試著忘記壹切 提交于 2019-12-12 11:22:58
问题 I understand the gist of how JIT compilation works (after reading such resources as this SO question). However, I am still wondering how does it actually execute the machine code at runtime? I don't have a deep background in operating systems or compiler optimizations, and haven't done anything with machine code directly, but am starting to explore it. I have started playing around in assembly, and see how something like NASM can take your assembly code and compile it to machine code (the

How to find inadvertent object pointer comparisons?

被刻印的时光 ゝ 提交于 2019-12-12 11:04:06
问题 Quick question - Is there a good way to find uses of == with objects instead of isEqual: ? Full story: I had a bunch of code kind of like this: typedef long DataKey; DataKey x; DataKey y; if (x == y) { // do stuff } I now have a need to replace using a long for my DataKey with an object. After creating the class and doing a bunch of global search and replace, my code now is kind of like this: @interface DataKey : NSObject DataKey *x; DataKey *y; if (x == y) { // uh-oh - this is now bad // do

Clang++ --gcc-toolchain and gcc 4.9.3 linking issues

随声附和 提交于 2019-12-12 10:57:18
问题 (Ubuntu 16.04.1) By default on 16.04.1 clang is picking the gcc tool chain for 5.4. Unfortunately I have a library that requires pre-5.0 ABI and I do NOT have access to the source, nor has the implementer released a new version. I've been trying to use the --gcc-toolchain option, but I can NOT get it to work. (ctrbegin.o and crtend.o don't get the proper prefix at link.) $ clang++-3.8 -v -print-search-dirs clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final) Target: x86_64-pc-linux-gnu

LLVM OS X symbol(s) not found for architecture x86_64 compile error

旧街凉风 提交于 2019-12-12 10:53:08
问题 I have succesfully compiled the LLVM kalidoscope examples in C. Now I'm extending the code with: #include "llvm/Support/CommandLine.h" static cl::opt<std::string> InputFilename(cl::Positional, cl::desc("<input file>"), cl::Required); int mail(... now i compile using: clang++ -g toy.cpp llvm-config --cppflags --ldflags --libs all -O3 -o toy and after this change i receive the following error: Undefined symbols for architecture x86_64: "typeinfo for llvm::cl::GenericOptionValue", referenced

Save breakpoints in LLDB

随声附和 提交于 2019-12-12 10:38:49
问题 How can I save breakpoints in lldb? This is a feature that gdb has and I suspect that lldb has it too but I haven't been able to find it in the help. How this is done in gdb: Getting gdb to save a list of breakpoints? 回答1: As Jim Ingham said above, you currently cannot save breakpoints in lldb. However, there is a work around. You can load lldb commands from a command file as follows: lldb -S <path_to_command_file> You can have this in your command file: file <path_to_binary> breakpoint set -

How to check the LLVM compiler version Xcode is using?

吃可爱长大的小学妹 提交于 2019-12-12 10:32:51
问题 I'm using Xcode 4.5.2 on OS X 10.8.2. How do I know which version of LLVM compiler Xcode is using? 回答1: From UI: Click on your project Choose a target (it may be choosen by default) Click on Build Settings tab Scroll it to see "Apple LLVM complier: X.X - Code generation" X.X is version of your LLVM 回答2: From the command line: 07:40:35 andrew@iMac SalesIQ (siq-303)$ llvm-gcc -v Using built-in specs. Target: i686-apple-darwin11 Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67

svn - How do I download a specific release of llvm,clang

别说谁变了你拦得住时间么 提交于 2019-12-12 09:56:57
问题 When I svn co llvm-3.3,clang-3.3,compiler -rt, build passes but build didn't create clang exe in build/Debug+Asserts. When I put only clang for svn co build didn't pass but he creates clang exe. I'm Linux user on Ubuntu. make[4]: Leaving directory `/home/rtrk/llvm/test/branches_release/release_33-build/tools/clang/runtime/compiler-rt' make[3]: *** [compiler-rt/.makeall] Error 2 make[3]: Leaving directory `/home/rtrk/llvm/test/branches_release/release_33-build/tools/clang/runtime' make[2]: ***