diff options
author | Jakub Jelinek <jakub@redhat.com> | 2022-07-28 12:42:14 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2022-07-28 14:09:09 +0200 |
commit | 3a4cd5dc6faca8fed7fa256c4c06f4999b5a1f9c (patch) | |
tree | 15530c2313c5ba9218e43b05a7dd24985c22bdb2 /gcc/tree-switch-conversion.c | |
parent | a1b7908c3d4a8efee575fd9492409c93facc9000 (diff) | |
download | gcc-3a4cd5dc6faca8fed7fa256c4c06f4999b5a1f9c.zip gcc-3a4cd5dc6faca8fed7fa256c4c06f4999b5a1f9c.tar.gz gcc-3a4cd5dc6faca8fed7fa256c4c06f4999b5a1f9c.tar.bz2 |
gimple, internal-fn: Add IFN_TRAP and use it for __builtin_unreachable [PR106099]
__builtin_unreachable and __ubsan_handle_builtin_unreachable don't
use vops, they are marked const/leaf/noreturn/nothrow/cold.
But __builtin_trap uses vops, isn't const, just leaf/noreturn/nothrow/cold.
This is I believe so that when users explicitly use __builtin_trap in their
sources they get stores visible at the trap side.
-fsanitize=unreachable -fsanitize-undefined-trap-on-error used to transform
__builtin_unreachable to __builtin_trap even in the past, but the sanopt pass
has TODO_update_ssa, so it worked fine.
Now that gimple_build_builtin_unreachable can build a __builtin_trap call
right away, we can run into problems that whenever we need it we would need
to either manually or through TODO_update* ensure the vops being updated.
Though, as it is originally __builtin_unreachable which is just implemented
as trap, I think for this case it is fine to avoid vops. For this the
patch introduces IFN_TRAP, which has ECF_* flags like __builtin_unreachable
and is expanded as __builtin_trap.
2022-07-28 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/106099
* internal-fn.def (TRAP): New internal fn.
* internal-fn.h (expand_TRAP): Declare.
* internal-fn.cc (expand_TRAP): Define.
* gimple.cc (gimple_build_builtin_unreachable): For BUILT_IN_TRAP,
use internal fn rather than builtin.
* gcc.dg/ubsan/pr106099.c: New test.
Diffstat (limited to 'gcc/tree-switch-conversion.c')
0 files changed, 0 insertions, 0 deletions