<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 6/16/2017 9:24 AM, Jajoo, Malhar via
      llvm-dev wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:DB6PR06MB315761AF528058B03A365ADAB0C10@DB6PR06MB3157.eurprd06.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;"
        dir="ltr">
        <div>I was trying to run the simplify CFG Pass in LLVM , and
          delete an unreachable basic block ("continuation" below
          ) after running one of my own IR transforms , but I keep
          getting the </div>
        <div>error -</div>
        <div><br>
        </div>
        <div><b>While deleting: i8* %g</b></div>
        <div><b><br>
          </b></div>
        <div><b>Use still stuck around after Def is destroyed:  store i8
            0, i8* %g</b></div>
        <div><br>
        </div>
        <div>I am well aware of what that means, but isn't the whole
          purpose of the "simplifyCFGPass" to delete the unreachable
          basic blocks for us ? Why must it then throw this error ? I
          would assume it should simply be able to manage all the
          use-def dependencies and delete the instructions in the
          unreachable "continuation" basic block below.</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><b>Following is the relevant IR </b></div>
        <div><br>
        </div>
        <div>    entry:</div>
        <div>      %a3 = alloca i32</div>
        <div>      store i32 %a, i32* %a3</div>
        <div>      %a4 = load i32, i32* %a3 </div>
        <div>      %ifcond = icmp ne i32 %a4, 0</div>
        <div>      br i1 %ifcond, label %then, label %else</div>
        <div>    </div>
        <div>   </div>
        <div>    then:                                             ;
          preds = %entry</div>
        <div>      %gclone1 = alloca i32</div>
        <div>      store i32 0, i32* %gclone1</div>
        <div>      ret i5 0</div>
        <div>    </div>
        <div>    else:                                             ;
          preds = %entry</div>
        <div>      %gclone4 = alloca i64</div>
        <div>      store i64 0, i64* %gclone4</div>
        <div>      ret i5 0</div>
        <div>    </div>
        <div>    continuation:                                     ; No
          predecessors!</div>
        <div>      %iftmp = phi i32 [ 32, %then ], [ 64, %else ], !range
          !0</div>
        <div>      %datasize = alloca i32</div>
        <div>      store i32 %iftmp, i32* %datasize</div>
        <div>    </div>
        <div>      %g = alloca i8<span style="color: rgb(255, 0, 0);">
            ---------------------> Issue</span></div>
        <div>      store i8 0, i8* %g <span style="color: rgb(255, 0,
            0);">---------------------> Issue</span></div>
        <div>      ret i5 0</div>
        <div>    }</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><b>Can someone please explain why this error crops up ?
            Isn't the API supposed to handle this ?</b></div>
      </div>
    </blockquote>
    <br>
    1. If you're going to send a testcase to llvmdev, please make sure
    it is complete: if it isn't possible to reproduce the issue, we're
    going to be left guessing what the issue is.<br>
    2. Running the verifier can catch a lot of issues
    (llvm::verifyModule in the C++ API).  If your IR doesn't follow the
    rules correctly, you can get weird results.<br>
    3. It's generally a bad idea to put "alloca" instructions anywhere
    other than the entry block of a function, if you can avoid it; see
    <a class="moz-txt-link-freetext" href="http://llvm.org/docs/tutorial/LangImpl07.html">http://llvm.org/docs/tutorial/LangImpl07.html</a> .<br>
    <p><br>
    </p>
    <p>-Eli<br>
    </p>
    <pre class="moz-signature" cols="72">-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</pre>
  </body>
</html>