[PATCH] D47895: llvm: Add support for "-fno-delete-null-pointer-checks"

Manoj Gupta via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 26 14:19:59 PDT 2018


manojgupta marked 4 inline comments as done.
manojgupta added a comment.

In https://reviews.llvm.org/D47895#1139800, @sanjoy wrote:

> Drive by comments
>
> You also need to change the inliner to not inline `null-pointer-is-dereferenceable` into functions that don't have that attribute.


Done. 
Note that, I am expecting that functions with alwaysinline attribute should still get inlined. If that happens and caller does not have this attribute, then optimizer is free to remove the checks.

In https://reviews.llvm.org/D47895#1139757, @efriedma wrote:

> Please fix lib/Analysis/BasicAliasAnalysis.cpp to allow null pointers to alias other objects.  Please fix lib/Analysis/LoopAccessAnalysis.cpp to allow a loop to dereference null.  Please fix isGEPKnownNonNull in lib/Analysis/ValueTracking.cpp to allow objects located at null.  Please fix ConstantFoldScalarCall in lib/Analysis/ConstantFolding.cpp to allow objects located at null.  Please fix Argument::hasNonNullAttr in lib/IR/Function.cpp to allow objects at null.


Done.



================
Comment at: docs/LangRef.rst:1464
     as SEH, will still provide their implementation defined semantics.
+``"null-pointer-is-defined"``
+   If ``"null-pointer-is-defined"`` is set to ``"true"``, then ``null`` address
----------------
sanjoy wrote:
> This should be called `null-pointer-is-dereferenceable` or something like that.
I actually had a typo here. The IR is using  "null-pointer-is-valid" so changed to the same name. 


================
Comment at: docs/LangRef.rst:1468
+   optimization should not treat dereferencing a pointer to ``null`` as
+   ``undefined`` behavior in this function.
 ``optforfuzzing``
----------------
sanjoy wrote:
> efriedma wrote:
> > undefined isn't a keyword.
> What about functions called from this function?
If the functions are not inlined, it shouldn't normally matter.
For functions that get inlined, I believe caller convention should be kept i.e. not propagating this attribute from callee to caller when inlining.


================
Comment at: lib/IR/ConstantFold.cpp:1504
       if (!GV->hasExternalWeakLinkage() && !isa<GlobalAlias>(GV) &&
-          GV->getType()->getAddressSpace() == 0)
+          !NullPointerIsDefined(nullptr /* F */,
+                                GV->getType()->getAddressSpace()))
----------------
There does not seem to be a way to find the Function and thereby the attribute here. Any suggestions?


Repository:
  rL LLVM

https://reviews.llvm.org/D47895





More information about the llvm-commits mailing list