diff --git a/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp index 7f74204229c..81d848a8759 100644 --- a/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -431,6 +431,7 @@ static bool mustPreserveGV(const GlobalValue &GV) { if (const Function *F = dyn_cast(&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));