[PATCH] D106589: [GlobalOpt] support ConstantExpr use of global address for OptimizeGlobalAddressOfMalloc
Shimin Cui via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 23 15:21:52 PDT 2021
scui added inline comments.
================
Comment at: llvm/lib/Transforms/IPO/GlobalOpt.cpp:1063
+ if (SI->getOperand(0) == V &&
+ SI->getOperand(1)->stripPointerCasts() != GV)
+ return false; // Storing the pointer itself... bad.
----------------
efriedma wrote:
> scui wrote:
> > efriedma wrote:
> > > `VUse.getOperandNo() == 0`?
> > Thanks for the suggestion. This is the original code as it is, I can change it as you suggested - but looks to me no difference as SI is available.
> The `SI->getOperand(1)->stripPointerCasts() != GV` seems very suspicious to me; I don't understand why we want to special-case storing the address of a global to itself.
>
> For the `SI->getOperand(0) == V` part, I guess it doesn't really matter.
I think this is to make sure the malloc site for GV is only for GV.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106589/new/
https://reviews.llvm.org/D106589
More information about the llvm-commits
mailing list