public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/101432] New: NULL dereferences aren't assumed to be unreachable even with -fdelete-null-pointer-checks -fno-isolate-erroneous-paths-dereference
@ 2021-07-13 5:25 josephcsible at gmail dot com
2021-07-13 7:44 ` [Bug tree-optimization/101432] " rguenth at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: josephcsible at gmail dot com @ 2021-07-13 5:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101432
Bug ID: 101432
Summary: NULL dereferences aren't assumed to be unreachable
even with -fdelete-null-pointer-checks
-fno-isolate-erroneous-paths-dereference
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: josephcsible at gmail dot com
Target Milestone: ---
Target: x86_64-linux-gnu
Consider this C code:
#include <stddef.h>
int f(_Bool x) {
if(x) {
int *null = NULL;
return *null;
} else {
return 42;
}
}
I want this assembly:
f:
movl $42, %eax
ret
But even with -O3 -fdelete-null-pointer-checks
-fno-isolate-erroneous-paths-dereference, I get this assembly:
f:
movl $42, %eax
testb %dil, %dil
je .L1
movl 0, %eax
.L1:
ret
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/101432] NULL dereferences aren't assumed to be unreachable even with -fdelete-null-pointer-checks -fno-isolate-erroneous-paths-dereference
2021-07-13 5:25 [Bug c/101432] New: NULL dereferences aren't assumed to be unreachable even with -fdelete-null-pointer-checks -fno-isolate-erroneous-paths-dereference josephcsible at gmail dot com
@ 2021-07-13 7:44 ` rguenth at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-13 7:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101432
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-07-13
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
-fisolate-erroneous-paths-dereference is the only one that "elides" the null
dereference but it doesn't currently have a way to optimistically remove it,
instead it places a trap at the path entry unconditionally. Thus you get
f:
.LFB0:
.cfi_startproc
testb %dil, %dil
je .L2
movl 0, %eax
ud2
.p2align 4,,10
.p2align 3
.L2:
movl $42, %eax
ret
there are duplicate enhancement requests for an option to control this
behavior. The current default behavior is on purpose.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-13 7:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13 5:25 [Bug c/101432] New: NULL dereferences aren't assumed to be unreachable even with -fdelete-null-pointer-checks -fno-isolate-erroneous-paths-dereference josephcsible at gmail dot com
2021-07-13 7:44 ` [Bug tree-optimization/101432] " rguenth at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).