<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’m attempting to port some code which uses the GlobalMappingLayer in the Orc JIT. This code worked fine in LLVM 4, but I’m getting a compile error with LLVM 5. I think the problem is that this layer hasn’t been modified to account for
some of the changes made in LLVM 5, but I wanted to make sure that I wasn’t missing something.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I have code which looks like this:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> ModuleHandle addModule(std::unique_ptr<Module> M) {<o:p></o:p></p>
<p class="MsoNormal"> // Build our symbol resolver:<o:p></o:p></p>
<p class="MsoNormal"> // Lambda 1: Look back into the JIT itself to find symbols that are part of<o:p></o:p></p>
<p class="MsoNormal"> // the same "logical dylib".<o:p></o:p></p>
<p class="MsoNormal"> // Lambda 2: Search for external symbols in the host process.<o:p></o:p></p>
<p class="MsoNormal"> auto Resolver = createLambdaResolver(<o:p></o:p></p>
<p class="MsoNormal"> [&](const std::string &Name) {<o:p></o:p></p>
<p class="MsoNormal"> if (auto Sym = OptimizeLayer.findSymbol(Name, false))<o:p></o:p></p>
<p class="MsoNormal"> return Sym;<o:p></o:p></p>
<p class="MsoNormal"> return JITSymbol(nullptr);<o:p></o:p></p>
<p class="MsoNormal"> },<o:p></o:p></p>
<p class="MsoNormal"> [](const std::string &Name) {<o:p></o:p></p>
<p class="MsoNormal"> if (auto SymAddr =<o:p></o:p></p>
<p class="MsoNormal"> RTDyldMemoryManager::getSymbolAddressInProcess(Name))<o:p></o:p></p>
<p class="MsoNormal"> return JITSymbol(SymAddr, JITSymbolFlags::Exported);<o:p></o:p></p>
<p class="MsoNormal"> return JITSymbol(nullptr);<o:p></o:p></p>
<p class="MsoNormal"> });<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> // Add the set to the JIT with the resolver we created above and a newly<o:p></o:p></p>
<p class="MsoNormal"> // created SectionMemoryManager.<o:p></o:p></p>
<p class="MsoNormal"> return OptimizeLayer.addModule(std::move(M),<o:p></o:p></p>
<p class="MsoNormal"> std::move(Resolver));<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Where OptimizeLayer is:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> IRTransformLayer<GlobalMappingLayerT, OptimizeFunction> OptimizeLayer;<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This worked fine with LLVM 4, but causes a problem in LLVM 5. It looks like the issue is that IRTransformLayer::addModule returns an Expected<ModuleT>, whereas GlobalMappingLayer returns just a ModuleHandleT. However, in LLVM 4, IRTransformLayer::addModuleSet
returned a ModuleSetT and GlobalMappingLayer::addModuleSet also returned a ModuleSetHandleT, so the types matched up. In LLVM 5, the CompileOnDemandLayer was changed to return an Expected<ModuleHandleT>, but not GlobalMappingLayer.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Does that explanation seem correct, or am I missing something?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thx,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">-brian<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>