llvm-ir

clang segfaults when compiling LLVM IR

安稳与你 提交于 2019-12-14 03:08:45
问题 I am trying to compile a LLVM IR file. However, when I try to compile it, I get this stack trace: warning: overriding the module target triple with x86_64-pc-linux-gnu [-Woverride-module] #0 0x00007f415c9179fa llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x8549fa) #1 0x00007f415c915c76 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x852c76) #2 0x00007f415c915dab (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1

LLVM front end register class error OpenCL — GPU target

╄→гoц情女王★ 提交于 2019-12-13 06:56:25
问题 I've recently been encountering this error when compiling OpenCL kernel files with my LLVM_IR pass: aoc: ../../../TargetRegisterInfo.cpp:89: const llvm::TargetRegisterClass* llvm::TargetRegisterInfo::getMinimalPhysRegClass(unsigned int, llvm::EVT) const: Assertion `BestRC && "Couldn't find the register class"' failed. I'm not sure what this means. What I've read from the documention doesn't make a lot of sense. Basically it means the backend doesn't know what type to place into the register?

LLVM what does i32 (…)** mean in type define?

情到浓时终转凉″ 提交于 2019-12-13 04:21:24
问题 I create a class called student: class Student{ public: int getNumber() const { return number; } virtual void setNumber(int number) { Student::number = number; } private: int number; }; and converted it to IR, but there's one part confused me a lot: %class.Student = type <{ i32 (...)**, i32, [4 x i8] }> I believe the i32 (...)** part is for v-table, the i32 part is for int number and the [4 x i8] part is for alignment. But I searched the language references and could not find what i32 (...)**

How to save the variable name when use clang to generate llvm ir?

橙三吉。 提交于 2019-12-13 00:07:29
问题 I generate ir by use 'clang -S -emit-llvm test.c'. int main(int argc, char **argv) { int* a=0; a=(int *)malloc(sizeof(int)); printf("hello world\n"); return 0; } and this is the ir: define i32 @main(i32, i8**) #0 { %3 = alloca i32, align 4 %4 = alloca i32, align 4 %5 = alloca i8**, align 8 %6 = alloca i32*, align 8 store i32 0, i32* %3, align 4 store i32 %0, i32* %4, align 4 store i8** %1, i8*** %5, align 8 store i32* null, i32** %6, align 8 %7 = call noalias i8* @malloc(i64 4) #3 %8 =

LLVM “Instruction does not dominate all uses” - Inserting new Instruction

元气小坏坏 提交于 2019-12-12 20:09:31
问题 I am getting the following error while inserting an instruction using an llvm pass: Instruction does not dominate all uses! %add = add nsw i32 10, 2 %cmp3 = icmp ne i32 %a.01, %add Broken module found, compilation aborted! I have the source code in a bitcode file whose snippet is: if.then: ; preds = %entry %add = add nsw i32 10, 2 br label %if.end if.else: ; preds = %entry %sub = sub nsw i32 10, 2 br label %if.end if.end: ; preds = %if.else, %if.then %a.0 = phi i32 [ %add, %if.then ], [ %sub,

Compiling C++ on the fly: clang/libtooling fails to set Triple for LLVM IR

跟風遠走 提交于 2019-12-12 12:16:48
问题 Let's say I want to compile a C++ string on the fly: llvm::LLVMContext context; std::unique_ptr<clang::CodeGenAction> action = std::make_unique<clang::EmitLLVMOnlyAction>(&context); clang::tooling::runToolOnCode/*WithArgs*/(action.get(), "int foo(int x){ return ++x;}"); std::unique_ptr<llvm::Module> module = action->takeModule(); Unfortunately, it seems that when LLVM tries to transform the IR, there is an exception saying that the Triple is not set (https://clang.llvm.org/docs

How to convert javascript to LLVM IR?

拟墨画扇 提交于 2019-12-12 12:08:19
问题 Is there any LLVM backend for javascript? If not, other tools that convert dynamic language(similar to javascript) to LLVM IR will also be okay. Because I am writing a dynamic language compiler and such tools can help me find out how some features are implemented. 回答1: FTL JIT (JavaScriptCore) uses LLVM as a backend. Other VMs for dynamic languages using LLVM MCJIT: Pyston HHVM LLILC Julia The list goes on 回答2: I think you can have a look at Emscripten. It's a llvm-backend for asm.js. But

Incorrect LLVM alias analysis

孤街醉人 提交于 2019-12-11 21:31:41
问题 I'm asking a question similar to this post about an LLVM alias analysis that seems to give incorrect results. Since it contains considerable re-writing, I have decided to post it as a separate question. I'm running this very simple code: char *foo() { int i; int size; char *s=malloc(5); char *p=malloc(8); while ((i < size) && (s < p)) { i--; } return NULL; } Every time my code runs into an icmp instruction, I ask whether its operands can be aliases of one another. For the first comparison it

How to fix segmentation fault in genrated llvm bytecode?

我们两清 提交于 2019-12-11 17:57:50
问题 I'm currently working on a compiler using llvm, and it generates this code, which produces a segfault at the last dtore instruction of the case_body block of the test.main$v function. I'm not an expert in debugging manually in general and am especially a beginner with gdb etc. If someone could point out what grave error I've made here I'd be very grateful! ; ModuleID = 'test.bc' source_filename = "test" %test.Node = type { i32, %test.OptionalNode } %test.OptionalNode = type { i8, [8 x i8] }

How to get variable definition line number etc. using dbg metadata?

纵然是瞬间 提交于 2019-12-11 14:36:48
问题 As far as I know, when I need to get the line number of a local variable I had to look for the invocation of the llvm.dbg.declare intrinsics and get the dbg metadata(since AllocaInst itself does not contain any dbg info). However there seems no guarantee that this CallInst is the next instruction of the the AllocaInst , and I have to traverse the instruction in a specified function, which is inefficient. So I'm wondering whether there is a method for AllocaInst to get the llvm.dbg.declare