[PATCH] D66079: [SimplifyLibCalls] Add dereferenceable bytes from known callsites [WIP]

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 13:10:45 PDT 2019


xbolva00 marked 2 inline comments as done.
xbolva00 added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:943
+    inferDereferenceableBytes(LHS, LenC->getZExtValue());
+    inferDereferenceableBytes(RHS, LenC->getZExtValue());
     if (Value *Res = optimizeMemCmpConstantSize(CI, LHS, RHS,
----------------
jdoerfert wrote:
> `LHS` and `RHS` are call site operands for which we deduced dereferenceability. Thus we want to annotate the call site. Now with this code, if I'm not mistaken, there are two possibilities for `LHS`, `RHS` is the same:
> 
> 1) `LHS` is anything but an argument -> no annotation -> not what we want
> 2) `LHS` is an argument -> annotation at the argument -> not necessarily correct, see below:
> 
> We should not derive `deref` for the arguments `a` or `b` from the `memcmp` call. We can and should derive `deref` for their usage in the `memcmp` call.
> ```
> void foo(int *a, int *b) {
>   if (a && b)
>     memcmp(a, b, 4);
> }
> ```
> 
Right. I also wanted to annotate callsite arguments but I didnt find a nice API.

I will try your code above.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:983
+  if (isIntrinsic)
+    return nullptr;
+
----------------
jdoerfert wrote:
> What does the return value here mean? I'm also confused by the `Op0` which was there already.
> 
nullptr means that nothing was simplified.

below, for memcpy, we can just turn memcpy libcall to memcpy intrinsic.


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

https://reviews.llvm.org/D66079





More information about the llvm-commits mailing list