[PATCH] D65402: [Attributor][MustExec] Deduce dereferenceable and nonnull attribute using MustBeExecutedContextExplorer

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 1 09:13:26 PDT 2019


jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

One nit, and one problem that can be easily fixed and needs to be tested.
Otherwise, LGTM.



================
Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:439
+// Helper function that returns pointer operand of memory instruction.
+const Value *getPointerOperand(const Instruction *I) {
+  if (auto *LI = dyn_cast<LoadInst>(I))
----------------
make helpers static, also below. I somehow thought this function exists somewhere but I might be wrong.


================
Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:1996
+            Offset +
+            DL.getTypeStoreSize(Base->getType()->getPointerElementType());
+        addKnownNonnull();
----------------
This is not correct, I think. We should add a test for sure.

The problem is that there could be bitcasts between base and I which cause the accessed bytes to be less than the base type would suggest.

So 
```
i32* %A
load i8, i8* (bitcast i32* %A to i8*)
```
should cause deref(1) on %A but not deref(4)


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

https://reviews.llvm.org/D65402





More information about the llvm-commits mailing list