[cfe-dev] RFC: Implementing -fno-delete-null-pointer-checks in clang

Tim Northover via cfe-dev cfe-dev at lists.llvm.org
Wed Apr 18 12:54:04 PDT 2018


> Despite the name, the flag actually has rather straightforward semantics
> from the compiler's perspective.  From the gcc docs for
> -fdelete-null-pointer-checks: "Assume that programs cannot safely
> dereference null pointers, and that no code or data element resides at
> address zero."  (-fno-delete-null-pointer-checks is the opposite.)

Ah, now that's quite a bit more palatable. I really should have read
the docs before spouting "my favourite rant #1". Then my main concern
is that we end up with a sufficiently clear (and documented)
definition that we're not promising more than we intend. I get very
grumpy if I can't tell someone with UB that they're Doing It Wrong.

Of the two options, I still think the second is a non-starter.
Something between the two might be a datalayout flag specifying
addrspace(0) behaviour. It's pretty easy to argue that it'd be good if
code used some kind of
"DataLayout::isPointerIntrinsicallyInvalid(Value *)" for this kind of
thing anyway (rename or relocate at will).

And the name really is terrible, we should change it if at all feasible

Tim.



More information about the cfe-dev mailing list