<div dir="ltr"><div dir="ltr"><div>I don't think it's the same problem as you described. By printing I meant calling printf function and passing my global variable as one of the arguments.<br></div><div><br></div><div>My code:</div><div><br></div><div>
Instruction* InstructionVisitor::incrementGlobalKey(Instruction* I) {<br><div style="margin-left:40px">   IRBuilder<> Builder(I->getContext());<br>        Builder.SetInsertPoint(I->getNextNode());<br><br>        GlobalVariable* key = I->getModule()->getNamedGlobal("globalKey");<br><br>  if (key) {<br></div><div style="margin-left:40px"><div style="margin-left:40px">            LoadInst* load = Builder.CreateLoad(key);<br>             Value* inc = Builder.CreateAdd(load, Builder.getInt64(1));<br>            StoreInst* store = Builder.CreateStore(inc, key);<br>             return store;<br></div></div><div style="margin-left:40px">   }<br>     return I;<br></div>} <br></div><div><br></div><div>Instruction* InstructionVisitor::print(Instruction* I, const char* text, Value* arg1, Value* arg2, Value* arg3, Value* arg4) {<br><div style="margin-left:40px">       Function* printfFn = I->getModule()->getFunction("printf");<br>   if (printfFn) {<br></div><div style="margin-left:40px"><div style="margin-left:40px">               IRBuilder<> Builder(I->getContext());<br>                Builder.SetInsertPoint(I->getNextNode());<br>          Value* convertedText = Builder.CreateGlobalStringPtr(text);<br><br>         std::vector <Value *> params;<br>           params.push_back(convertedText);<br>              if (arg1)<br></div></div><div style="margin-left:40px"><div style="margin-left:40px"><div style="margin-left:40px">                   params.push_back(arg1);<br></div></div></div><div style="margin-left:40px"><div style="margin-left:40px">               if (arg2)<br></div></div><div style="margin-left:40px"><div style="margin-left:40px"><div style="margin-left:40px">                   params.push_back(arg2);<br></div></div></div><div style="margin-left:40px"><div style="margin-left:40px">               if (arg3)<br></div></div><div style="margin-left:40px"><div style="margin-left:40px"><div style="margin-left:40px">                   params.push_back(arg3);<br></div></div></div><div style="margin-left:40px"><div style="margin-left:40px">               if (arg4)<br></div></div><div style="margin-left:40px"><div style="margin-left:40px"><div style="margin-left:40px">                   params.push_back(arg4);<br></div></div></div><div style="margin-left:40px"><div style="margin-left:40px"><br>             return Builder.CreateCall(printfFn, params);<br></div></div><div style="margin-left:40px">    }<br>     return I;<br></div>}</div><div><br></div><div>void InstructionVisitor::visitCallInst(CallInst &CI) {<br><div style="margin-left:40px">      if (isAllocationFn(&CI, &TLI)) {<br></div><div style="margin-left:40px"><div style="margin-left:40px">              Value* allocatedAddress = &CI;<br>            Instruction* I = &CI;<br>             Value* allocatedSize = I->getOperand(0);<br>           Instruction* next = incrementGlobalKey(I);<br>            GlobalVariable* key = I->getModule()->getNamedGlobal("globalKey");<br>            const char* message = "Allocated address: 0x%p, size: %d, key: %lld\n";<br>             print(next, message, allocatedAddress, allocatedSize, key->getOperand(0));<br></div></div><div style="margin-left:40px">   }<br></div>}</div><div><br></div><div>Code that I'm executing (source code) is:</div><div>int main()<br>{<br><div style="margin-left:40px">       char* buffer;<br> int size = 101;<br>       buffer = new char[size];<br>      printf("CHECK address: 0x%p, size: %d\n", buffer, size);<br>    TestClass* test = new TestClass(1, 2);<br>        printf("(CHECK address: 0x%p, size: %llu\n", test, sizeof(TestClass));<br><br>    delete buffer;<br>        delete test;</div>}</div><div><br></div><div>And program output after instrumentation:</div><div><br></div><div>Allocated address: 0x000001CD326C1B20, size: 101, key: 0<br>CHECK address: 0x000001CD326C1B20, size: 101<br>Allocated address: 0x000001CD326C1B90, size: 8, key: 0<br>CHECK address: 0x000001CD326C1B90, size: 8</div><div><br></div><div>Regards,</div><div>Emma Luciano<br></div><div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">śr., 3 cze 2020 o 11:21 Eli Friedman <<a href="mailto:efriedma@quicinc.com">efriedma@quicinc.com</a>> napisał(a):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div class="gmail-m_2076883137098454188WordSection1">
<p class="MsoNormal">Suppose I have the following program:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">$ cat test.c<u></u><u></u></p>
<p class="MsoNormal">int a = 0;<u></u><u></u></p>
<p class="MsoNormal">int main() { a = 1; };<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Then I compile and run it:<u></u><u></u></p>
<p class="MsoNormal">$ clang test.c<u></u><u></u></p>
<p class="MsoNormal">$ ./a.out<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Then I print the contents of test.c again:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">$ cat test.c<u></u><u></u></p>
<p class="MsoNormal">int a = 0;<u></u><u></u></p>
<p class="MsoNormal">int main() { a = 1; }<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Why does it say “int a = 0;”?  The program set it to 1, no?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">As far as I can tell, this is equivalent to your question… except it’s less obvious because the “source code” is an LLVM IR module in memory.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Maybe you’re looking for ExecutionSession::lookup?  The same way the tutorial computes the address of “main”, you can compute the runtime address of any other externally visible symbol.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">See also <a href="https://llvm.org/docs/ORCv2.html" target="_blank">https://llvm.org/docs/ORCv2.html</a> ,
<a href="https://www.youtube.com/watch?v=hILdR8XRvdQ" target="_blank">https://www.youtube.com/watch?v=hILdR8XRvdQ</a> .<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">-Eli<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-color:currentcolor currentcolor currentcolor blue;border-style:none none none solid;border-width:medium medium medium 1.5pt;padding:0in 0in 0in 4pt">
<div>
<div style="border-color:rgb(225,225,225) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>> <b>On Behalf Of
</b>Emma Luciano via llvm-dev<br>
<b>Sent:</b> Wednesday, June 3, 2020 1:35 AM<br>
<b>To:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> [EXT] [llvm-dev] Fwd: I cannot change value of global variable in LLVM IR using IRBuilder<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p style="margin-right:0in;margin-bottom:12pt;margin-left:0in;vertical-align:baseline">
<span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:rgb(36,39,41)">Hi Everyone,<u></u><u></u></span></p>
<p style="margin-right:0in;margin-bottom:12pt;margin-left:0in;vertical-align:baseline;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit">
<span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:rgb(36,39,41)">I'm quite new to LLVM and I want to update value of global variable in LLVM IR. I created new global variable in ModulePass:<u></u><u></u></span></p>
<pre style="vertical-align:baseline;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit;max-height:600px;border-radius:3px;overflow:auto"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">bool runOnModule(llvm::</span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Module</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in"> &M) {<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">IRBuilder</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in"><> </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Builder</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">(M.getContext());<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Instruction</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in"> *I = &*inst_begin(M.getFunction("main"));<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Builder</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">.</span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">SetInsertPoint</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">(I);<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    M.getOrInsertGlobal("globalKey", </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Builder</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">.getInt64Ty());<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">GlobalVariable</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">* gVar = M.getNamedGlobal("globalKey");<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    gVar->setLinkage(</span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">GlobalValue</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">::</span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">InternalLinkage</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">);<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    gVar->setAlignment(</span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Align</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">(8));<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    gVar->setInitializer(</span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Builder</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">.getInt64(0));<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    gVar->setConstant(false);<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in"><u></u> <u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    for (</span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Function</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in"> &F : M.functions()) {<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">        </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">InstructionVisitor</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in"> visitor(DL, getAnalysis<</span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">TargetLibraryInfoWrapperPass</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">>().getTLI(F));<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">        for (</span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Instruction</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in"> &I : instructions(F)) {<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">            visitor.visit(I);<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">        }<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    }<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    return true;<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">}</span></code><span style="font-family:Consolas;color:rgb(36,39,41)"><u></u><u></u></span></pre>
<p style="margin-right:0in;margin-bottom:12pt;margin-left:0in;vertical-align:baseline;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit">
<span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:rgb(36,39,41)">Later in InstructionVisitor I try to update it like that:<u></u><u></u></span></p>
<pre style="vertical-align:baseline;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit;max-height:600px;border-radius:3px;overflow:auto"><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">IRBuilder</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in"><> </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Builder</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">(I->getContext());<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Builder</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">.</span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">SetInsertPoint</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">(I->getNextNode());<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in"><u></u> <u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">GlobalVariable</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">* key = I->getModule()->getNamedGlobal("globalKey");<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in"><u></u> <u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">if (key) {<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">LoadInst</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">* load = </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Builder</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">.</span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">CreateLoad</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">(key);<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Value</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">* inc = </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Builder</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">.</span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">CreateAdd</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">(load, </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Builder</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">.getInt64(1));<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">    </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">StoreInst</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">* store = </span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">Builder</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">.</span></code><code><span style="font-family:"inherit",serif;color:rgb(43,145,175);border:1pt none windowtext;padding:0in">CreateStore</span></code><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">(inc, key);<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">}</span></code><span style="font-family:Consolas;color:rgb(36,39,41)"><u></u><u></u></span></pre>
<p style="margin:0in 0in 0.0001pt;vertical-align:baseline;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit">
<span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:rgb(36,39,41)">I print that global variable during execution of instrumented code. I access it's value by key->getOperand(0), but it's unchanged. I'm using ORC JIT based on this tutorial: <a href="https://llvm.org/docs/tutorial/BuildingAJIT2.html" target="_blank"><span style="font-family:"inherit",serif;border:1pt none windowtext;padding:0in">https://llvm.org/docs/tutorial/BuildingAJIT2.html</span></a> and
 I run ModulePass from optimizeModule function from this tutorial.<u></u><u></u></span></p>
<p style="margin-right:0in;margin-bottom:12pt;margin-left:0in;vertical-align:baseline;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit">
<span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:rgb(36,39,41)">In IR it looks like that:<u></u><u></u></span></p>
<pre style="vertical-align:baseline;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit;max-height:600px;border-radius:3px;overflow:auto"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">  %2 = load i64, i64* @globalKey<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">  %3 = add i64 %2, 1<u></u><u></u></span></code></pre>
<pre style="vertical-align:baseline"><code><span style="font-family:"inherit",serif;color:rgb(36,39,41);border:1pt none windowtext;padding:0in">  store i64 %3, i64* @globalKey</span></code><span style="font-family:Consolas;color:rgb(36,39,41)"><u></u><u></u></span></pre>
<p style="margin-right:0in;margin-bottom:12pt;margin-left:0in;vertical-align:baseline;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit">
<span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:rgb(36,39,41)">I tried updating value of global variable, which was present in source code that I'm instrumenting. It didn't work either.<u></u><u></u></span></p>
<p style="margin-right:0in;margin-bottom:12pt;margin-left:0in;vertical-align:baseline;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit">
<span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:rgb(36,39,41)">I created corresponding stackoverflow topic: <a href="https://stackoverflow.com/questions/62142574/how-can-i-update-global-variable-value-in-llvm-ir-using-irbuilder?fbclid=IwAR2X7uGhUjm_SN2UcxWYqaRQW2-cs6iPbMx2_tbKubeyYUkZ_pS6rkFfY9I" target="_blank"><span style="font-size:12pt">https://stackoverflow.com/questions/62142574/how-can-i-update-global-variable-value-in-llvm-ir-using-irbuilder?fbclid=IwAR2X7uGhUjm_SN2UcxWYqaRQW2-cs6iPbMx2_tbKubeyYUkZ_pS6rkFfY9I</span></a><u></u><u></u></span></p>
<p style="margin-right:0in;margin-bottom:12pt;margin-left:0in;vertical-align:baseline;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit">
<span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:rgb(36,39,41)">I will be really grateful for help.<u></u><u></u></span></p>
<p style="margin-right:0in;margin-bottom:12pt;margin-left:0in;vertical-align:baseline;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit">
<span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:rgb(36,39,41)">Regards,<u></u><u></u></span></p>
<p style="margin-right:0in;margin-bottom:12pt;margin-left:0in;vertical-align:baseline;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit">
<span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:rgb(36,39,41)">Emma Luciano<u></u><u></u></span></p>
</div>
</div>
</div>
</div>
</div>
</div>

</blockquote></div></div>