[PATCH] D98783: [CUDA][HIP] Remove unused addr space casts

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 29 22:46:48 PDT 2021


rjmccall added a comment.

In D98783#2642269 <https://reviews.llvm.org/D98783#2642269>, @tra wrote:

> We may want to add someone with more expertise with the IR as a reviewer. I'd like an educated opinion on whether the invisible dangling IR is something that needs fixing in general or if it's OK to just clean it up in this particular case. Or both.
>
> @rjmccall, @rsmith -- do you have any suggestions -- either on the subject of the invisible dangling IR or on who may be the right person to talk to?

If Clang is creating constants unnecessarily, we should try to avoid that on general compile time / memory usage grounds unless doing so is a serious problem.  But I don't think it should be our responsibility to GC unused constant expressions in order to make DCE work.

It's extremely common to create `bitcast` global constants.  So the fact that this happens with `addrspacecast`s but hasn't been a persistent problem with `bitcast`s makes more suspect that DCE actually tries to handle this, but something about what it's doing isn't aware of `addrspacecast`.  And indeed, LLVM's GlobalDCE seems to call a method called `removeDeadConstantUsers()` before concluding that a constant can't be thrown away.  So either you're using a different transform that needs to do the same thing, or something is stopping `removeDeadConstantUsers()` from eliminating this `addrspacecast`.


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

https://reviews.llvm.org/D98783



More information about the cfe-commits mailing list