llvm

program loading/execution

断了今生、忘了曾经 提交于 2019-12-04 10:12:15
I'm a beginner in compilers but I'm very interested in learning about how a program is structured (the binary) and how it is read and loaded in memory for execution. What ebooks/books/tutorials do you guys suggest me reading for a quick start? Compilers and executable binaries are remotely related. (the actual executable is built by the linker ld , not the compiler). On Linux systems, the linux kernel use copy-on-write and demand-paging techniques to lazily load the program pages, for ELF executables. Shared libraries may be dynamically loaded and preferably contain position independent code .

isKindOfClass doesn't work as expected

筅森魡賤 提交于 2019-12-04 09:25:41
问题 i'm working on a iOS5+ project (xcode 4.4.1 SDK 5.1) i have this code inside a unit test: [_appDelegate application:nil didFinishLaunchingWithOptions:nil]; UITabBarController *tabBarController = (UITabBarController*)_appDelegate.window.rootViewController; NSArray *viewControllers = [tabBarController viewControllers]; UINavigationController *nc_1 = [viewControllers objectAtIndex:0]; UIViewController *vc_1 = nc_1.topViewController; STAssertTrue([vc_1 isKindOfClass:[ScheduleViewController class]

How can I declare a global variable in LLVM?

空扰寡人 提交于 2019-12-04 09:17:36
问题 I'd like to record some dynamic behaviors into some global variables. So I wrote a pass to instrument the code and insert some instructions to update the global variable. I tried to use the GlobalVariable constructor to define a global variable, but there are two problems. First, how can I DEFINE the global variables in the module containing main function? Second, how can I DECLARE those global variables in other modules? It's like "extern double someThing;". The target programs are written

Clang - Compiling a C header to LLVM IR/bitcode

天大地大妈咪最大 提交于 2019-12-04 08:57:14
问题 Say I have the following trivial C header file: // foo1.h typedef int foo; typedef struct { foo a; char const* b; } bar; bar baz(foo*, bar*, ...); My goal is to take this file, and produce an LLVM module that looks something like this : %struct.bar = type { i32, i8* } declare { i32, i8* } @baz(i32*, %struct.bar*, ...) In other words, convert a C .h file with declarations into the equivalent LLVM IR, including type resolution, macro expansion, and so on. Passing this through Clang to generate

Building and using a pure llvm toolchain for c++ on linux

大憨熊 提交于 2019-12-04 08:56:17
Assuming this is possible, could someone tell me, how I have to configure the cmake build to create a "pure" llvm toolchain on ubuntu-16.04 consisting of clang lld libc++ libc++abi libunwind (llvm) compiler-rt any other pieces that might be relevant and are "production ready" The resulting compiler should be as fast as possible (optimizations turned on, no unnecessary asserts or other checks in the compiler binary itself) be installed in a separate, local directory (lets call it <llvm_install> ) not have dependencies to the llvm tolchain provided by packet manager use libc++, libc++abi etc by

How to install clang pre-built binaries ubuntu 12.04

半腔热情 提交于 2019-12-04 08:26:28
问题 I am very new to linux, and don't know where I need to put Clang pre-built binaries http://llvm.org/releases/download.html#3.3 . I download it, unpack with mouse, and add path to /bin to my $PATH, and path to /lib to $LD_LIBRARY_PATH, and add *.conf with path to my /lib to /etc/ld.so.conf.d . I even reboot my notebook. ...but still cant build my simple program with Code::Blocks GCC (error: /home/aadgrand/tmp/LLVM-3.3/final/llvm.src/lib/Support/Signals.cpp - undefined reference to `dladdr').

How to efficiently implement closures in LLVM IR?

我只是一个虾纸丫 提交于 2019-12-04 08:18:04
问题 I started adding closures (lambdas) to my language that uses LLVM as the backend. I have implemented them for simple cases where they can be always inlined i.e. code for the closure definition itself doesn't need to be generated, as it is inlined where used. But how to generate the code for a closure in case the closure isn't always inlined (for example, it is passed to another function that isn't inlined). Preferably, the call sites shouldn't care whether they are passed regular functions or

what optimization passes are done for -O4 in clang?

匆匆过客 提交于 2019-12-04 08:18:00
We are trying to implement a jit compiler whose performance is supposed to be same as doing it with clang -o4. Is there a place where I could easily get the list of optimization passes invoked by clang with -o4 is specified? As far as I know -O4 means same thing as -O3 + enabled LTO (Link Time Optimization). See the folloing code fragments: Tools.cpp // Manually translate -O to -O2 and -O4 to -O3; Driver.cpp // Check for -O4. Also see here : You can produce bitcode files from clang using -emit-llvm or -flto, or the -O4 flag which is synonymous with -O3 -flto. For optimizations used with -O3

generating CFG for whole source code with LLVM

三世轮回 提交于 2019-12-04 08:10:40
Does anyone from LLVM community know if there is a way to generate CFG for the whole input source code using opt -dot-cfg foo.ll(.bc) ? as this one generates the CFG per function thus the connections between functions will be ignored. It seems that the older analyze tool has depreciated. Nhome I wonder if you found any way to get interprocedural CFG. I found that inlining call functions by other inliner passes might be helpful but I couldn't be able to get it to work yet. I've posted this Finding all possible paths in a c/c++ program by LLVM 来源: https://stackoverflow.com/questions/26556356

How to convert llvm IR to c code?

梦想的初衷 提交于 2019-12-04 08:06:01
Is there any way to convert the llvm IR to c code and keep its semantics? For example, can we compile the c code first to llvm IR and then compile it back to another piece of c code. I don't expect that these two files will be the same. But they need to have the same functionality. Thanks You can use the C backend, with llc -march=c 来源: https://stackoverflow.com/questions/8563670/how-to-convert-llvm-ir-to-c-code