[llvm-dev] Problems with IR Builder

Craig Topper via llvm-dev llvm-dev at lists.llvm.org
Sat Apr 29 08:38:45 PDT 2017


It should be checked at creation if you have assertions enabled. It's
checked in BinaryOperator::init which is called by the BinaryOperator
constructor.

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.

On Sat, Apr 29, 2017 at 2:22 AM James Courtier-Dutton via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hi,
>
> I am finding that I can happily add this instruction to with the IR
> Builder API.
> %reg010 = add i32 %reg007, i64 %reg001
>
> Then when I do a "verify" pass I get this:
> Both operands to a binary operator are not of the same type!
>   %reg010 = add i32 %reg007, i64 %reg001
>
> Now, why doesn't it catch this error when I add the instruction,
> instead of waiting till the verify pass to catch it?
>
> I have found other cases, where it passes the verify pass, I can write
> the .bc bitcode to a file.
> Then when I use llvm-dis  to convert the .bc to .ll format, llvm-dis
> fails to load it.
> So, why aren't the tests done at the "verify" pass the same as the
> tests done by llvm-dis ?
>
>
> I need my program to have sufficient tests in it to ensure that
> whatever bitcode it tries to write, it will be valid bitcode that can
> be read by all other llvm tools.
> I.e. I wish to catch the error at creation time.
>
> Is this expected behaviour, or a bug?
>
> Kind Regards
>
> James
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-- 
~Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170429/b97fd7ed/attachment.html>


More information about the llvm-dev mailing list