<div dir="ltr">I am performing the bit analysis, so actually I want to propagate 
information about bits from operands to the instruction (the result of 
instruction), and every time I access the Instruction first , than get 
the operands, then access to the next instruction. <br>That was the only
 problem, that I keep a map from Instruction to bit info and was 
confused, is Instruction, that I am putting to map, is the same object 
as the Value, that will be used later, <br>as here <span class="gmail-im"><span style="color:rgb(33,33,33);font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont;font-size:15px">%a = alloca i32, align 4 ...%b= mul %a, 2. Now seems to be, that yes.</span></span></div><div class="gmail_extra"><br><div class="gmail_quote">2017-07-20 16:43 GMT+02:00 Evgeny Astigeevich <span dir="ltr"><<a href="mailto:Evgeny.Astigeevich@arm.com" target="_blank">Evgeny.Astigeevich@arm.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div>

<div id="m_5617805080601563213divtagdefaultwrapper" style="font-size:11pt;color:#000000;font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p>You think in terms of the textual representation of IR and are trying to work on IR in these terms.</p>
<p>See:</p>
<p><a href="http://www.llvm.org/docs/ProgrammersManual.html#coreclasses" class="m_5617805080601563213OWAAutoLink" target="_blank">http://www.llvm.org/docs/<wbr>ProgrammersManual.html#<wbr>coreclasses</a></p>
<p><a href="http://llvm.org/doxygen/classllvm_1_1Value.html" class="m_5617805080601563213OWAAutoLink" target="_blank">http://llvm.org/doxygen/<wbr>classllvm_1_1Value.html</a><br>
</p>
<p><br>
</p>
<p>In the LLVM representation Value is a thing which can be used as an operand to instructions.
<span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:14.6667px">
In</span><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:14.6667px"> API there is no such thing as the named </span><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:14.6667px">right
 part. </span>An instruction itself is a value which is produced as result of execution of the instruction. Look at the example:</p>
<p><br>
</p>
<p>Instr 1:  add i32 1, 2</p>
<p> </p>
<p>Instr 2:  add  i32 <result of Instr1>, 10</p>
<p><br>
</p>
<p>We have a def-use connection between Instr 2 and Instr 1. We don't need names. We can traverse def-use connection in this way (<a href="http://www.llvm.org/docs/ProgrammersManual.html#helpful-hints-for-common-operations" class="m_5617805080601563213OWAAutoLink" target="_blank">http://www.llvm.org/docs/<wbr>ProgrammersManual.html#<wbr>helpful-hints-for-common-<wbr>operations</a>):</p>
<p><br>
</p>
<p></p>
<pre style="overflow-x:auto;overflow-y:hidden;font-family:Consolas,"Deja Vu Sans Mono","Bitstream Vera Sans Mono",monospace;font-size:0.95em;line-height:15.96px;padding:0.5em;border:1px solid rgb(204,204,204);background-color:rgb(248,248,248)"><span class="m_5617805080601563213n">Instruction</span> <span class="m_5617805080601563213o" style="color:rgb(102,102,102)">*</span><span class="m_5617805080601563213n">pi</span> <span class="m_5617805080601563213o" style="color:rgb(102,102,102)">=</span> <span class="m_5617805080601563213p">...;</span>

<span class="m_5617805080601563213k" style="color:rgb(0,112,32);font-weight:bold">for</span> <span class="m_5617805080601563213p">(</span><span class="m_5617805080601563213n">Use</span> <span class="m_5617805080601563213o" style="color:rgb(102,102,102)">&</span><span class="m_5617805080601563213nl" style="color:rgb(0,32,112);font-weight:bold">U</span> <span class="m_5617805080601563213p">:</span> <span class="m_5617805080601563213n">pi</span><span class="m_5617805080601563213o" style="color:rgb(102,102,102)">-></span><span class="m_5617805080601563213n">operands</span><span class="m_5617805080601563213p">())</span> <span class="m_5617805080601563213p">{</span>
  <span class="m_5617805080601563213n">Value</span> <span class="m_5617805080601563213o" style="color:rgb(102,102,102)">*</span><span class="m_5617805080601563213n">v</span> <span class="m_5617805080601563213o" style="color:rgb(102,102,102)">=</span> <span class="m_5617805080601563213n">U</span><span class="m_5617805080601563213p">.</span><span class="m_5617805080601563213n">get</span><span class="m_5617805080601563213p">();</span>
  <span class="m_5617805080601563213c1" style="color:rgb(96,160,176);font-style:italic">// ...</span>
<span class="m_5617805080601563213p">}</span></pre>
<br>
<p></p>
<p><span style="font-size:11pt">Your case:</span><br>
</p><span class="">
<p><br>
</p>
<p><span style="color:rgb(33,33,33);font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont;font-size:15px">> %a = alloca i32, align 4 - %a here </span></p>
<p><span style="color:rgb(33,33,33);font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont;font-size:15px">>, but I don't quite understand the difference between Instruction object and Value object of a,
 which is used further , and in this case :</span><br style="color:rgb(33,33,33);font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont;font-size:15px">
