1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

[amdgpu] Remove the GlobalDCE pass prior to the internalization pass.

- In [D98783](https://reviews.llvm.org/D98783), an extra GlobalDCE pass
  is inserted before the internalization pass to ensure a global
  variable without users could be internalized even if there are dead
  users. Instead of inserting a dedicated optimization pass, the
  dead user checking, i.e. 'use_empty()', should be preceeded with
  constant dead user removal to ensure an accurate result.

Differential Revision: https://reviews.llvm.org/D105590
This commit is contained in:
Michael Liao 2021-07-07 16:44:47 -04:00
parent 1b885b1ce7
commit 4ed4e3be71

View File

@ -431,6 +431,7 @@ static bool mustPreserveGV(const GlobalValue &GV) {
if (const Function *F = dyn_cast<Function>(&GV))
return F->isDeclaration() || AMDGPU::isEntryFunctionCC(F->getCallingConv());
GV.removeDeadConstantUsers();
return !GV.use_empty();
}
@ -595,9 +596,6 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
PM.addPass(AMDGPUPrintfRuntimeBindingPass());
if (InternalizeSymbols) {
// Global variables may have dead uses which need to be removed.
// Otherwise these useless global variables will not get internalized.
PM.addPass(GlobalDCEPass());
PM.addPass(InternalizePass(mustPreserveGV));
}
PM.addPass(AMDGPUPropagateAttributesLatePass(*this));