<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p></p>
<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><b><br>
</b></div>
<div>Thanks,</div>
<div>Malhar</div>
<br>
<p></p>
</div>
</body>
</html>