[PATCH] D90328: Eliminates dead store of an exisiting value
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 2 09:54:10 PST 2020
fhahn added inline comments.
================
Comment at: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:2385
+ PushMemUses(Def);
+ for (unsigned I = 0; I < WorkList.size(); I++) {
+ if (WorkList.size() >= MemorySSAScanLimit) {
----------------
dmccrevan wrote:
> fhahn wrote:
> > Initially it would probably be best to start with just looking at the direct uses of the def and then go from there. One thing to watch out for is compile-time.
> I've been trying to figure out how to get the uses of each def, but for some reason, I keep running into an error being thrown.
>
> This is a snippet I am using to get the uses, but for some reason, getUser() is throwing an error.
>
> ```
> MemoryAccess *DefAccess = dyn_cast<MemoryAccess>(Def);
> if (isa<MemoryPhi>(DefAccess))
> continue;
> for(Use &U : DefAccess->uses()) {
> MemoryAccess * UseAccess = cast<MemoryAccess>(U.getUser());
> ```
>
> Any ideas how to get all of the uses from a Def?
> Any ideas how to get all of the uses from a Def?
That should be the way to do it.
What's the error?
One thing that looks suspicious is that you are using `*DefAccess` without checking if it is not null? (dyn_cast will return nullptr if the value does not have the requested type).
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90328/new/
https://reviews.llvm.org/D90328
More information about the llvm-commits
mailing list