llvm

How to cross-compile clang/llvm 3.7.0 for iOS8.x on ipad mini 3?

有些话、适合烂在心里 提交于 2019-12-08 10:46:55
问题 EDIT, 2015-10-24. This finally worked : ../configure --prefix=/usr/local/lvm-cross/llvm-ios --with-default-sysroot=/usr/local/iPhoneOS8.4.sdk --host=arm-apple-darwin11 --enable-optimized --disable-assertions --disable-libedit with clang -isysroot /usr/local/iPhoneOS8.4.sdk/ -target arm64-apple-darwin11 testcpp.cpp -o testcpp where testcpp.cpp contains : int main() { return 0; } Now if I modfified the source code simply as follows : #include <iostream> // I am not even calling << operator in

Clang Linking error: undefined reference to function calls added by LLVM pass

限于喜欢 提交于 2019-12-08 10:43:14
问题 So I am following this tutorial https://www.cs.cornell.edu/~asampson/blog/llvm.html to make a pass that instruments a program by adding calls to an external function (which is logop in rtlib.c). But unlike the tutorial I am trying to instrument a larger code-base which is masstree: https://github.com/kohler/masstree-beta. So as instructed for masstree I run ./configure first but then I edit the generated Makefile to use clang (instead of gcc/g++) and run my pass. I also add rtlib.c in the

Easiest way to work with intermediate format

安稳与你 提交于 2019-12-08 09:56:44
问题 A tool I'm working on needs to take the intermediate format generated by the compiler, add some code to it and then give that modified intermediate code to the backend of the compiler to generate the final code. By doing a little research on gcc, I found that the GIMPLE format is easy to understand, but I'm not sure about the complexity of modifying the GIMPLE code and don't know of any way to restart the compilation from there except using plugins and adding your own pass. Also people warned

C++/clang analyzer memory leaks?

无人久伴 提交于 2019-12-08 08:51:09
问题 I'm trying to get clang++ to tell me there is a memory leak. I tried scan-build but it reported nothing. How do I get llvm/clang to warn me of this problem? #include <iostream> int main() { int *a = new int; *a = 8; std::cout<< a << std::endl; } 回答1: False-positive pruning usually leads to removing all leaks that originate from main(), since the program will exit anyway. Try analyzing the same code, but in a different function. 回答2: Because int is too small, there is something like one

Undefined symbols for architecture x86_64: “std::terminate()”, when building kaleidoscope llvm

不羁的心 提交于 2019-12-08 08:39:23
问题 I'm doing the kaleidoscope tutorial. I'm on step two. https://github.com/westymatt/creole But I get this error when building with clang++ clang++ -Wno-c++11-extensions -g -std=c++11 -I/usr/local/Cellar/llvm/3.6.1/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS src/lexer.cc src/parser.cc -L/usr/local/Cellar/llvm/3.6.1/lib/ -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMProfileData

How do I link when building with llvm libraries?

混江龙づ霸主 提交于 2019-12-08 07:55:12
问题 I am trying to parse a LLVM-IR file(.ll) and do a static analysis.. I found this sample code below, and I tried to build it, but I don't know which library to link. #include <iostream> #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IRReader/IRReader.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; int main(int argc, char** argv) { if (argc < 2) { errs() << "Expected an argument - IR file name\n"; exit(1); }

Can LLVM 4.0 Be Used in Xcode 4.3?

∥☆過路亽.° 提交于 2019-12-08 07:44:42
问题 In other words, use literals but target for iOS 5. I am aware of this but that post is not conclusive. 回答1: 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"

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

ぃ、小莉子 提交于 2019-12-08 07:34:16
问题 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*

changing llvm::Function signature after code generation, before last CreateRet

烂漫一生 提交于 2019-12-08 06:48:00
问题 I'm trying to implement the following functionality; a function with no explicit return will by default return the last evaluation in the last executed block So, currently the process i'm doing is 1) create a Function llvm::Function* result = llvm::Function::Create(Compiler::Detail::getAnonymousFunctionSignature(llvmContext), llvm::GlobalValue::ExternalLinkage, name, module()); result->setCallingConv( llvm::CallingConv::C ); 2) add blocks and evaluations to the blocks builder.createFoo.....

How to intercept LLVM lli tool input?

青春壹個敷衍的年華 提交于 2019-12-08 01:02:14
问题 I'd like to use LLVM lli tool as static library (rename main() to lli() and export it in libLLi.a) - to create rich UI for it. How can i modify it (or use without modifications) in order to intercept stdin? Assume i know how to generate LLVM assembly file (using clang -S -emit-llvm .. -o output.ll ) and how to execute it using lli tool ( lli output.ll ). Common use case: Source code of simple app to be interpreted by lli: #include <iostream> using namespace std; int main() { char name[128];