[llvm-dev] Kaleidoscope on Windows - bug maybe found?

Russell Wallace via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 31 18:42:30 PDT 2016


To try to find out why it was crashing, I followed the trail of function
calls:

C:\llvm\examples\Kaleidoscope\Orc\initial\toy.cpp

      auto ExprSymbol = J.findUnmangledSymbol("__anon_expr");

  JITSymbol findUnmangledSymbol(const std::string Name) {
    return findSymbol(mangle(Name));
  }

  JITSymbol findSymbol(const std::string &Name) {
    return CompileLayer.findSymbol(Name, true);
  }

  CompileLayerT CompileLayer;
  typedef IRCompileLayer<ObjLayerT> CompileLayerT;

C:\llvm\include\llvm\ExecutionEngine\Orc\IRCompileLayer.h

template <typename BaseLayerT> class IRCompileLayer {

  JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) {
    return BaseLayer.findSymbol(Name, ExportedSymbolsOnly);
  }

C:\llvm\examples\Kaleidoscope\Orc\initial\toy.cpp

  typedef ObjectLinkingLayer<> ObjLayerT;

C:\llvm\include\llvm\ExecutionEngine\Orc\ObjectLinkingLayer.h

  JITSymbol findSymbol(StringRef Name, bool ExportedSymbolsOnly) {
    for (auto I = LinkedObjSetList.begin(), E = LinkedObjSetList.end(); I
!= E;
         ++I)
      if (auto Symbol = findSymbolIn(I, Name, ExportedSymbolsOnly))
        return Symbol;

  JITSymbol findSymbolIn(ObjSetHandleT H, StringRef Name,
                         bool ExportedSymbolsOnly) {
    if (auto Sym = (*H)->getSymbol(Name)) {
C:\llvm\examples\Kaleidoscope\Orc\initial\toy.cpp

      auto ExprSymbol = J.findUnmangledSymbol("__anon_expr");

  JITSymbol findUnmangledSymbol(const std::string Name) {
    return findSymbol(mangle(Name));
  }

  JITSymbol findSymbol(const std::string &Name) {
    return CompileLayer.findSymbol(Name, true);
  }

  CompileLayerT CompileLayer;
  typedef IRCompileLayer<ObjLayerT> CompileLayerT;

C:\llvm\include\llvm\ExecutionEngine\Orc\IRCompileLayer.h

template <typename BaseLayerT> class IRCompileLayer {

  JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) {
    return BaseLayer.findSymbol(Name, ExportedSymbolsOnly);
  }

C:\llvm\examples\Kaleidoscope\Orc\initial\toy.cpp

  typedef ObjectLinkingLayer<> ObjLayerT;

C:\llvm\include\llvm\ExecutionEngine\Orc\ObjectLinkingLayer.h

  JITSymbol findSymbol(StringRef Name, bool ExportedSymbolsOnly) {
    for (auto I = LinkedObjSetList.begin(), E = LinkedObjSetList.end(); I
!= E;
         ++I)
      if (auto Symbol = findSymbolIn(I, Name, ExportedSymbolsOnly))
        return Symbol;

  JITSymbol findSymbolIn(ObjSetHandleT H, StringRef Name,
                         bool ExportedSymbolsOnly) {
    if (auto Sym = (*H)->getSymbol(Name)) {
      if (Sym.isExported() || !ExportedSymbolsOnly) {

and after putting in some debugging code, it turns out this is it - the
client wants exported symbols only, but the expression is not exported.
This is the easiest change to fix the problem:

  JITSymbol findSymbol(const std::string &Name) {
    return CompileLayer.findSymbol(Name, false);
  }

 but is it the right one? Or should the symbol be exported instead?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160401/a262de7e/attachment.html>


More information about the llvm-dev mailing list