llvm

clang and __float128 bug/error

二次信任 提交于 2019-12-04 16:32:07
问题 I've successfully compiled the current 3.3 branch of clang. But then C++ compilation of any file fails with the bug/error. Can that be fixed? In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/iostream:39: In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/ostream:39: In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/ios:40: In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../..

llvm pass: How to insert a variable using existing variable value

你离开我真会死。 提交于 2019-12-04 16:14:27
I defined int a = 5 ; in the source code, and I transform the source to LLVM IR: %a = alloca i32, align 4 store i32 5, i32* %a, align 4 I want to insert int b = a; by writing a pass. I compile int a=5; int b=a into LLVM IR, it load "a" first, then store it. I also checked the doxygen, in which the LoadInst is LoadInst (Value *Ptr, const Twine &NameStr, Instruction *InsertBefore) Still, I don't know how to get the Value of "a". How to get a variable value? In LLVM IR the sequence int a = 5; int b = a; without any optimization, is translated as %a = alloca i32, align 4 %b = alloca i32, align 4

CLang libc, libc++ on Windows with debugging symbols compatible with Visual Studio

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 14:56:43
I'm trying to find info and I don't see it on clang web site. I'm thinking to try to use it on windows, but I have no clue if it has it's own libc or it uses broken libc from MS? another question: if i compile code with clang, will I be able to use visual studio as a debugger, e.g. is clang capable of emitting debugging symbols in MS format (this is the reason I don't want to use gcc; and this is something that intel compiler can do, but it uses MS's libc). In short, I'd like to be able to use visual studio as a debugger, but I need at the same time decent real c compiler with normal lib c. or

How to get the filename and directory from a LLVM Instruction?

我们两清 提交于 2019-12-04 14:27:55
I need to extract the directory and filename during a llvm pass. The current version of llvm moved getFilename and getDirectory from DebugLoc to DebugInfoMetadata . I can't find a class member getFilename directly in the DebugLoc header. Thus, how to do I go from an instruction to source code filename and directory? http://llvm.org/docs/doxygen/html/classllvm_1_1DebugLoc.html Additionally, there is a print function that might help but it only takes a llvm::raw_ostream and can't be redirected to a std::string . void print (raw_ostream &OS) const // prints source location /path/to/file.exe:line

How to use Clang CompilerInstance for completion?

两盒软妹~` 提交于 2019-12-04 14:16:59
问题 I have a library which uses and exposes a clang::CompilerInstance. How can I use the CompilerInstance for getting code-completion- suggestions ? Basically I'm looking to write a function with the following signature: vector<string> completeSnippet( clang::CompilerInstance CI, string codeSnippet, int completeAtIndex ); Any ideas ? Thanks in advance 回答1: To be honest I didn't figure out how to implement vector<string> completeSnippet( clang::CompilerInstance CI, string codeSnippet, int

Compilation failing on EnableABIBreakingChecks

本小妞迷上赌 提交于 2019-12-04 13:31:27
I recently installed LLVM v8.0.0 (on RHEL 7.4). I am going through the LLVM Kaleidoscope tutorial to learn how to use the system, but am running into an issue linking. Per the tutorial ( end of chapter 2 ), I run: clang++ -g -O3 kld.cpp `llvm-config --cxxflags` -o kld It compiles, but the linker fails on: /tmp/kld-f7264f.o:(.data+0x0): undefined reference to `llvm::EnableABIBreakingChecks' clang-8: error: linker command failed with exit code 1 (use -v to see invocation) I suspected this may have been an issue with llvm-config , so I also tried using the --ldflags and --system-libs flags, but

How to instrument a statement just before another statement using clang

戏子无情 提交于 2019-12-04 13:19:37
问题 I have to instrument certain statements in clang by adding a statement just before it. I have a pointer to an Expr object using which I need to insert another statement just before the statement containing it. Right now I am using a hacky approach which just moves back the SourceLocation pointer till I see a ; or } or {. But this does not work for all cases. eg when I try to instrument a for statement, it fails. Is there any class in clang which provides a method to do this in a more cleaner

How to build LLVM source code on Eclipse?

无人久伴 提交于 2019-12-04 13:19:17
I am trying to add a new pass to the llvm compiler infrastructure. I have been able to build LLVM-2.9 using make.But I wants to build using Eclipse so that I can trace the code. I imported llvm source files to c++ project with LinuxGcc tool chain and CDT internal builder(Eclipse with CDT-7.0).But it gives some errors. Is this is a right way to build llvm using eclipse?. Please suggest me steps involved to build llvm source using Eclipse. Note: Platform ubuntu. You can use cmake -G"Eclipse CDT4 - Unix Makefiles" to produce the native Eclipse set of projects. It might require tweaking your

At which level does one unit test lock-free code?

时光毁灭记忆、已成空白 提交于 2019-12-04 12:50:29
Can LLVM, QEMU, GDB, Bochs, OpenStack or the like be used to unit test lock-free concurrent code on an open-source platform? Has anyone achieved this? If you answer by recommending software, I don't mind, but I mention LLVM, QEMU and the others because these function at various different levels. I should like to learn at which level practical success has been found at interleaving threads under unit-test control. I am aware of SPIN/Promela, incidentally. That is fine software but one cannot compile C++, Rust, etc., onto a SPIN/Promela target as far as I know. Examples of existing, open-source

Get cpu cycles of LLVM IR using CostModel

跟風遠走 提交于 2019-12-04 12:31:55
问题 Since LLVM 3.0, there is CostModel.cpp under Analysis directory. Referring to its doc, it says This file defines the cost model analysis. It provides a very basic cost estimation for LLVM-IR. This analysis uses the services of the codegen to approximate the cost of any IR instruction when lowered to machine instructions. The cost results are unit-less and the cost number represents the throughput of the machine assuming that all loads hit the cache, all branches are predicted, etc. The cost