[LLVMdev] Disabling assertions in llvm.org releases

Renato Golin rengolin at systemcall.org
Sun Jun 20 14:10:02 PDT 2010

On 20 June 2010 21:11, Duncan Sands <baldrick at free.fr> wrote:
> An additional consideration here is clang: while LLVM itself is reasonably
> mature, that's not the case for clang.  I don't know if it is practical to
> ship LLVM with assertions disabled, and clang with assertions enabled.

I strongly suggest not to.

LLVM's assertions won't only get LLVM's own bugs, but also Clang bugs.
IR is not perfect and sometimes allow wrong code to be produced and
validated, only to break at codegen pass on an assert. As they're a
last resort in finding problems, I fear that if we turn them off, bad
code will be generated and, as they'll be running on the user, it'll
be very difficult to trace or even find out that there is a bug in the
compiler in the first place.

Maybe what we need is a cheaper error check. Less computation on the
checking and more on the reporting, so only if there is an error, the
red button is pressed.

So, instead of:

assert(condition && "error message");

we do:

if (!condition) error("message");

I don't think it's that much difference, but that's the cheaper I can
think of...


PS: asserts get inlined normally, don't they?

More information about the llvm-dev mailing list