[PATCH] D71435: [WIP] [Attributor] Function level undefined behavior attribute

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 15 21:33:38 PST 2019


jdoerfert added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:1994
+          noUBLoads.insert(I);
+        }
+      }
----------------
baziotis wrote:
> baziotis wrote:
> > jdoerfert wrote:
> > > jdoerfert wrote:
> > > > FWIW: Branching on an uninitialized local variable is UB.
> > > For now just check if the pointer is a constant null and if null is not dereferenceable 
> > > FWIW: Branching on an uninitialized local variable is UB
> > Yes, thanks, it was intended to sort of signify that "this is not complete yet, it has to be filled".
> > For now just check if the pointer is a constant null and if null is not dereferenceable
> 
> I was assuming the first one but in the second one I lost it.
> Did you maybe mean "If it is not constant null, check if it is not dereferenceable (i.e. getAAFor<Dereferenceable>)"?
> Did you maybe mean "If it is not constant null, check if it is not dereferenceable (i.e. getAAFor<Dereferenceable>)"?

No, AADerferenceable will not tell you if it is "not dereferenceanle" but only if it is.

What I tried to say in more words:

Do not assume NULL cannot be dereferenced, thus that a load from NULL would be UB for sure. NULL can be a valid pointer, it just happens to be one that is different on your OS. In order to determine if NULL can be dereferenced, use the `NullPointerIsDefined` helper function, you can find some uses of it in the Attributor.cpp file already.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71435/new/

https://reviews.llvm.org/D71435





More information about the llvm-commits mailing list