<div dir="ltr">Hi Andy,<br><br>It looks like you're using LLVM's old JIT, rather than MCJIT? The old JIT has been removed from the mainline, and is no longer supported. I'd recommend building your own copy of LLVM from the development branch (as Reed suggested) where MCJIT is used by default - this may fix your issue.<div><br></div><div>If you want to stick with the precompiled binaries, then you should change:<br><br><font face="courier new, monospace">#include "llvm/ExecutionEngine/JIT.h"</font><br><br>to<br><br><font face="courier new, monospace">#include "llvm/ExecutionEngine/MCJIT.h"</font><br><br>and add:<br><br><font face="courier new, monospace">.setUseMCJIT(true)</font><br><br>to your EngineBuilder invocation.<br><br>And finally change:<br><br><font face="courier new, monospace">jit->getPointerToFunction(rtlib->getFunction("main"));</font><br><br>to<br><br><font face="courier new, monospace">jit->getFunctionAddress("main");</font><br><br>Cheers,<br>Lang.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 2, 2014 at 4:28 PM, Reed Kotler <span dir="ltr"><<a href="mailto:Reed.Kotler@imgtec.com" target="_blank">Reed.Kotler@imgtec.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It's really easy to build LLVM from source on any linux environment.<br>
<br>
________________________________________<br>
From: Andy Jost [<a href="mailto:Andrew.Jost@synopsys.com">Andrew.Jost@synopsys.com</a>]<br>
Sent: Tuesday, September 02, 2014 4:00 PM<br>
To: Reed Kotler; Andy Jost; <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a><br>
Subject: RE: Problem linking and JITing code through C++-API<br>
<div class="HOEnZb"><div class="h5"><br>
Yes. It appears that a bad reference to DataLayout was passed to MachineJumpTableInfo::getEntrySize. I'm using LLVM as a pre-compiled Ubuntu package for this work, so I can't do much more in GDB without building from source.<br>
<br>
Program received signal SIGSEGV, Segmentation fault.<br>
0x00000000007565f0 in llvm::MachineJumpTableInfo::getEntrySize(llvm::DataLayout const&) const ()<br>
(gdb) where<br>
#0 0x00000000007565f0 in llvm::MachineJumpTableInfo::getEntrySize(llvm::DataLayout const&) const ()<br>
#1 0x0000000000704313 in (anonymous namespace)::JITEmitter::getJumpTableEntryAddress(unsigned int) const ()<br>
#2 0x000000000070bce1 in (anonymous namespace)::JITEmitter::finishFunction(llvm::MachineFunction&) ()<br>
#3 0x0000000000474430 in (anonymous namespace)::Emitter<llvm::JITCodeEmitter>::runOnMachineFunction(llvm::MachineFunction&) ()<br>
#4 0x0000000000b214dc in llvm::FPPassManager::runOnFunction(llvm::Function&) ()<br>
#5 0x0000000000b21610 in llvm::FunctionPassManagerImpl::run(llvm::Function&) ()<br>
#6 0x0000000000b216f4 in llvm::FunctionPassManager::run(llvm::Function&) ()<br>
#7 0x00000000006fe26e in llvm::JIT::jitTheFunction(llvm::Function*, llvm::MutexGuard const&) ()<br>
#8 0x00000000006fe8cf in llvm::JIT::runJITOnFunctionUnlocked(llvm::Function*, llvm::MutexGuard const&) ()<br>
#9 0x00000000006fead2 in llvm::JIT::getPointerToFunction(llvm::Function*) ()<br>
#10 0x00000000006fd63f in llvm::JIT::getPointerToBasicBlock(llvm::BasicBlock*) ()<br>
#11 0x00000000009e14ee in llvm::ExecutionEngine::getConstantValue(llvm::Constant const*) ()<br>
#12 0x00000000009e265f in llvm::ExecutionEngine::InitializeMemory(llvm::Constant const*, void*) ()<br>
#13 0x00000000009e27e3 in llvm::ExecutionEngine::InitializeMemory(llvm::Constant const*, void*) ()<br>
#14 0x00000000009e3628 in llvm::ExecutionEngine::EmitGlobalVariable(llvm::GlobalVariable const*) ()<br>
#15 0x00000000006fd559 in llvm::JIT::getOrEmitGlobalVariable(llvm::GlobalVariable const*) ()<br>
#16 0x000000000070b8cd in (anonymous namespace)::JITEmitter::getPointerToGlobal(llvm::GlobalValue*, void*, bool) [clone .isra.439] ()<br>
#17 0x000000000070c505 in (anonymous namespace)::JITEmitter::finishFunction(llvm::MachineFunction&) ()<br>
#18 0x0000000000474430 in (anonymous namespace)::Emitter<llvm::JITCodeEmitter>::runOnMachineFunction(llvm::MachineFunction&) ()<br>
#19 0x0000000000b214dc in llvm::FPPassManager::runOnFunction(llvm::Function&) ()<br>
#20 0x0000000000b21610 in llvm::FunctionPassManagerImpl::run(llvm::Function&) ()<br>
#21 0x0000000000b216f4 in llvm::FunctionPassManager::run(llvm::Function&) ()<br>
#22 0x00000000006fe26e in llvm::JIT::jitTheFunction(llvm::Function*, llvm::MutexGuard const&) ()<br>
#23 0x00000000006fe8fa in llvm::JIT::runJITOnFunctionUnlocked(llvm::Function*, llvm::MutexGuard const&) ()<br>
#24 0x00000000006fead2 in llvm::JIT::getPointerToFunction(llvm::Function*) ()<br>
#25 0x00000000004285e7 in main () at sprite.cpp:172<br>
(gdb) x/10i $pc<br>
=> 0x7565f0 <_ZNK4llvm20MachineJumpTableInfo12getEntrySizeERKNS_10DataLayoutE>: cmpl $0x5,(%rdi)<br>
0x7565f3 <_ZNK4llvm20MachineJumpTableInfo12getEntrySizeERKNS_10DataLayoutE+3>: mov (%rdi),%edx<br>
0x7565f5 <_ZNK4llvm20MachineJumpTableInfo12getEntrySizeERKNS_10DataLayoutE+5>: lea 0x4ccc5c(%rip),%rax # 0xc23258<br>
0x7565fc <_ZNK4llvm20MachineJumpTableInfo12getEntrySizeERKNS_10DataLayoutE+12>: movslq (%rax,%rdx,4),%rdx<br>
0x756600 <_ZNK4llvm20MachineJumpTableInfo12getEntrySizeERKNS_10DataLayoutE+16>: add %rdx,%rax<br>
0x756603 <_ZNK4llvm20MachineJumpTableInfo12getEntrySizeERKNS_10DataLayoutE+19>: jmpq *%rax<br>
0x756605 <_ZNK4llvm20MachineJumpTableInfo12getEntrySizeERKNS_10DataLayoutE+21>: nopl (%rax)<br>
0x756608 <_ZNK4llvm20MachineJumpTableInfo12getEntrySizeERKNS_10DataLayoutE+24>: mov $0x4,%eax<br>
0x75660d <_ZNK4llvm20MachineJumpTableInfo12getEntrySizeERKNS_10DataLayoutE+29>: retq<br>
0x75660e <_ZNK4llvm20MachineJumpTableInfo12getEntrySizeERKNS_10DataLayoutE+30>: xchg %ax,%ax<br>
(gdb) x $rdi<br>
0x3eb000003ec: Cannot access memory at address 0x3eb000003ec<br>
<br>
<br>
-----Original Message-----<br>
From: Reed Kotler [mailto:<a href="mailto:rkotler@mips.com">rkotler@mips.com</a>]<br>
Sent: Tuesday, September 02, 2014 3:33 PM<br>
To: Andy Jost; <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a><br>
Subject: Re: Problem linking and JITing code through C++-API<br>
<br>
Have you tried running this under gdb and looking at where the segmentation fault occurs?<br>
<br>
<br>
On 09/01/2014 04:41 PM, Andy Jost wrote:<br>
> I have a frontend that generates some LLVM bitcode that needs to be<br>
> linked with other bitcode (its runtime library), which I generate from<br>
> C++ source using Clang.<br>
><br>
> If I write the output of my program to disk, link it with llvm-link, and<br>
> then run it with lli, everything works perfectly. But if I try to<br>
> perform the linking and running steps in my main program, I get this<br>
> error during llvm::ExecutionEngine::getPointerToFunction:<br>
><br>
> Stack dump:<br>
><br>
> 0. Running pass 'X86 Machine Code Emitter' on function<br>
> '@.step.myappend'<br>
><br>
> 1. Running pass 'X86 Machine Code Emitter' on function<br>
> '@.step.myappend'<br>
><br>
> Segmentation fault (core dumped)<br>
><br>
> There are no other messages. Any idea what I'm doing wrong? I'll copy<br>
> the source of my main C++ file and the bitcode for .step.myappend<br>
> below. I can send the full bitcode file, too, if someone asks for it,<br>
> but it is around 800 lines.<br>
><br>
> ####################<br>
><br>
> #include <fstream><br>
><br>
> #include <iostream><br>
><br>
> #include "llvm/Bitcode/ReaderWriter.h"<br>
><br>
> #include "llvm/ExecutionEngine/JIT.h"<br>
><br>
> #include "llvm/IR/DataLayout.h"<br>
><br>
> #include "llvm/Linker.h"<br>
><br>
> #include "llvm/PassManager.h"<br>
><br>
> #include "llvm/Support/MemoryBuffer.h"<br>
><br>
> #include "llvm/Support/raw_ostream.h"<br>
><br>
> #include "llvm/Support/system_error.h"<br>
><br>
> #include "llvm/Support/TargetSelect.h"<br>
><br>
> #include "llvm/Transforms/IPO.h"<br>
><br>
> #include "llvm/Transforms/Scalar.h"<br>
><br>
> #include "sprite/compiler.hpp"<br>
><br>
> #include "sprite/config.hpp"<br>
><br>
> #include "sprite/curryinput.hpp"<br>
><br>
> #include "sprite/icurry_parser.hpp"<br>
><br>
> namespace<br>
><br>
> {<br>
><br>
> std::string dirname(std::string const & path)<br>
><br>
> {<br>
><br>
> size_t const pos = path.find_last_of("/");<br>
><br>
> return path.substr(0, pos == std::string::npos ? 0 : pos);<br>
><br>
> }<br>
><br>
> std::string basename(std::string const & path)<br>
><br>
> {<br>
><br>
> size_t const pos = path.find_last_of("/");<br>
><br>
> return path.substr(pos == std::string::npos ? 0 : pos + 1);<br>
><br>
> }<br>
><br>
> std::string remove_extension(std::string const & path)<br>
><br>
> {<br>
><br>
> size_t const pos = path.find_last_of(".");<br>
><br>
> return pos == std::string::npos ? path : path.substr(0, pos);<br>
><br>
> }<br>
><br>
> std::string joinpath(std::string const & dirname, std::string const &<br>
> path)<br>
><br>
> {<br>
><br>
> if(!path.empty() && path.front() == '/')<br>
><br>
> return path;<br>
><br>
> if(dirname.empty())<br>
><br>
> return path;<br>
><br>
> return dirname.back() == '/' ? dirname + path : dirname + "/" + path;<br>
><br>
> }<br>
><br>
> }<br>
><br>
> int main(int argc, char const *argv[])<br>
><br>
> {<br>
><br>
> if(argc != 2)<br>
><br>
> {<br>
><br>
> std::cerr << "Usage: " << argv[0] << " <file.curry>" << std::endl;<br>
><br>
> return 1;<br>
><br>
> }<br>
><br>
> std::string const curry2read =<br>
><br>
> std::string(SPRITE_LIBINSTALL) + "/cmc/translator/bin/curry2read";<br>
><br>
> std::string const curryfile(argv[1]);<br>
><br>
> std::string const readablefile = joinpath(<br>
><br>
> dirname(curryfile)<br>
><br>
> , ".curry/" + remove_extension(basename(curryfile)) + ".read"<br>
><br>
> );<br>
><br>
> // Generate the readable Curry file.<br>
><br>
> int ok = std::system((curry2read + " -q " + curryfile).c_str());<br>
><br>
> if(ok != 0) return 1;<br>
><br>
> std::ifstream input(readablefile);<br>
><br>
> if(!input)<br>
><br>
> {<br>
><br>
> std::cerr << "Could not open \"" << readablefile << "\"" << std::endl;<br>
><br>
> return 1;<br>
><br>
> }<br>
><br>
> // Parse the input program.<br>
><br>
> sprite::curry::Library lib;<br>
><br>
> input >> lib;<br>
><br>
> std::string topmodule = lib.modules.front().name;<br>
><br>
> // sprite::compiler::prettyprint(lib);<br>
><br>
> // Compile the program.<br>
><br>
> sprite::compiler::LibrarySTab stab;<br>
><br>
> sprite::compiler::compile(lib, stab);<br>
><br>
> // Declare the main function.<br>
><br>
> namespace tgt = sprite::backend;<br>
><br>
> auto & module_stab = <a href="http://stab.modules.at" target="_blank">stab.modules.at</a>(topmodule);<br>
><br>
> auto & compiler = *module_stab.compiler;<br>
><br>
> tgt::scope _ = module_stab.module_ir;<br>
><br>
> tgt::extern_(<br>
><br>
> tgt::types::int_(32)(), "main", {}<br>
><br>
> , [&]{<br>
><br>
> // Construct the root expression (just the "main" symbol).<br>
><br>
> tgt::value root_p = compiler.node_alloc();<br>
><br>
> sprite::curry::Qname const main_{topmodule, "main"};<br>
><br>
> root_p = construct(compiler, root_p, {main_, {}});<br>
><br>
> // Evaluate and then print the root expression.<br>
><br>
> compiler.rt.normalize(root_p);<br>
><br>
> compiler.rt.printexpr(root_p, "\n");<br>
><br>
> tgt::return_(0);<br>
><br>
> }<br>
><br>
> );<br>
><br>
> // module_stab.module_ir->dump();<br>
><br>
> // Load the runtime library.<br>
><br>
> llvm::OwningPtr<llvm::MemoryBuffer> buffer;<br>
><br>
> llvm::error_code err = llvm::MemoryBuffer::getFile(<br>
><br>
> SPRITE_LIBINSTALL "/sprite-rt.bc", buffer<br>
><br>
> );<br>
><br>
> if(err)<br>
><br>
> {<br>
><br>
> std::cerr << err.message() << std::endl;<br>
><br>
> return EXIT_FAILURE;<br>
><br>
> }<br>
><br>
> // Make the runtime library into a module.<br>
><br>
> std::string errmsg;<br>
><br>
> llvm::Module *rtlib = llvm::ParseBitcodeFile(<br>
><br>
> buffer.get(), module_stab.module_ir.context(), &errmsg<br>
><br>
> );<br>
><br>
> if(!rtlib)<br>
><br>
> {<br>
><br>
> std::cerr << errmsg << std::endl;<br>
><br>
> return EXIT_FAILURE;<br>
><br>
> }<br>
><br>
> // Link the compiled program code into the runtime module.<br>
><br>
> bool failed = llvm::Linker::LinkModules(<br>
><br>
> rtlib, module_stab.module_ir.ptr(), llvm::Linker::PreserveSource,<br>
> &errmsg<br>
><br>
> );<br>
><br>
> if(failed)<br>
><br>
> {<br>
><br>
> std::cerr << errmsg << std::endl;<br>
><br>
> return EXIT_FAILURE;<br>
><br>
> }<br>
><br>
> std::cout << "Linking done..." << std::endl;<br>
><br>
> rtlib->dump();<br>
><br>
> // Run optimization passes.<br>
><br>
> // std::vector<const char *> exportList;<br>
><br>
> // llvm::PassManager Passes;<br>
><br>
> // Passes.add(new llvm::DataLayout(rtlib));<br>
><br>
> // Passes.add(llvm::createDemoteRegisterToMemoryPass());<br>
><br>
> // Passes.add(llvm::createInternalizePass(exportList));<br>
><br>
> // Passes.add(llvm::createScalarReplAggregatesPass());<br>
><br>
> // Passes.add(llvm::createInstructionCombiningPass());<br>
><br>
> // Passes.add(llvm::createGlobalOptimizerPass());<br>
><br>
> // Passes.add(llvm::createFunctionInliningPass());<br>
><br>
> // Passes.run(*rtlib);<br>
><br>
> // Create the JIT<br>
><br>
> llvm::InitializeNativeTarget();<br>
><br>
> llvm::ExecutionEngine * jit = llvm::EngineBuilder(rtlib)<br>
><br>
> .setErrorStr(&errmsg)<br>
><br>
> .setEngineKind(llvm::EngineKind::JIT)<br>
><br>
> .create();<br>
><br>
> if(!jit)<br>
><br>
> {<br>
><br>
> std::cerr << "Failed to create JIT compiler: " << errmsg << std::endl;<br>
><br>
> return EXIT_FAILURE;<br>
><br>
> }<br>
><br>
> // Execute the program.<br>
><br>
> std::cout << "Begin Execution..." << std::endl;<br>
><br>
> // rtlib->dump();<br>
><br>
> void * main_fp = jit->getPointerToFunction(rtlib->getFunction("main"));<br>
><br>
> int32_t (*target_program)() = (int32_t(*)())(intptr_t)(main_fp);<br>
><br>
> std::cout << "Ready..." << std::endl;<br>
><br>
> return target_program();<br>
><br>
> #if 0<br>
><br>
> // Write a bitcode file and interpret it.<br>
><br>
> {<br>
><br>
> std::string err;<br>
><br>
> llvm::raw_fd_ostream fout("sprite-out.bc", err,<br>
> llvm::raw_fd_ostream::F_Binary);<br>
><br>
> llvm::WriteBitcodeToFile(module_stab.module_ir.ptr(), fout);<br>
><br>
> }<br>
><br>
> std::system("llvm-link-3.3 sprite-out.bc " SPRITE_LIBINSTALL<br>
> "/sprite-rt.bc > tmp.bc");<br>
><br>
> std::system("mv tmp.bc sprite-out.bc");<br>
><br>
> int const status = std::system("lli-3.3 sprite-out.bc");<br>
><br>
> return WEXITSTATUS(status);<br>
><br>
> #endif<br>
><br>
> }<br>
><br>
> ####################<br>
><br>
> define linkonce void @.step.myappend(%"struct.sprite::compiler::node"*<br>
> %root_p) {<br>
><br>
> .entry:<br>
><br>
> %0 = alloca %"struct.sprite::compiler::node"*<br>
><br>
> %1 = alloca %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %root_p,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> %2 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %3 = getelementptr %"struct.sprite::compiler::node"* %2, i32 0, i32 2<br>
><br>
> %4 = load i8** %3<br>
><br>
> %5 = bitcast i8* %4 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %5,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> br label %11<br>
><br>
> ; <label>:6 ; preds = %11<br>
><br>
> %7 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %8 = getelementptr %"struct.sprite::compiler::node"* %7, i32 0, i32 2<br>
><br>
> %9 = load i8** %8<br>
><br>
> %10 = bitcast i8* %9 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %10,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> br label %11, !sprite.implied !0<br>
><br>
> ; <label>:11 ; preds = %6, %.entry<br>
><br>
> %12 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %13 = getelementptr %"struct.sprite::compiler::node"* %12, i32 0, i32 1<br>
><br>
> %14 = load i64* %13<br>
><br>
> %15 = load i64* %13<br>
><br>
> %16 = icmp eq i64 %15, -3<br>
><br>
> br i1 %16, label %6, label %17<br>
><br>
> ; <label>:17 ; preds = %11<br>
><br>
> %18 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> store %"struct.sprite::compiler::node"* %18,<br>
> %"struct.sprite::compiler::node"** %1<br>
><br>
> %19 = getelementptr %"struct.sprite::compiler::node"* %18, i32 0, i32 1<br>
><br>
> %20 = load i64* %19<br>
><br>
> %21 = add i64 %20, 4<br>
><br>
> %22 = getelementptr [6 x i8*]* @.jtable, i32 0, i64 %21<br>
><br>
> %23 = load i8** %22<br>
><br>
> indirectbr i8* %23, [label %24, label %26, label %36, label %38,<br>
> label %44, label %66]<br>
><br>
> ; <label>:24 ; preds = %26, %17<br>
><br>
> %25 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([16 x<br>
> i8]* @.str21, i32 0, i32 0))<br>
><br>
> ret void, !case...FAIL !1<br>
><br>
> ; <label>:26 ; preds = %26, %17<br>
><br>
> %27 = load %"struct.sprite::compiler::node"** %1<br>
><br>
> %28 = getelementptr %"struct.sprite::compiler::node"* %27, i32 0, i32 2<br>
><br>
> %29 = load i8** %28<br>
><br>
> %30 = bitcast i8* %29 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %30,<br>
> %"struct.sprite::compiler::node"** %1<br>
><br>
> %31 = getelementptr %"struct.sprite::compiler::node"* %30, i32 0, i32 1<br>
><br>
> %32 = load i64* %31<br>
><br>
> %33 = add i64 %32, 4<br>
><br>
> %34 = getelementptr [6 x i8*]* @.jtable, i32 0, i64 %33<br>
><br>
> %35 = load i8** %34<br>
><br>
> indirectbr i8* %35, [label %24, label %26, label %36, label %38,<br>
> label %44, label %66]<br>
><br>
> ; <label>:36 ; preds = %26, %17<br>
><br>
> %37 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x<br>
> i8]* @.str22, i32 0, i32 0))<br>
><br>
> ret void, !case...CHOICE !1<br>
><br>
> ; <label>:38 ; preds = %26, %17<br>
><br>
> %39 = load %"struct.sprite::compiler::node"** %1<br>
><br>
> %40 = getelementptr %"struct.sprite::compiler::node"* %39, i32 0, i32 0<br>
><br>
> %41 = load %"struct.sprite::compiler::vtable"** %40<br>
><br>
> %42 = getelementptr %"struct.sprite::compiler::vtable"* %41, i32 0, i32 4<br>
><br>
> %43 = load void (%"struct.sprite::compiler::node"*)** %42<br>
><br>
> tail call void %43(%"struct.sprite::compiler::node"* %39)<br>
><br>
> ret void<br>
><br>
> ; <label>:44 ; preds = %26, %17<br>
><br>
> store %"struct.sprite::compiler::node"* %root_p,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> %45 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %46 = getelementptr %"struct.sprite::compiler::node"* %45, i32 0, i32 3<br>
><br>
> %47 = load i8** %46<br>
><br>
> %48 = bitcast i8* %47 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %48,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> br label %54<br>
><br>
> ; <label>:49 ; preds = %54<br>
><br>
> %50 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %51 = getelementptr %"struct.sprite::compiler::node"* %50, i32 0, i32 2<br>
><br>
> %52 = load i8** %51<br>
><br>
> %53 = bitcast i8* %52 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %53,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> br label %54, !sprite.implied !0<br>
><br>
> ; <label>:54 ; preds = %49, %44<br>
><br>
> %55 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %56 = getelementptr %"struct.sprite::compiler::node"* %55, i32 0, i32 1<br>
><br>
> %57 = load i64* %56<br>
><br>
> %58 = load i64* %56<br>
><br>
> %59 = icmp eq i64 %58, -3<br>
><br>
> br i1 %59, label %49, label %60<br>
><br>
> ; <label>:60 ; preds = %54<br>
><br>
> %61 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %62 = bitcast %"struct.sprite::compiler::node"* %61 to i8*<br>
><br>
> %63 = getelementptr %"struct.sprite::compiler::node"* %root_p, i32 0,<br>
> i32 0<br>
><br>
> store %"struct.sprite::compiler::vtable"* @.fwd.vt,<br>
> %"struct.sprite::compiler::vtable"** %63<br>
><br>
> %64 = getelementptr %"struct.sprite::compiler::node"* %root_p, i32 0,<br>
> i32 1<br>
><br>
> store i64 -3, i64* %64<br>
><br>
> %65 = getelementptr %"struct.sprite::compiler::node"* %root_p, i32 0,<br>
> i32 2<br>
><br>
> store i8* %62, i8** %65<br>
><br>
> ret void<br>
><br>
> ; <label>:66 ; preds = %26, %17<br>
><br>
> store %"struct.sprite::compiler::node"* %root_p,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> %67 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %68 = getelementptr %"struct.sprite::compiler::node"* %67, i32 0, i32 2<br>
><br>
> %69 = load i8** %68<br>
><br>
> %70 = bitcast i8* %69 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %70,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> br label %76<br>
><br>
> ; <label>:71 ; preds = %76<br>
><br>
> %72 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %73 = getelementptr %"struct.sprite::compiler::node"* %72, i32 0, i32 2<br>
><br>
> %74 = load i8** %73<br>
><br>
> %75 = bitcast i8* %74 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %75,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> br label %76, !sprite.implied !0<br>
><br>
> ; <label>:76 ; preds = %71, %66<br>
><br>
> %77 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %78 = getelementptr %"struct.sprite::compiler::node"* %77, i32 0, i32 1<br>
><br>
> %79 = load i64* %78<br>
><br>
> %80 = load i64* %78<br>
><br>
> %81 = icmp eq i64 %80, -3<br>
><br>
> br i1 %81, label %71, label %82<br>
><br>
> ; <label>:82 ; preds = %76<br>
><br>
> %83 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %84 = getelementptr %"struct.sprite::compiler::node"* %83, i32 0, i32 2<br>
><br>
> %85 = load i8** %84<br>
><br>
> %86 = bitcast i8* %85 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %86,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> br label %92<br>
><br>
> ; <label>:87 ; preds = %92<br>
><br>
> %88 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %89 = getelementptr %"struct.sprite::compiler::node"* %88, i32 0, i32 2<br>
><br>
> %90 = load i8** %89<br>
><br>
> %91 = bitcast i8* %90 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %91,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> br label %92, !sprite.implied !0<br>
><br>
> ; <label>:92 ; preds = %87, %82<br>
><br>
> %93 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %94 = getelementptr %"struct.sprite::compiler::node"* %93, i32 0, i32 1<br>
><br>
> %95 = load i64* %94<br>
><br>
> %96 = load i64* %94<br>
><br>
> %97 = icmp eq i64 %96, -3<br>
><br>
> br i1 %97, label %87, label %98<br>
><br>
> ; <label>:98 ; preds = %92<br>
><br>
> %99 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %100 = bitcast %"struct.sprite::compiler::node"* %99 to i8*<br>
><br>
> %101 = call i8* @malloc(i64 32)<br>
><br>
> %102 = bitcast i8* %101 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %root_p,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> %103 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %104 = getelementptr %"struct.sprite::compiler::node"* %103, i32 0, i32 2<br>
><br>
> %105 = load i8** %104<br>
><br>
> %106 = bitcast i8* %105 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %106,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> br label %112<br>
><br>
> ; <label>:107 ; preds = %112<br>
><br>
> %108 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %109 = getelementptr %"struct.sprite::compiler::node"* %108, i32 0, i32 2<br>
><br>
> %110 = load i8** %109<br>
><br>
> %111 = bitcast i8* %110 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %111,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> br label %112, !sprite.implied !0<br>
><br>
> ; <label>:112 ; preds = %107, %98<br>
><br>
> %113 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %114 = getelementptr %"struct.sprite::compiler::node"* %113, i32 0, i32 1<br>
><br>
> %115 = load i64* %114<br>
><br>
> %116 = load i64* %114<br>
><br>
> %117 = icmp eq i64 %116, -3<br>
><br>
> br i1 %117, label %107, label %118<br>
><br>
> ; <label>:118 ; preds = %112<br>
><br>
> %119 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %120 = getelementptr %"struct.sprite::compiler::node"* %119, i32 0, i32 3<br>
><br>
> %121 = load i8** %120<br>
><br>
> %122 = bitcast i8* %121 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %122,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> br label %128<br>
><br>
> ; <label>:123 ; preds = %128<br>
><br>
> %124 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %125 = getelementptr %"struct.sprite::compiler::node"* %124, i32 0, i32 2<br>
><br>
> %126 = load i8** %125<br>
><br>
> %127 = bitcast i8* %126 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %127,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> br label %128, !sprite.implied !0<br>
><br>
> ; <label>:128 ; preds = %123, %118<br>
><br>
> %129 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %130 = getelementptr %"struct.sprite::compiler::node"* %129, i32 0, i32 1<br>
><br>
> %131 = load i64* %130<br>
><br>
> %132 = load i64* %130<br>
><br>
> %133 = icmp eq i64 %132, -3<br>
><br>
> br i1 %133, label %123, label %134<br>
><br>
> ; <label>:134 ; preds = %128<br>
><br>
> %135 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %136 = bitcast %"struct.sprite::compiler::node"* %135 to i8*<br>
><br>
> store %"struct.sprite::compiler::node"* %root_p,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> %137 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %138 = getelementptr %"struct.sprite::compiler::node"* %137, i32 0, i32 3<br>
><br>
> %139 = load i8** %138<br>
><br>
> %140 = bitcast i8* %139 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %140,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> br label %146<br>
><br>
> ; <label>:141 ; preds = %146<br>
><br>
> %142 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %143 = getelementptr %"struct.sprite::compiler::node"* %142, i32 0, i32 2<br>
><br>
> %144 = load i8** %143<br>
><br>
> %145 = bitcast i8* %144 to %"struct.sprite::compiler::node"*<br>
><br>
> store %"struct.sprite::compiler::node"* %145,<br>
> %"struct.sprite::compiler::node"** %0<br>
><br>
> br label %146, !sprite.implied !0<br>
><br>
> ; <label>:146 ; preds = %141, %134<br>
><br>
> %147 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %148 = getelementptr %"struct.sprite::compiler::node"* %147, i32 0, i32 1<br>
><br>
> %149 = load i64* %148<br>
><br>
> %150 = load i64* %148<br>
><br>
> %151 = icmp eq i64 %150, -3<br>
><br>
> br i1 %151, label %141, label %152<br>
><br>
> ; <label>:152 ; preds = %146<br>
><br>
> %153 = load %"struct.sprite::compiler::node"** %0<br>
><br>
> %154 = bitcast %"struct.sprite::compiler::node"* %153 to i8*<br>
><br>
> %155 = getelementptr %"struct.sprite::compiler::node"* %102, i32 0, i32 0<br>
><br>
> store %"struct.sprite::compiler::vtable"* @.vtable.for.myappend,<br>
> %"struct.sprite::compiler::vtable"** %155<br>
><br>
> %156 = getelementptr %"struct.sprite::compiler::node"* %102, i32 0, i32 1<br>
><br>
> store i64 -1, i64* %156<br>
><br>
> %157 = getelementptr %"struct.sprite::compiler::node"* %102, i32 0, i32 2<br>
><br>
> store i8* %136, i8** %157<br>
><br>
> %158 = getelementptr %"struct.sprite::compiler::node"* %102, i32 0, i32 3<br>
><br>
> store i8* %154, i8** %158<br>
><br>
> %159 = getelementptr %"struct.sprite::compiler::node"* %root_p, i32<br>
> 0, i32 0<br>
><br>
> store %"struct.sprite::compiler::vtable"* @.vt.CTOR.MyCons,<br>
> %"struct.sprite::compiler::vtable"** %159<br>
><br>
> %160 = getelementptr %"struct.sprite::compiler::node"* %root_p, i32<br>
> 0, i32 1<br>
><br>
> store i64 1, i64* %160<br>
><br>
> %161 = getelementptr %"struct.sprite::compiler::node"* %root_p, i32<br>
> 0, i32 2<br>
><br>
> store i8* %100, i8** %161<br>
><br>
> %162 = getelementptr %"struct.sprite::compiler::node"* %root_p, i32<br>
> 0, i32 3<br>
><br>
> store i8* %101, i8** %162<br>
><br>
> ret void<br>
><br>
> }<br>
><br>
><br>
><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>