llvm

Indirect jump destination calculation

旧街凉风 提交于 2019-12-24 06:58:30
问题 Given an arbitrary executable, is it possible to determine some or all of the indirect branch destination addresses? What is a programmatic approach to computing these destinations? I'm asking because I am reconstructing a CFG from an executable and can't figure out a clean way of computing indirect branches. Sometimes the operand can be determined with a little forensic analysis, but other times it's not so clear. 回答1: Calculating possible indirect branch destinations in a compiled program

The use of getSmallConstantTripCount method of Loop in LLVM

隐身守侯 提交于 2019-12-24 06:16:10
问题 In my pass, I add LoopInfo as a required pass. Then I'd like to print the constant loop trip count of each loop if it has one. However, every time I called getSmallConstantTripCount , it returns 0, even for a very simple loop: for(i=0; i<3; ++i) {;} Any idea why? 回答1: LLVM has a principle of making each part do the least amount of work. LoopInfo::getSmallConstantTripCount doesn't do any fancy analysis, it looks for a simple loop with a single backedge that increments a value by 1 each time

Segfault when calling llvm_sys' LLVMCreateTargetMachine to generate object file in Rust

三世轮回 提交于 2019-12-24 05:53:27
问题 extern crate llvm_sys; use llvm_sys::*; use llvm_sys::prelude::*; use llvm_sys::core::*; pub fn emit(module: LLVMModuleRef) { unsafe { use llvm_sys::target_machine::*; let triple = LLVMGetDefaultTargetTriple(); let mut target: LLVMTargetRef = std::mem::uninitialized(); LLVMGetTargetFromTriple(triple, &mut target, ["Cannot get target.\0".as_ptr() as *mut i8].as_mut_ptr()); let cpu = "x86\0".as_ptr() as *const i8; let feature = "\0".as_ptr() as *const i8; let opt_level = LLVMCodeGenOptLevel:

LLVM Interoperability (Like JVM or .Net) - Is it possible to do?

六眼飞鱼酱① 提交于 2019-12-24 05:26:09
问题 I recently played around a bit with different LLVM Frontends like Clang (C Familiy ), LDC2 (D), Terra, ... All these languages can be compiled into the LLVM IR (somewhat readable) and LLVM IR Bitcode . So at this stage they are all on the same "level" right? My Question is : Is there some way of language interoperability like the .NET Languages or JVM Languages on "language level" or is it only possible to do it by editing in the IR? I already looked this question up in Google but didn't find

clang++ warning: “warning: unknown warning option '-Wno-maybe-uninitialized'”

南楼画角 提交于 2019-12-24 04:15:35
问题 Having installed LLVM on Ubuntu 16.04 using the command: sudo apt-get install clang llvm I get the following error when compiling: nlykkei@nlykkei-VirtualBox:~$ clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs` -o toy warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option] 1 warning generated. To be specific, I follow the tutorial: http://llvm.org/docs/tutorial/LangImpl03.html on the LLVM website. The

Is it possible to specify a hexadecimal number in LLVM IR code?

爷,独闯天下 提交于 2019-12-24 03:48:19
问题 For example: error: floating point constant invalid for type %3 = and i8 0x80, %2 ^ 回答1: From a scan of the IR reference manual, it looks like hexadecimal literals are reserved for the representation of floating point numbers that cannot be exactly represented in a reasonable number of digits. Which explains why your error message says that the floating point constant is invalid. 来源: https://stackoverflow.com/questions/16310509/is-it-possible-to-specify-a-hexadecimal-number-in-llvm-ir-code

Clang AST dump doesn't show #defines

最后都变了- 提交于 2019-12-24 02:58:40
问题 I'm dumping the AST of some headers like this: clang -cc1 -ast-dump -fblocks header.h However, any #define s on the header are not showing on the dump. Is there a way of adding them? 回答1: It's true, #defines are handled by the preprocessor, not the compiler. So you need a preprocessor parser stage. I know of two: Boost Wave can preprocess the input for you, and/or give you hooks to trigger on macro definitions or uses. The Clang tool pp-trace uses a Clang library that can do callbacks on many

Clang AST dump doesn't show #defines

邮差的信 提交于 2019-12-24 02:58:07
问题 I'm dumping the AST of some headers like this: clang -cc1 -ast-dump -fblocks header.h However, any #define s on the header are not showing on the dump. Is there a way of adding them? 回答1: It's true, #defines are handled by the preprocessor, not the compiler. So you need a preprocessor parser stage. I know of two: Boost Wave can preprocess the input for you, and/or give you hooks to trigger on macro definitions or uses. The Clang tool pp-trace uses a Clang library that can do callbacks on many

How to get all the line number of a variable from source code given LLVM IR?

喜你入骨 提交于 2019-12-24 02:44:07
问题 I am totally a newbie in LLVM. I wanted to know how we can get all the line numbers for a particular variable from source code given LLVM IR? For example (showing snippet of LLVM IR) store i32 0, i32* %i, align 4, !dbg !12 !12 = !DILocation(line: 2, column: 6, scope: !7) %4 = load i32*, i32** %ip, align 8, !dbg !30 !30 = !DILocation(line: 7, column: 4, scope: !25) I believe, from inspecting LLVM IR, getting the line number details for any variable has something to do with accessing !dbg at

llvm not generation byte code properly

删除回忆录丶 提交于 2019-12-24 02:30:31
问题 I've installed llvm 3.0 with llvm-gcc 4.6 on ubuntu 11.10. I'm trying to do the "example with llvm-gcc4" on http://llvm.org/docs/GettingStarted.html#tutorial4 But here's what I get: buse@buseZenbook:~$ gcc --version gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. buse@buseZenbook:~$ llvm-gcc --version