llvm-c++-api

Compilation failing on EnableABIBreakingChecks

送分小仙女□ 提交于 2019-12-06 06:42:18
问题 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

Possible to auto-generate llvm c++ api code from LLVM-IR?

心不动则不痛 提交于 2019-12-04 22:15:15
问题 The clang 3.0 online demo page http://llvm.org/demo/index.cgi provides an option to output LLVM C++ API code" representing the LLVM-IR for the input program. Is "produce LLVM C++ API code" output a clang option (and if so, what is it)? Or is it an llvm tool option (which one)? Is it possible to do the same thing but from LLVM-IR input? Basically I'd like to see the proper llvm c++ api calls needed to produce a particular given llvm-ir sequence. I'd like to learn backwards by example rather

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

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

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

Clang Tool: rewrite ObjCMessageExpr

99封情书 提交于 2019-12-04 10:08:34
问题 I want to rewrite all messages in my code, I need replace only selectors, but I need be able to replace nested expressions f. e. : [super foo:[someInstance someMessage:@""] foo2:[someInstance someMessage2]]; I tried do it with clang::Rewriter replaceText and just generate new string, but there is a problem: It would not be work if I change selectors length, because I replace nested messages with those old positions. So, I assumed that I need to use clang::Rewriter ReplaceStmt

Possible to auto-generate llvm c++ api code from LLVM-IR?

只愿长相守 提交于 2019-12-03 16:13:36
The clang 3.0 online demo page http://llvm.org/demo/index.cgi provides an option to output LLVM C++ API code" representing the LLVM-IR for the input program. Is "produce LLVM C++ API code" output a clang option (and if so, what is it)? Or is it an llvm tool option (which one)? Is it possible to do the same thing but from LLVM-IR input? Basically I'd like to see the proper llvm c++ api calls needed to produce a particular given llvm-ir sequence. I'd like to learn backwards by example rather than forwards from the documentation. Manual pages and --help and --help-hidden for clang, llvm-as and

Clang Tool: rewrite ObjCMessageExpr

柔情痞子 提交于 2019-12-03 05:03:45
I want to rewrite all messages in my code, I need replace only selectors, but I need be able to replace nested expressions f. e. : [super foo:[someInstance someMessage:@""] foo2:[someInstance someMessage2]]; I tried do it with clang::Rewriter replaceText and just generate new string, but there is a problem: It would not be work if I change selectors length, because I replace nested messages with those old positions. So, I assumed that I need to use clang::Rewriter ReplaceStmt(originalStatement, newStatement); I am using RecursiveASTVisitor to visit all messages, and I want to copy those

Run default optimization pipeline using modern LLVM

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 04:39:01
I'm using LLVM 7 and I have an llvm::Module that I'd like to optimize using the standard optimization pipeline. Unfortunately, there isn't a llvm::runDefaultOptimizations function that I can call. There seems to be a bajillion ways to optimize a module in LLVM. My searches on this topic have found many old/depreciated APIs and some examples that don't work on my system. I want to run all of the standard optimizations at -O3 with the least amount of hassle possible. I don't want to manually list all of the passes or even write a for loop. I thought llvm::PassBuilder:

Run default optimization pipeline using modern LLVM

三世轮回 提交于 2019-12-02 02:43:04
问题 I'm using LLVM 7 and I have an llvm::Module that I'd like to optimize using the standard optimization pipeline. Unfortunately, there isn't a llvm::runDefaultOptimizations function that I can call. There seems to be a bajillion ways to optimize a module in LLVM. My searches on this topic have found many old/depreciated APIs and some examples that don't work on my system. I want to run all of the standard optimizations at -O3 with the least amount of hassle possible. I don't want to manually