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

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 17 08:19:48 PDT 2021


yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall.
yaxunl requested review of this revision.

In device compilation, clang emit global variables in device or constant
address space then cast them to default address space. If global variables
are not used, there are invisible address space casts as LLVM constants
in the LLVM module. These casts cause spurious use of global variables
and prevent them from being eliminated by global DCE.

Such casts will disappear if the module is saved and reloaded, but stays
if the module is not saved and reloaded. This causes difference in generated ISA
depending on whether -save-temps is used.

The patch removes the invisible unused casts of global variables.


https://reviews.llvm.org/D98783

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGenCUDA/unused-global-var.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98783.331269.patch
Type: text/x-patch
Size: 3874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210317/b4e6c65e/attachment.bin>


More information about the cfe-commits mailing list