[PATCH] D98783: [AMDGPU] Add GlobalDCE before internalization pass

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 15 14:01:13 PDT 2021


yaxunl marked 2 inline comments as done.
yaxunl added inline comments.


================
Comment at: clang/test/CodeGenCUDA/unused-global-var.cu:23-29
+// CHECK-NOT: @_ZL2v3
+constexpr int v3 = 1;
+
+// Check managed variables are always kept.
+
+// CHECK: @v4
+__managed__ int v4;
----------------
tra wrote:
> Mixing CHECK and CHECK-NOT is tricky and, in general, only works if things are always in the same order.
> 
> E.g. if does `v3` get emitted after  `v4`, the test will still pass.
> 
> One way to deal with that would be to split the positive and negative checks into separate runs.
> First one would check the variables we do want to keep with `CHECK-DAG`.
> The other one would only check for the absence of the variables with `-NOT`.
will do


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp:584
+          PM.addPass(GlobalDCEPass());
           PM.addPass(InternalizePass(mustPreserveGV));
         }
----------------
arsenm wrote:
> Should we move where the internalize pass is added instead?
we need two global dce, one before internalize, one after internalize.

the first global dce will eliminate the dead users of the global vars, but not the vars themselves since they are external.

the internalize pass will make the useless vars internal.

the second global dec will eliminate the useless internal global vars. Without the second global dce, the useless global var will not be eliminated.


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

https://reviews.llvm.org/D98783



More information about the cfe-commits mailing list