<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Nov 11, 2012 at 10:42 PM, Bill Wendling <span dir="ltr"><<a href="mailto:isanbard@gmail.com" target="_blank">isanbard@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: void<br>
Date: Mon Nov 12 00:42:51 2012<br>
New Revision: 167717<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=167717&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=167717&view=rev</a><br>
Log:<br>
Check that the input size is correct for the given constraint.<br>
<br>
The 'a', 'c', and 'd' constraints on i386 mean a 32-bit register. We cannot<br>
place a 64-bit value into the 32-bit register. Error out instead of causing the<br>
compiler to spew general badness.<br>
<rdar://problem/12415959><br></blockquote><div><br></div><div>A few more comments in addition to the stuff Eli mentioned. </div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

+  virtual bool validateInputSize(StringRef Constraint,<br>
+                                 unsigned Size) const {<br>
+    switch (Constraint[0]) {<br>
+    default: break;<br>
+    case 'a':<br>
+    case 'b':<br>
+    case 'c':<br>
+    case 'd':<br>
+      return Size == 32;<br>
+    }<br>
+<br>
+    return true;<br>
+  }<br><br></blockquote><div><br></div><div>This needs some comments as well. It's both not obvious and (as you later saw) not quite correct. You should document the assumptions. Also, it makes review easier.</div><div>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
     Exprs[i] = Result.take();<br>
     InputConstraintInfos.push_back(Info);<br>
+<br>
+    const Type *Ty = Exprs[i]->getType().getTypePtr();<br>
+    if (Ty->isDependentType() || Ty->isIncompleteType())<br>
+      continue;<br>
+<br>
+    unsigned Size = Context.getTypeSize(Ty);<br>
+    if (!Context.getTargetInfo().validateInputSize(Literal->getString(),<br>
+                                                   Size))<br>
+      return StmtError(Diag(InputExpr->getLocStart(),<br>
+                            diag::err_asm_invalid_input_size)<br>
+                       << Info.getConstraintStr());<br>
   }<br>
<br></blockquote><div><br></div><div>Thoughts on whether or not this should be a conversion warning or asm warning instead? This isn't much different than the standard truncate warnings, except that it applies to inline assembly.</div>
<div><br></div><div>-eric</div></div></div>