[cfe-commits] r140232 - /cfe/trunk/lib/Sema/SemaExpr.cpp
Chandler Carruth
chandlerc at google.com
Wed Sep 21 15:36:15 PDT 2011
On Wed, Sep 21, 2011 at 3:25 PM, David Blaikie <dblaikie at gmail.com> wrote:
> One other point on this - the issues you've raised already exist in both
> assert and llvm_unreachable code, making this change (assert(0) ->
> llvm_unreachable) somewhat orthogonal to them.
>
Not at all. llvm_unreachable has a tremendously different impact in
optimized builds than assert(0) does. The latter has zero impact, the
control flow remains as expected.
But llvm_unreachable tells the optimizer that this code path *cannot be
taken*. That in turn constrains the value of the input. That in turn causes
other optimizations to fire, and so on. This can cause essentially unbounded
undefined behavior given an unexpected input, where as the assert will
"merely" fall through.
I've specifically seen cases in the disassembler and assembler code where
truly unexpected cases are assert(0)'ed, but then handled benignly. I don't
think we want to tell the optimizer that this *cannot* happen, but rather
catch when it does happen in our test suite. The assert seems well suited to
that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110921/28c63d0a/attachment.html>
More information about the cfe-commits
mailing list