<div dir="ltr"><div><div><div>Hi, <br><br></div>Are there some built-in LLVM transformation pass, or written library code that transforms LLVM::SwitchInst into if-condition statements (LLVM:: BranchInst)?<br><br>The purpose of the transformation is that we have a legacy program analyzer that includes an LLVM pass manipulating if-condition statements. Statements of LLVM::SwithchInst should have 
been handled in the same manner but was not done. Thus to transform these SwitchInst to if-condition looks a viable alternative for us.  <br><br>To illustrate, I give a simple C snippet with 'switch' and the expected transformation.<br>---------------------------------------- <br></div>Original program: <br><br><i> char grade;<br> ...<br>  switch(grade)<br>    {<br>    case 'A' :<br>      printf("Excellent!\n" );<br>      break;<br>    case 'B' :<br>      printf("Well done\n" );<br>      break;<br>  <br>    default :<br>      printf("Invalid grade\n" );<br>    }</i><br><br></div><div>may be transformed to something like<br><br></div><div><i>if (grad=='A') <br>          printf("Excellent!\n" );<br></i></div><div><i>else if (grad=='B')<br>      printf("Well done\n" );<br></i></div><div><i>else <br>       printf("Invalid grade\n" );</i></div><div>-------------------------------------------------<br></div><div> <br>Are you aware of such a transformation pass ? Thanks.<br clear="all"></div><div><div><div><div><div><div><div><div class="gmail_signature">Zhoulai</div></div>
</div>
</div></div></div></div></div></div>