[PATCH] D77977: [InstCombine] Simplify calls with casted "returned" attribute

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 13 10:12:22 PDT 2020


lebedev.ri marked an inline comment as done.
lebedev.ri added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:4660
+      Type *RetArgTy = ReturnedArg->getType();
+      if (RetArgTy->canLosslesslyBitCastTo(CallTy))
+        return replaceInstUsesWith(
----------------
jdoerfert wrote:
> lebedev.ri wrote:
> > nikic wrote:
> > > lebedev.ri wrote:
> > > > I can't imagine it matters, but these should be swapped around.
> > > Shouldn't this be an assertion rather than an if check?
> > Is there a verifier check for that?
> @nikic has a point. To fix the issue we just need the `CreateBitOrPointerCast`, anything that is not valid is an error in the IR.
> @lebedev.ri are you sure wrt. the order.We cast the returned argument to the call type so I figured we want to know if the returned argument type can be casted to the call return type.
> 
> I think I'll update with an assertion.
> @lebedev.ri are you sure wrt. the order.We cast the returned argument to the call type so I figured we want to know if the returned argument type can be casted to the call return type.

Hm, i guess it depends on how you look at it, either one can be argued to be the right one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77977





More information about the llvm-commits mailing list