[llvm-commits] [llvm] r140234 - in /llvm/trunk/lib: Support/ConstantRange.cpp Target/CppBackend/CPPBackend.cpp Target/X86/X86ISelLowering.cpp VMCore/Constants.cpp VMCore/Instructions.cpp
Benjamin Kramer
benny.kra at googlemail.com
Tue Sep 20 20:56:21 PDT 2011
On 20.09.2011, at 20:36, Richard Trieu wrote:
> On Tue, Sep 20, 2011 at 8:27 PM, David Blaikie <dblaikie at gmail.com> wrote:
>>> Change:
>>>
>>> assert(!"error message");
>>>
>>> To:
>>>
>>> assert(0 && "error message");
>>
>> Should these all be changed to llvm_unreachable instead?
>> - David
>
> I'm not sure what's the difference between assert's and
> llvm_unreachable's and how they are used within LLVM. This code
> change is to prepare the codebase for a new warning that I hope to
> turn on soon in Clang. Thus the change preserves behavior with
> minimal changes to not prevent the warning.
The main difference is that the compiler knows that llvm_unreachable doesn't return, no matter if it's a build with or without asserts. Thus it can be used to silence compiler warnings, for example missing returns in non-void functions when we now that the missing return is on an impossible path.
The optimizer can also take advantage of llvm_unreachable in Release builds and remove dead code, but I doubt that it has a huge effect.
- Ben
More information about the llvm-commits
mailing list