<div dir="ltr">I wrote a llvm pass:<div><br></div><div><pre class="" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">using</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">namespace</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> llvm</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">namespace</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
  </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">struct</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">CountOperands</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">public</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">FunctionPass</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
  </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
    std</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">::</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">map</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">std</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">::</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">string</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">int</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">></span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> opCounter</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
    </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">static</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">char</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> ID</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">

    </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">/*Constructor*/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> 
    </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">CountOperands</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">FunctionPass</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ID</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{}</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">

    </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">/*RunOnFuntion Method*/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
    </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">virtual</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">bool</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> runOnFunction</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Function</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">&</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">F</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
    </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
      errs</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><<</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"Function Name: "</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><<</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> F</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">getName</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><<</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"\n"</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">

      </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">/*Reading the OpCode in the function*/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
      </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">for</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Function</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">::</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">iterator</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> b </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> F</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">begin</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(),</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> be </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> F</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">end</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">();</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> b </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">!=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> be</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">++</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">b</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
      </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">    
       </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
        errs</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><<</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"##########Works fine "</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><<</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"\n"</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">

        </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">for</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">BasicBlock</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">::</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">iterator</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> i </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> b</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">begin</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(),</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> ie </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> b</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">end</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">();</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> i </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">!=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> ie</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">++</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">i</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
        </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{ ¬†</span></code></pre><pre class="" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">            ¬†errs()<<</span></code><span class="" style="white-space:inherit;margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"##########Works fine till here "</span><span class="" style="white-space:inherit;margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><<</span><span class="" style="white-space:inherit;margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"\n"</span><span class="" style="white-space:inherit;margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span></pre><pre class="" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">              if(BranchInst *pBranchInst=dyn_cast<BranchInst>(i))</span></code></pre><pre class="" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">              {//the problem is here,there is a stack dump?why?</span></code></pre><pre class="" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">              }</span></code></pre><pre class="" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">          .....</span></code></pre>whem I run the pass,the command is :<br><br>opt -load XX/XX.so <hello.bc> /dev/null<br><br>then I got a stack dump finally.why? could somebody help me?</div></div>