<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
Hi,<br><br>I think I've found a bug in this method.<br><br>I ran it on an MI which already had two implicit-use operands, and which defined a register with a subregindex, ie reg::lo16.<br><br>For the def-operand, with a subregindex, an implicit-use operand was added with this code:<br><br>VirtUseOps.insert(VirtUseOps.begin(), MI.getNumOperands());<br>MI.addOperand(MachineOperand::CreateReg(VirtReg,<br>                                               false,  // isDef<br>                                               true)); // isImplicit<br><br>As, can be seen, it is presumed that this operand is always the last operand, this is however not the case. It in fact becomes the first of the impl-use operands.<br><br>It might be preferred to change the addOperand(), so as to always insert the operand as the last element, or one could handle this locally by looking up the operand number, which unfortunately is not returned by addOperand(). <br><br><   for (unsigned i = 0; i  != MI.getNumOperands(); ++i) {<br>---<br>>   for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {<br>1918c1918<br><     if (MO.isImplicit()){<br>---<br>>     if (MO.isImplicit())<br>1923,1928d1922<br><       bool inserted=false;<br><       for(unsigned oi = 0;oi<VirtUseOps.size();oi++)<br><     if(VirtUseOps[oi]==i)<br><       inserted=true; <br><       if(inserted)<br><     continue; //skip: it was inserted by a partial def below<br>1930d1923<br><     }<br>1941,1951c1934,1937<br><       MachineOperand newMO = MachineOperand::CreateReg(VirtReg,<br><                             false,  // isDef<br><                               true);  // isImplicit<br><       MI.addOperand(newMO); <br><       int opNo; //FIX: the opNo should be returned by addOperand()<br><       for(unsigned oi=0;oi<MI.getNumOperands();oi++)<br><     if(MI.getOperand(oi).isIdenticalTo(newMO)){ <br><       opNo=oi;<br><       break;<br><     }<br><       VirtUseOps.insert(VirtUseOps.begin(), opNo);<br>---<br>>       VirtUseOps.insert(VirtUseOps.begin(), MI.getNumOperands());<br>>       MI.addOperand(MachineOperand::CreateReg(VirtReg,<br>>                                               false,  // isDef<br>>                                               true)); // isImplicit<br><br>/Jonas Paulsson<br><br>                                         </div></body>
</html>