<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<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">
<p>Hi Friedman , <br>
</p>
<p><br>
</p>
<p>I did not put the whole IR because it would be context sensitive.</p>
<p>I am trying to use non-concrete types in my language but trying to <br>
first generate the IR using dummy types and then transform the IR</p>
<p>to contain the correct types.<br>
</p>
<p><br>
</p>
<p>hence,I am forced to use the allocas in the middle , <br>
</p>
<p>again because of the problem above that I am trying to solve.</p>
<p><br>
</p>
<p>Thanks,</p>
<p>Malhar<br>
</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Friedman, Eli <efriedma@codeaurora.org><br>
<b>Sent:</b> Friday, June 16, 2017 8:29:25 PM<br>
<b>To:</b> Jajoo, Malhar; llvm-dev@lists.llvm.org<br>
<b>Subject:</b> Re: [llvm-dev] simplify CFG Pass in llvm</font>
<div> </div>
</div>
<div>
<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">
<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>
</div>
</body>
</html>