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

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 29 14:25:54 PDT 2018


efriedma added inline comments.


================
Comment at: lib/IR/ConstantFold.cpp:1504
       if (!GV->hasExternalWeakLinkage() && !isa<GlobalAlias>(GV) &&
-          GV->getType()->getAddressSpace() == 0)
+          !NullPointerIsDefined(nullptr /* F */,
+                                GV->getType()->getAddressSpace()))
----------------
manojgupta wrote:
> There does not seem to be a way to find the Function and thereby the attribute here. Any suggestions?
That's challenging... constants are, in general, outside any function, so we don't have any context for this.  (More generally, I think ConstantExprs are a terrible idea, but we're basically stuck with them, at least for now.)

I guess in this particular case, we could just ignore the attribute and still get reasonable behavior; even if there's memory mapped at address 0, it probably isn't a GlobalValue.  But please add a note here, and in LangRef.


================
Comment at: lib/Transforms/IPO/GlobalOpt.cpp:1599
+      !NullPointerIsDefined(nullptr /* F */,
+                            GV->getType()->getAddressSpace())) {
     if (Constant *SOVC = dyn_cast<Constant>(StoredOnceVal)) {
----------------
`GV->getType()` is the wrong type.


Repository:
  rL LLVM

https://reviews.llvm.org/D47895





More information about the llvm-commits mailing list