<div dir="ltr"><div><div><div><div>Made it a bit further. Here's the current code:<br><br>void llvm_load_IR_library(char *path)<br>{<br>        char *error;<br>        LLVMExecutionEngineRef engine;<br>        object0_t* (*func)(void), *output;<br>        LLVMContextRef global_context;<br>        LLVMMemoryBufferRef module;<br>        LLVMModuleRef ir_lib_module;<br>        bool flag;<br><br>        printf("loading IR library from path: %s\n", path);<br><br>        LLVMCreateMemoryBufferWithContentsOfFile(path, &module, &error);<br><br>        global_context = LLVMGetGlobalContext();<br><br>        flag = LLVMGetBitcodeModuleInContext2(global_context, module, &ir_lib_module);<br><br>        printf("LLVMGetBitcodeModuleInContext2() returned %d\n", flag);<br>        <br>        LLVMVerifyModule(ir_lib_module, LLVMAbortProcessAction, &error);<br>        LLVMDumpModule(ir_lib_module);<br><br>        if (LLVMCreateExecutionEngineForModule(&engine, ir_lib_module, &error) != 0) {<br>                fprintf(stderr, "failed to create execution engine\n");<br>                abort();<br>        }<br><br>        // Call the function<br>        func = (object0_t * (*)(void))LLVMGetFunctionAddress(engine, "test");<br>        output = (*func)();<br>}<br><br></div>when this code is executed, i see:<br><br>...<br>LLVMGetBitcodeModuleInContext2() returned 0<br>; ModuleID = '/home/toshi/tensyr/debug_build/test.bc'<br>source_filename = "test.c"<br>target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"<br>target triple = "x86_64-unknown-linux-gnu"<br><br>@str = private unnamed_addr constant [16 x i8] c"test successful\00"<br><br>; Materializable<br>; Function Attrs: nounwind uwtable<br>define void @test() local_unnamed_addr #0 {}<br><br>; Function Attrs: nounwind<br>declare i32 @puts(i8* nocapture readonly) #1<br><br>attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>attributes #1 = { nounwind }<br><br>!llvm.ident = !{!0}<br><br>!0 = !{!"clang version 3.9.1 (tags/RELEASE_391/final)"}<br>failed to create execution engine<br>Aborted (core dumped)<br><br></div>Not sure why LLVMCreateExecutionEngineForModule is failing.<br></div>Any help appreciated.<br><br></div>Toshi<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 8, 2017 at 3:56 PM, Toshiyasu Morita <span dir="ltr"><<a href="mailto:toshi@tensyr.com" target="_blank">toshi@tensyr.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class=""><span class="m_-9171418793383708215gmail-im"><blockquote type="cite"><div dir="ltr"><div>Or do you mean I need to load the module into memory before
          calling LLVMGetBitcodeModuleInContext2<wbr>?<br>
        </div>
      </div>
    </blockquote>
    <br></span>
    > Yes, you need to load the module into memory first.<br>> LLVMCreateMemoryBufferWithCont<wbr>entsOfFile will do that for you.</span><div class="m_-9171418793383708215gmail-yj6qo m_-9171418793383708215gmail-ajU"><div id="m_-9171418793383708215gmail-:z5" class="m_-9171418793383708215gmail-ajR"><img class="m_-9171418793383708215gmail-ajT" src="https://ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif"><br></div><div id="m_-9171418793383708215gmail-:z5" class="m_-9171418793383708215gmail-ajR">Thanks!<br><br></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 8, 2017 at 3:48 PM, Friedman, Eli <span dir="ltr"><<a href="mailto:efriedma@codeaurora.org" target="_blank">efriedma@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><span>
    <div class="m_-9171418793383708215m_3832703634050351426moz-cite-prefix">On 3/8/2017 3:44 PM, Toshiyasu Morita
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div><span class="m_-9171418793383708215m_3832703634050351426gmail-im">
                  <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
                            module_path = LLVMCreateMemoryBufferWithMemo<wbr>ryRange(path,
                    strlen(path), "path", 1);<br>
                  </blockquote>
                  <br>
                </span>
                LLVMCreateMemoryBufferWithCont<wbr>entsOfFile takes a
                path.<br>
              </div>
              <br>
            </div>
            Erm...no...the code is calling
            LLVMCreateMemoryBufferWithMemo<wbr>ryRange, not
            LLVMCreateMemoryBufferWithCont<wbr>entsOfFile...<br>
            <br>
          </div>
          Or do you mean I need to load the module into memory before
          calling LLVMGetBitcodeModuleInContext2<wbr>?<br>
        </div>
      </div>
    </blockquote>
    <br></span>
    Yes, you need to load the module into memory first. 
    LLVMCreateMemoryBufferWithCont<wbr>entsOfFile will do that for you.<span><br>
    <br>
    -Eli<br>
    <pre class="m_-9171418793383708215m_3832703634050351426moz-signature" cols="72">-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</pre>
  </span></div>

</blockquote></div><br></div>
</div></div></blockquote></div><br></div>