<div dir="ltr">Hello All,<div><br></div><div>I'm not able to extract f1 from a getelementptr inbounds Instruction.</div><div><span style="font-family:"Consolas, ";color:rgb(0,0,255)"><br></span></div><div><span style="font-family:"Consolas, ";color:rgb(0,0,255)">struct</span><span style="background-color:rgb(255,255,254);color:rgb(0,0,0);font-family:"Consolas, ""> </span><span style="background-color:rgb(255,255,254);color:rgb(0,0,0);font-family:"Consolas, "">foo {</span><br></div><div><div style="color:rgb(0,0,0);font-family:"Consolas, ""><div style="background-color:rgb(255,255,254)"><span style="color:rgb(0,0,255)">int</span> num;</div><div style="background-color:rgb(255,255,254)">}; </div><div style="background-color:rgb(255,255,254)"><span style="color:rgb(0,0,255)">extern</span> <span style="color:rgb(0,0,255)">struct</span> foo f1;</div><div style="background-color:rgb(255,255,254)"><span style="color:rgb(0,0,255)">void</span> hello () {</div><div><span style="background-color:rgb(255,255,254);color:rgb(0,0,255)">if</span><span style="background-color:rgb(255,255,254)"> (</span><span style="background-color:rgb(255,255,0)">f1</span><span style="background-color:rgb(255,255,254)">.num){</span></div><div style="background-color:rgb(255,255,254)">}</div><div style="background-color:rgb(255,255,254)">}</div></div></div><div><div style="font-family:"Consolas, ""><div><font color="#ff0000"><span style="background-color:rgb(255,255,0)">@f1</span><span style="background-color:rgb(255,255,254)"> = external dso_local global %struct.foo, align 4</span></font></div></div><div style="color:rgb(0,0,0);font-family:"Consolas, ""><div style="background-color:rgb(255,255,254)"><span style="color:rgb(0,0,255)">define</span> <span style="color:rgb(0,128,128)">dso_local</span> <span style="color:rgb(0,128,128)">void</span> <span style="color:rgb(0,128,128)">@hello</span>() <span style="color:rgb(9,134,88)">#0</span> !<span style="color:rgb(0,128,128)">dbg</span> !<span style="color:rgb(9,134,88)">9</span> {</div><div><span style="background-color:rgb(255,255,254);color:rgb(205,49,49)">%1</span> <span style="background-color:rgb(255,255,254);color:rgb(205,49,49)">=</span> <span style="background-color:rgb(255,255,254);color:rgb(0,0,255)">load</span> <span style="background-color:rgb(255,255,254);color:rgb(0,128,128)">i32</span><span style="background-color:rgb(255,255,254)">, </span><span style="background-color:rgb(255,255,254);color:rgb(0,128,128)">i32</span><span style="background-color:rgb(255,255,254)">* </span><span style="background-color:rgb(255,255,254);color:rgb(0,128,128)">getelementptr</span> <span style="background-color:rgb(255,255,254);color:rgb(0,128,128)">inbounds</span><span style="background-color:rgb(255,255,254)"> (</span><span style="background-color:rgb(255,255,254);color:rgb(0,128,128)">%struct.foo</span><span style="background-color:rgb(255,255,254)">, </span><span style="background-color:rgb(255,255,254);color:rgb(0,128,128)">%struct.foo</span><span style="background-color:rgb(255,255,254)">* </span><span style="color:rgb(0,128,128);background-color:rgb(255,255,0)"><b>@f1</b></span><span style="background-color:rgb(255,255,254)">, </span><span style="background-color:rgb(255,255,254);color:rgb(0,128,128)">i32</span> <span style="background-color:rgb(255,255,254);color:rgb(9,134,88)">0</span><span style="background-color:rgb(255,255,254)">, </span><span style="background-color:rgb(255,255,254);color:rgb(0,128,128)">i32</span> <span style="background-color:rgb(255,255,254);color:rgb(9,134,88)">0</span><span style="background-color:rgb(255,255,254)">), </span><span style="background-color:rgb(255,255,254);color:rgb(0,128,128)">align</span> <span style="background-color:rgb(255,255,254);color:rgb(9,134,88)">4</span><span style="background-color:rgb(255,255,254)">, !</span><span style="background-color:rgb(255,255,254);color:rgb(0,128,128)">dbg</span><span style="background-color:rgb(255,255,254)"> !</span><span style="background-color:rgb(255,255,254);color:rgb(9,134,88)">13</span></div><div style="background-color:rgb(255,255,254)"><span style="color:rgb(205,49,49)">%2</span> <span style="color:rgb(205,49,49)">=</span> <span style="color:rgb(0,0,255)">icmp</span> <span style="color:rgb(0,128,128)">ne</span> <span style="color:rgb(0,128,128)">i32</span> <span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,134,88)">1</span>, <span style="color:rgb(9,134,88)">0</span>, !<span style="color:rgb(0,128,128)">dbg</span> !<span style="color:rgb(9,134,88)">15</span></div><div style="background-color:rgb(255,255,254)"><span style="color:rgb(0,0,255)">br</span> <span style="color:rgb(0,128,128)">i1</span> <span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,134,88)">2</span>, <span style="color:rgb(0,128,128)">label</span> <span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,134,88)">3</span>, <span style="color:rgb(0,128,128)">label</span> <span style="color:rgb(205,49,49)">%</span><span style="color:rgb(9,134,88)">4</span>, !<span style="color:rgb(0,128,128)">dbg</span> !<span style="color:rgb(9,134,88)">16</span></div><div style="background-color:rgb(255,255,254)"><span style="color:rgb(9,134,88)">}</span></div><div style="background-color:rgb(255,255,254)"><div><br></div><div>Instruction*Inst = load <span style="color:rgb(0,128,128)">i32</span>, <span style="color:rgb(0,128,128)">i32</span>* <span style="color:rgb(0,128,128)">getelementptr</span> <span style="color:rgb(0,128,128)">inbounds</span> (<span style="color:rgb(0,128,128)">%struct.foo</span>, <span style="color:rgb(0,128,128)">%struct.foo</span>* <font color="#ff0000" style="background-color:rgb(255,255,0)">@f1</font>, <span style="color:rgb(0,128,128)">i32</span> <span style="color:rgb(9,134,88)">0</span>, <span style="color:rgb(0,128,128)">i32</span> <span style="color:rgb(9,134,88)">0</span>)</div><div>Value *V=Inst->getOperand()[0] = <span style="color:rgb(0,128,128)">i32</span>* <span style="color:rgb(0,128,128)">getelementptr</span> <span style="color:rgb(0,128,128)">inbounds</span> (<span style="color:rgb(0,128,128)">%struct.foo</span>, <span style="color:rgb(0,128,128)">%struct.foo</span>* <font color="#ff0000" style="background-color:rgb(255,255,0)">@f1</font>, <span style="color:rgb(0,128,128)">i32</span> <span style="color:rgb(9,134,88)">0</span>, <span style="color:rgb(0,128,128)">i32</span> <span style="color:rgb(9,134,88)">0</span>)</div><div><b>V->getName().str() </b>// does not return anything.</div><div>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:"Helvetica Neue";color:rgb(69,69,69)"><br></p></div><div>Any pointers.</div><div><br></div></div><div style="background-color:rgb(255,255,254)">Thanks.</div></div></div></div>