From: Lang Hames Date: Thu, 26 May 2016 19:44:33 +0000 (+0000) Subject: [Kaleidoscope][BuildingAJIT] Fix a bug in the symbol resolver in Chapter2. X-Git-Tag: android-x86-7.1-r4~32764 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=67faeedf4795d6532dbbfc9e8b978962617573cb;p=android-x86%2Fexternal-llvm.git [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270899 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h index 6ea559bec0a..754c382a1df 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h @@ -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); },