llvm

Is it possible to translate an assembly language to LLVM IR, optimize it and then recompile it to a different architecture?

徘徊边缘 提交于 2019-12-06 19:25:38
问题 Is it possible to translate an assembly language to LLVM IR, optimize it and then recompile it to a different architecture? How would you handle "push"es and "pop"s on the stack in the IR? This is the simplest objection I found, but I'm sure that there're tons like this. I'm planning to build a dynamic recompiler, and it seems that this would be an excellent solution, since LLVM would automatically optimize my code for the new architecture. Is all this possible with LLVM? Thanks 回答1: This is

Get pointer to llvm::Value previously allocated for CreateLoad function

霸气de小男生 提交于 2019-12-06 16:39:14
I'm new to llvm and I'm writing a small llvm IR Builder. I use the IRBuilder and all these Create* functions to generate my IR. What I'm trying to do is to create a load instruction which create a new SSA local variable with value of a previously allocated llvm::Value . What I expected to have : %2 = load i32* %1 With %2 results of load instruction and %1 my previously allocated Value (CreateAlloca) Here is what I tried : // Get Ptr from Val Value* ptr = ConstantExpr::getIntToPtr((Constant*)loc[n],PointerType::getUnqual(builder->getInt32Ty())); // Générate load instruction with the new Ptr

VSC 使用Clang-format 时报错:write EPIPE而不能使用自动格式

我的梦境 提交于 2019-12-06 16:13:05
问题 VSC 1.34.0 使用Clang-format 时报错:write EPIPE而不能使用自动格式 解决方法 填写clang-format运行位置的绝对路径 "clang-format.executable" : "C: \\ Users \\ Administrator \\ .vscode \\ extensions \\ ms-vscode.cpptools-0.23.1 \\ LLVM \\ bin \\ clang-format" } 我的配置 当前路径下创建文件: .clang-format , 内容如下: # https://clang.llvm.org/docs/ClangFormatStyleOptions.html # The .clang-format file uses YAML format: # Example of usage: BreakBeforeBraces: Custom BraceWrapping: AfterEnum: true AfterStruct: false SplitEmptyFunction: false AlignConsecutiveAssignments: true AlignOperands: true AllowShortLoopsOnASingleLine : true

Libclang API to get function definitions defined in a different file

被刻印的时光 ゝ 提交于 2019-12-06 16:03:12
问题 Suppose I have two files main.c and func.c func.c is called from main.c's main function. Normally, I would generate main.o and func.o and linker would find definition of func and tie it up to it's call in main .c Now, I want to do same thing through libclang APIs. This is for a Doxygen type code browsing utility I am making. I am able to parse the two files. From here, I don't know how to proceed. Should I generate *.o files and make clang link them? Thanks, I hope I am clear in asking the

Can LLVM 4.0 Be Used in Xcode 4.3?

荒凉一梦 提交于 2019-12-06 15:18:37
In other words, use literals but target for iOS 5. I am aware of this but that post is not conclusive. You can switch the compiler out, but it doesn't work as you might think (I tried it just now). There are a few requirements of the compiling SDK for using this new syntax (i.e. it will work on previous iOS versions, but you need to compile it with the iOS 6.0 SDK). I don't think I am allowed to discuss them here at the moment, but they are covered in detail in the "Modern Objective-C" WWDC 2012 video. Basically, you will have the syntax, but the libraries will not know how to respond to it.

llvm dependencies alloca-load

我与影子孤独终老i 提交于 2019-12-06 14:59:57
问题 I have some problems of finding dependencies. I want to get the corresponding Alloca from every Load (corresponding from the point of view of the variable used, meaning that the Load is using a variable based/dependent on the Alloca or Allocas). Hence, I have a chain like : Alloca -> Load(1) -> ... -> Computation where the variable might be changed -> Store(new_var) -> ... -> Load(n) "Computation where the variable is changed" means that : I might have Alloca(a), c=a+7000*b[32], Load(c) .

How to change LLVMPass long opt command to a simple Command

你说的曾经没有我的故事 提交于 2019-12-06 14:26:01
问题 I am working on LLVM obfuscation project. I have written a llvm pass(lets say flow flattening pass) which i am running on source (test.c) with following command: clang -emit-llvm test.c -c -o test.bc opt -load ../../.. LLVMFlattening.so -fla <test.bc>/dev/null But i have seen that in O-LLVM project they achieved same thing using: clang -emit-llvm test.c -c -o test.bc -mllvm -fla Can someone tell me what is -mllvm here and how this changed to a simple command? 回答1: -mllvm means Additional

How to tell if LLVM Instruction as a Left-Hand Side

孤者浪人 提交于 2019-12-06 14:20:48
Is there a way to tell if an LLVM Instruction has a left-hand side? That is, whether it produces a value? For example, an add instruction would have a left-hand side; however, a store or br instruction would not. In general you can identify those instructions which cannot have a result assignment, but you cannot say if an instruction will result in an assignment, only that it might . This is because you don't have to assign the result of an operation. For instance, the following line of code is valid in LLVM IR: add nsw i32 %a, %b but it's pointless because it has no effect whatsoever. No sane

What is LLVM metadata

。_饼干妹妹 提交于 2019-12-06 14:18:43
These might be very basic questions.. 1) What is LLVM metadata and how do I use it in my program? I've read all the documentation, but I don't understand how to use it. 2) How to I add my personal metadata in a file? Thanks in advance! The best source of information would be the blog post from 2010 that introduced metadata into LLVM IR - Extensible Metadata in LLVM IR . The first paragraph mentions the motivation: This metadata could be used to influence language-specific optimization passes (for example, Type Based Alias Analysis in C), tag information for a custom code generator, or pass

No format security warnings in Xcode 4.4

爱⌒轻易说出口 提交于 2019-12-06 13:23:49
问题 I don't get any format security warnings ( -Wformat-security ) from this code using Xcode 4.4: #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { // a = @"%@" or a = @"%@%@" NSString *a = [@"%@" stringByAppendingFormat:@"%@", arc4random_uniform(2)? @"%@": @"", nil]; // 50% change of crash, but no warning NSLog(a, @"Hello, World!"); } return 0; } Is this normal or have I somehow disabled this warning in Xcode? I have just created the project with