<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi Lang!</p>
    <p>Yes, I was able to boil it down to a minimal test case.</p>
    <p>The test case uses the KaleidoscopeJIT.h that ships with LLVM 8
      (except <br>
      that I had to expose the Datalayout). It reads from the filesystem
      an IR <br>
      file (filename "func_works.ll" or "func_cos_fails.ll) and asks the
      ORC <br>
      JIT first for the symbol "func_ir" and then for the address.<br>
      <br>
      In case the file "func_works.ll" was read the program succeeds
      with:<br>
      <br>
      symbol found!<br>
      address found!<br>
      <br>
      In case the file "func_cos_fails.ll" was read the program fails
      with:<br>
      <br>
      symbol found!<br>
      Failure value returned from cantFail wrapped call<br>
      UNREACHABLE executed at <br>
      install/llvm-8.0-x86-debug/include/llvm/Support/Error.h:732!<br>
      Stack dump:<br>
      <br>
      This was tested on an x86 Linux Ubuntu system.</p>
    <p>LLVM was configured with<br>
    </p>
    <p>cmake -G "Unix Makefiles" \<br>
      Â Â Â Â Â  -DBUILD_SHARED_LIBS="ON" \<br>
      Â Â Â Â Â  -DLLVM_ENABLE_RTTI="ON" \<br>
      Â Â Â Â Â  -DLLVM_ENABLE_ZLIB="OFF" \<br>
      Â Â Â Â Â  -DLLVM_ENABLE_TERMINFO="OFF" \<br>
      Â Â Â Â Â  -DCMAKE_BUILD_TYPE="Debug" \<br>
      Â Â Â Â Â  -DCMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX \<br>
      Â Â Â Â Â  -DLLVM_TARGETS_TO_BUILD="X86" \<br>
      Â Â Â Â Â  $SRC<br>
    </p>
    <p><br>
    </p>
    <p>I hope that makes it easier to see what's going on.<br>
    </p>
    <br>
    <p>Best,<br>
      Frank<br>
      <br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 3/29/19 5:37 PM, Lang Hames wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CALLttgob6KJbrP2gO4=15Pj0dKZqfkSkgzHBNx9WCz8z43QfXA@mail.gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr">Hi Frank,
          <div><br>
          </div>
          <div>That error message/location indicates that the JIT was
            able to "find" the 'cosf' symbol, but not able to get an
            address for it. That kind of result is usually restricted to
            JIT'd code: when the JIT find's a not-yet-compiled
            definition, tries to compile it to get a final address, and
            fails. It sounds like you are using a libm function though,
            and I would expect that to either not be found at all, or to
            be found and trivially have an address.<br>
          </div>
          <div><br>
          </div>
          <div>Are you able to provide some more context? Is the code
            line you shared from LLVM, or your own ORC-based JIT? Do you
            have a test case that you can share?</div>
          <div><br>
          </div>
          <div>Cheers,</div>
          <div>Lang.</div>
          <div> </div>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Fri, Mar 22, 2019 at 1:43
          PM Frank Winter via llvm-dev <<a
            href="mailto:llvm-dev@lists.llvm.org" moz-do-not-send="true">llvm-dev@lists.llvm.org</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Hi,<br>
          <br>
          for my application (uses Builder and MCJIT) I am making the
          transition <br>
          LLVM 6.0 -> 8.0.<br>
          <br>
          It runs fine for self-contained functions, but whenever a
          jit-ed <br>
          function contains calls to the math library (e.g. @cosf) it
          seems to <br>
          have problems getting the address after successfully finding
          the symbol:<br>
          <br>
          Failure value returned from cantFail wrapped call<br>
          UNREACHABLE executed at <br>
~/toolchain/install/llvm-8.0-x86-debug/include/llvm/Support/Error.h:732!<br>
          <br>
          if (auto Sym =
          CompileLayer.findSymbol(MangledNameStream.str(),true))<br>
          Â Â Â Â  {<br>
          Â Â Â Â  Â  void* fptr = (void *)cantFail(Sym.getAddress());<br>
          <br>
          The last statement fails with the above message.<br>
          <br>
          <br>
          Has anything related to using MCJIT with math library
          functions changed <br>
          since LLVM 6.0?<br>
          <br>
          <br>
          Best,<br>
          <br>
          Frank<br>
          <br>
          <br>
          <br>
          <br>
          _______________________________________________<br>
          LLVM Developers mailing list<br>
          <a href="mailto:llvm-dev@lists.llvm.org" target="_blank"
            moz-do-not-send="true">llvm-dev@lists.llvm.org</a><br>
          <a
href="https://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev&data=02%7C01%7Cfwinter%40jlab.org%7Ca89da3e7b6744855dc1308d6b48eb52f%7Cb4d7ee1f4fb34f0690372b5b522042ab%7C1%7C1%7C636894922351400719&sdata=IX3IZBCWPU0xIN44ODXU9jFonCRTDeRpGARZt0fJVBU%3D&reserved=0"
originalsrc="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
shash="x1ZW56jJcUh9tG2pSAgrmAOOMi7Z7exig+eHXwSHUyHxiyEehTVqKrNo6p4Bd9vhipltdxIhWA1AFwNM1NCYky9mLQyU7MT5BQZsGCSu9zZ61aqvobqvoVixvNh/nEfbqmCSMIOYi8WejBMkOm7a9rRleIRc/dke9EDZjO6LqZY="
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
        </blockquote>
      </div>
    </blockquote>
  </body>
</html>