<span style="color:rgb(33,33,33);font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont;font-size:15px"><br>
</span></p>
</span><p><span style="color:rgb(33,33,33);font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont;font-size:15px"><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:14.6667px">Instr1: </span><span style="color:rgb(33,33,33);font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont;font-size:15px">alloca
 i32, align 4 </span><br>
</span></p>
<p><span style="color:rgb(33,33,33);font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont;font-size:15px">If there are users of Instr1 then can access them calling user_begin() on Instr1. You can access
 Instr1 from users as in the example above. Of course you need to keep the pointer to Instr1 somewhere to check that it's used.</span></p><span class="">
<p><span style="color:rgb(33,33,33);font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont;font-size:15px"><br>
</span></p>
<p><span style="color:rgb(33,33,33);font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont;font-size:15px">> %1 = alloca i32, align 4 - I also wanted to use %1 and in this case the only possibility is Instruction
 object.</span><br>
</p>
<p><br>
</p>
</span><p>You traverse basic blocks and process the instructions. Processing can include any type of actions: analysis, optimization etc.</p>
<p>So what is your use case?</p>
<p><br>
</p>
<p>-Evgeny</p>
<p></p>
</div>
<hr style="display:inline-block;width:98%">
<div id="m_5617805080601563213divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Anastasiya Ruzhanskaya <<a href="mailto:anastasiya.ruzhanskaya@frtk.ru" target="_blank">anastasiya.ruzhanskaya@frtk.<wbr>ru</a>><br>
<b>Sent:</b> Thursday, July 20, 2017 3:02:26 PM<br>
<b>To:</b> Evgeny Astigeevich<br>
<b>Cc:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>; nd<br>
<b>Subject:</b> Re: [llvm-dev] Value</font>
<div> </div>
</div><div><div class="h5">
<div>
<div dir="ltr">Thank you! I wanted to use the right part of the instruction ,<br>
 %a = alloca i32, align 4 - %a here , but I don't quite understand the difference between Instruction object and Value object of a, which is used further , and in this case :<br>
%1 = alloca i32, align 4 - I also wanted to use %1 and in this case the only possibility is Instruction object.<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2017-07-20 15:32 GMT+02:00 Evgeny Astigeevich <span dir="ltr">
<<a href="mailto:Evgeny.Astigeevich@arm.com" target="_blank">Evgeny.Astigeevich@arm.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div id="m_5617805080601563213m_7856916512580753053divtagdefaultwrapper" style="font-size:11pt;color:#000000;font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p>Hi Anastasiya,</p>
<p><br>
</p>
<p>What do you mean 'identifiable'? You have Module, Function, BasicBlock etc. You can access Values and Users. They form a data-flow graph. You can store pointers to Values and Users if you wish. If you want a name for any Value there is ValueSymbolTable (<a href="http://www.llvm.org/docs/ProgrammersManual.html#advanced-topics" class="m_5617805080601563213m_7856916512580753053OWAAutoLink" target="_blank">http://www.llvm.org/docs/Prog<wbr>rammersManual.html#advanced-<wbr>topics</a>)
 which provides <span>a symbol table that the Function and Module classes use for naming value definitions. You should take into account that some Values might not have names and passes can change names of Values.</span></p>
<p><span><br>
</span></p>
<p><span>Thanks,</span></p>
<p><span>Evgeny Astigevich</span></p>
</div>
<hr style="display:inline-block;width:98%">
<div id="m_5617805080601563213m_7856916512580753053divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.o<wbr>rg</a>>
 on behalf of Anastasiya Ruzhanskaya via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Sent:</b> Thursday, July 20, 2017 2:21:44 PM<br>
<b>To:</b> LLVM Developers Mailing List<br>
<b>Subject:</b> [llvm-dev] Value</font>
<div> </div>
</div>
<span>
<div>
<div dir="ltr">
<div>Hello,<br>
</div>
I am trying to write my own pass for some purposes, and found out that there is no way to work with such variables as %1 and so on. How they are identifiable? Only by the Value object, without any possibility for visual representation as for example %a, %b
 values?</div>
</div>
</span></div>
</blockquote>
</div>
<br>
</div>
</div>
</div></div></div>

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