[llvm] cc92833 - [amdgpu] Remove the GlobalDCE pass prior to the internalization pass.
Michael Liao via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 8 07:26:12 PDT 2021
Author: Michael Liao
Date: 2021-07-08T10:25:58-04:00
New Revision: cc92833f8a3de7f6d4e301a1cb22adf2ffe94df4
URL: https://github.com/llvm/llvm-project/commit/cc92833f8a3de7f6d4e301a1cb22adf2ffe94df4
DIFF: https://github.com/llvm/llvm-project/commit/cc92833f8a3de7f6d4e301a1cb22adf2ffe94df4.diff
LOG: [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
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index 7f74204229c2..81d848a8759a 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -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));
More information about the llvm-commits
mailing list