<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'>
Yes, I'm saying that the implicit-def operand that was added in this case ended up as #4, out of 6, when the operands list was reallocated in addOperand().<br><br>If addOperand was rewritten, I think it's best not to add my fix for ProcessUses(), as I wrote earlier.<br><br>Jonas<br><br><div><hr id="stopSpelling">Subject: Re: [LLVMdev] VirtRegRewriter.cpp: LocalRewriter::ProcessUses()<br>From: stoklund@2pi.dk<br>Date: Wed, 12 Oct 2011 09:14:52 -0700<br>CC: llvmdev@cs.uiuc.edu<br>To: jnspaulsson@hotmail.com<br><br>
<meta http-equiv="Content-Type" content="text/html; charset=unicode">
<meta name="Generator" content="Microsoft SafeHTML"><br><div><div>On Oct 7, 2011, at 8:14 AM, Jonas Paulsson wrote:</div><br class="ecxApple-interchange-newline"><blockquote><span class="ecxApple-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-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><div class="ecxhmmessage" 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="ecxApple-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></div>                                         </div></body>
</html>