https://bugs.llvm.org/show_bug.cgi?id=45839
Bug ID: 45839
Summary: std::terminate() and abort() do not have
__builtin_unreachable() semantics
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangb...@nondot.org
Reporter: s_bugzi...@nedprod.com
CC: blitzrak...@gmail.com, dgre...@apple.com,
erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
richard-l...@metafoo.co.uk
Consider the codegen from https://godbolt.org/z/Em3ZXP:
```
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <exception>
void sum(uint32_t *__restrict a, const uint32_t *__restrict b, const uint32_t
*__restrict c, size_t count)
{
auto invoke_terminate = []{
#ifdef USE_UNREACHABLE
__builtin_unreachable();
#else
std::terminate();
#endif
};
if((((uintptr_t)a) & 15)!=0) invoke_terminate();
if((((uintptr_t)b) & 15)!=0) invoke_terminate();
if((((uintptr_t)c) & 15)!=0) invoke_terminate();
if((count & 15) != 0) invoke_terminate();
while(count != 0)
{
*a++ = *b++ + *c++;
count--;
}
}
```
It would seem that functions marked with both [[noreturn]] and noexcept do not
have the same improvements on codegen as __builtin_unreachable() has. This is
despite that [[noreturn]] functions returning is explicitly required to be UB
in the standard, and if they are noexcept then they cannot throw an exception
either.
Can noexcept functions marked [[noreturn]] please gain the same effects on
codegen as __builtin_unreachable() has please?
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs