<div>It should be checked at creation if you have assertions enabled. It's checked in BinaryOperator::init which is called by the BinaryOperator constructor.</div><div><br></div><div>I'm sure it's done this way for performance of release builds. Development is done with assertions enabled to flush out all the issues then release builds don't have to pay the cost of the checks.</div><div><br><div class="gmail_quote"><div>On Sat, Apr 29, 2017 at 2:22 AM James Courtier-Dutton via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I am finding that I can happily add this instruction to with the IR Builder API.<br>
%reg010 = add i32 %reg007, i64 %reg001<br>
<br>
Then when I do a "verify" pass I get this:<br>
Both operands to a binary operator are not of the same type!<br>
  %reg010 = add i32 %reg007, i64 %reg001<br>
<br>
Now, why doesn't it catch this error when I add the instruction,<br>
instead of waiting till the verify pass to catch it?<br>
<br>
I have found other cases, where it passes the verify pass, I can write<br>
the .bc bitcode to a file.<br>
Then when I use llvm-dis  to convert the .bc to .ll format, llvm-dis<br>
fails to load it.<br>
So, why aren't the tests done at the "verify" pass the same as the<br>
tests done by llvm-dis ?<br>
<br>
<br>
I need my program to have sufficient tests in it to ensure that<br>
whatever bitcode it tries to write, it will be valid bitcode that can<br>
be read by all other llvm tools.<br>
I.e. I wish to catch the error at creation time.<br>
<br>
Is this expected behaviour, or a bug?<br>
<br>
Kind Regards<br>
<br>
James<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature">~Craig</div>