llvm

LLVM String Value objects: How can I retrieve the String from a Value?

给你一囗甜甜゛ 提交于 2019-12-04 02:19:26
When building the IR from an existing AST, my AST has some string values (at compile-time they are built from std::string ) and I want to set them safely as llvm::Value to use as a part of an expression. In this case, I don't need to bind the string at run-time, because string values are only meant to resolve stuff as variables, functions or classes at compile-time (the language doesn't support a native string type). Whats the best way to keep my string content as llvm::Value and still be able to retrieve it at later stages of compilation (when the nesting expressions are built)? More

Why does clang still need libgcc.a to compile my code?

ぃ、小莉子 提交于 2019-12-04 02:16:25
int main(int argc, char **argv) { return 0; } I cross compile (host= linux x86_64, target= linux aarch64) /path/to/clang --target=aarch64-linux-gnu -v main.cpp -o main -fuse-ld=lld -L./libs -lc -lc_nonshared -Xlinker -Map=a.map In the -L./libs folder I've put all the dependencies from the target. When I exclude libgcc.a this linker error happens ld.lld: error: unable to find library -lgcc I've added the -Map option to get information about the linked static libraries. In the map file I cannot see references to libgcc.a ... but I battle to read the map file. There are plenty of lines with

LLVM backend for stack based machine

孤人 提交于 2019-12-04 01:42:10
Does anyone know any example of an open source LLVM backend for a stack based machine? I need this for education purposes. The JVM is a stack-based virtual machine. VMKit was an open-source project of LLVM which implemented a JVM with a LLVM backend. The idea of VMKit was to create a toolkit for building virtual machines (or managed runtime environments) such as JVM, CLI/CLR, R's runtime etc. To find out more, see Nicolas Geoffray's PhD thesis . While the project is retired, the source code is still available . Also, Microsoft have released llilc which is a LLVM JIT compiler for IL/MSIL/CIL

Which optimization does LLVM perform?

痞子三分冷 提交于 2019-12-04 01:40:35
I would like concretely to know what does the various optimizations levels of LLVM correspond to. That is to say, I would like to know which optimization passes are EXACTLY executed (outside the frontend) and in which order when I use the "-0x" options of llvm (or clang or opt). The "man" of the corresponding tools do not provide much information on this matter (to the oposite of gcc's one). I am aware of this useful page: http://llvm.org/docs/Passes.html , but it does not provide any information regarding the "-Ox" options. I was looking for some debugging or verbose options (esp. using

LLVM and the future of optimization

自闭症网瘾萝莉.ら 提交于 2019-12-03 23:45:57
I realize that LLVM has a long way to go, but theoretically, can the optimizations that are in GCC/ICC/etc. for individual languages be applied to LLVM byte code? If so, does this mean that any language that compiles to LLVM byte code has the potential to be equally as fast? Or are language specific optimizations (before the LLVM bytecode stage) going to always play a large part in optimizing any specific program. I don't know much about compilers or optimizations (only enough to be dangerous), so I apologize if this question isn't well defined. In general, no. For example, in Haskell a common

How to embed LLVM?

南笙酒味 提交于 2019-12-03 23:37:05
The LLVM Core project consists of: Compiler - converts source code to LLVM IR VM - executes compiled IR code How can I embed the VM to a C++ application? Take a look at the HowToUseJIT example in LLVM. The LLVM is really a collection of libraries that you can link to, so it's pretty easy to embed. More often the LLVM takes IR that you generate and compiles it directly to machine code. There is also a library available to interpret and execute IR for platforms that do not support JIT compilation. There's a pretty good tutorial available on the LLVM website here: http://llvm.org/docs/tutorial/ .

Xcode “Message from debugger: got unexpected response to k packet: OK”

孤人 提交于 2019-12-03 22:48:59
I got this message when testing my app on simulator: Message from debugger: got unexpected response to k packet: OK What does it mean and is my app in any sort of danger? Using Xcode 6.4 & 7.2 If you look at the file ProcessGDBRemote.cpp in the llvm source code, you will see that this occurs when there is an unexpected response from Xcode's debugger process, in this case if the packet is not the 'W' or 'X' characters: Error ProcessGDBRemote::DoDestroy () { // ... if (m_gdb_comm.SendPacketAndWaitForResponse("k", 1, response, send_async) == GDBRemoteCommunication::PacketResult::Success) { char

Getting LLVM/Clang to be 16 bit aligned

佐手、 提交于 2019-12-03 22:26:49
I am working on a legacy project that has a large amount of files dating back to pre-OS X days. It's data has been 16 bit aligned for > 15 years. I would like to move to a full LLVM compilation but I can't seem to get 2 byte alignment working. Are there any compiler level options available for this? (previously using -malign-mac68k) I am aware of the #pragma pack(2) option here. However that would require me to modify upwards of 1000 source files to include this. That it's a worst-case option, but it seems like a hack. Besides, if this is possible then surely there is a default option to set

How to call functions from external DLL using LLVM IRBuilder?

落花浮王杯 提交于 2019-12-03 22:04:31
How to call functions from external DLL from LLVM? How to call a function defined in a DLL file from a LLVM code? As your question is missing vital information, I can guess that you want to achieve the following. I am guessing you will be using the c/c++ interface and that the function has a signature void fun(void) . I also guess that you will be using LLVM Builder to create calls to this very function (and not clang or the like). Start by using dlopen / loadlibrary to dynamically load the function and get the function pointer fnPtr . Create a Type* for the function's return value Type*

LLVM insert intrinsic function Cos

徘徊边缘 提交于 2019-12-03 21:19:55
问题 I am trying to insert intrinsic cos() function call to LLVM pass. My code in a FunctionPass: std::vector<Type *> arg_type; arg_type.push_back(Type::getFloatTy(getGlobalContext())); Function *fun = Intrinsic::getDeclaration(F.getParent(), Intrinsic::cos, arg_type); CallInst* callInst = CallInst::Create(fun, args, Twine("cos"), (Instruction *)&I); When I leave out last line generated IR is: define i32 @main() nounwind uwtable { entry: ... } declare float @llvm.cos.f32(float) nounwind readonly ,