<html><head><base href="x-msg://4735/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Oct 7, 2011, at 8:14 AM, Jonas Paulsson wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Menlo; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; "><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().<span class="Apple-converted-space"> </span><br></div></div></span></blockquote><div><br></div><div>Jonas, after looking into this, I am not sure I understand what you mean.</div><div><br></div><div>The VirtUseOps vector contains operand indexes. For weird reasons, it has indexes of implicit operands first followed by explicit operand indexes at the end.</div><div><br></div><div>MI.addOperand() will always append an implicit register operand to the end of the instruction, so MI.getNumOperands() is the index of the added operand.</div><div><br></div><div>This index is added to the front of VirtUseOps because it corresponds to an implicit operand.</div><div><br></div><div><br></div><div>Are you saying that MI.addOperand() doesn't append the operand to the end? It really should. </div><div><br></div><div>Also note that MI.addOperand() was mostly rewritten in r140744.</div><div><br></div><div>/jakob</div><div><br></div></div></body></html>