[llvm] r270899 - [Kaleidoscope][BuildingAJIT] Fix a bug in the symbol resolver in Chapter2.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Thu May 26 12:44:33 PDT 2016

Author: lhames
Date: Thu May 26 14:44:33 2016
New Revision: 270899

URL: http://llvm.org/viewvc/llvm-project?rev=270899&view=rev
[Kaleidoscope][BuildingAJIT] Fix a bug in the symbol resolver in Chapter2.

Symbol resolution should be done on the top layer of the stack unless there's a
good reason to do otherwise. In this case it would have worked because
OptimizeLayer::addModuleSet eagerly passes all modules down to the
CompileLayer, meaning that searches in CompileLayer will find the definitions.
In later chapters where the top layer's addModuleSet isn't a pass-through, this
would break.


Modified: llvm/trunk/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h?rev=270899&r1=270898&r2=270899&view=diff
--- llvm/trunk/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h (original)
+++ llvm/trunk/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h Thu May 26 14:44:33 2016
@@ -71,7 +71,7 @@ public:
     // Lambda 2: Search for external symbols in the host process.
     auto Resolver = createLambdaResolver(
         [&](const std::string &Name) {
-          if (auto Sym = CompileLayer.findSymbol(Name, false))
+          if (auto Sym = OptimizeLayer.findSymbol(Name, false))
             return RuntimeDyld::SymbolInfo(Sym.getAddress(), Sym.getFlags());
           return RuntimeDyld::SymbolInfo(nullptr);

More information about the llvm-commits mailing list