<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=iso-8859-1">
<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:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
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;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
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="DE" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-GB">Hey everyone,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">I felt this question is different from my other question - hope this is okay.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">So - I was playing around with the lookup function of the ExecutionSession and there are some things I don't understand.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">I have a .BC file with a function "?Sampler@@YAXXZ" referencing a value "?_Plansch_test@@3HA" that is not defined in that module itself. I first planed on not providing an address for "?_Plansch_test@@3HA" but wanted
 to know the address of "?Sampler@@YAXXZ". So I issued something like that:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">                auto &ES = this->jit->getExecutionSession();<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">                SymbolLookupSet lookupSet;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">                <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">                lookupSet.add("?Sampler@@YAXXZ", llvm::orc::SymbolLookupFlags::WeaklyReferencedSymbol);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">                ES.lookup({{&jit->getMainJITDylib(), llvm::orc::JITDylibLookupFlags::MatchAllSymbols}}, lookupSet, llvm::orc::LookupKind::Static, llvm::orc::SymbolState::Resolved);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">                <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Even though the "tryToGenerate" function of my DefinitionGenerator returned a "llvm::orc::SymbolsNotFound" for the "?_Plansch_test@@3HA", I got an address for "?Sampler@@YAXXZ". Dumping the "MainJITDylib" I saw, that
 the "?Sampler@@YAXXZ" was in an Error state. Which made sense - I guess.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Question 1.)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Is there any way to reset the error state of "?Sampler@@YAXXZ" at this point?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">- After my first call I used the "define" function of the JITDylib to define ?_Plansch_test@@3HA and then I tried calling the lookup function again and again, however I only got the error: "Failed to materialize symbols"
 even though "?_Plansch_test@@3HA" was defined now...<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">- Changing the order of the "define" and the "lookup" call works of course, but I'm interested in the case where I don't know the address yet.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Out of curiosity I repeated the previous scenario - but added "?_Plansch_test@@3HA" to the "lookupSet" which changed things drasticly. When executing "lookup" I now get the "llvm::orc::SymbolsNotFound" error from my DefinitionGenerator
 and "?Sampler@@YAXXZ" is stuck as a pending query in the MaterializingInfos entries. When I then add a definition for "?_Plansch_test@@3HA" and call "lookup" the second time, it will succeed and give me the addresses. Also I'm able to execute the code now.
 This is great! However...<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Question 2.)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Why did the first call to lookup not return the address of "?Sampler@@YAXXZ" like in the first scenario? I expected it would return an address for it.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Question 3.)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Can I somehow combine both behaviours? Getting the address for all the symbols (like in scenario 1) while still being able to provide definitions later (like in scenario 2)?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Thank you in advance and kind greetings,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Björn<o:p></o:p></span></p>
</div>
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
</body>
</html>