diff --git a/llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp b/llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp index 3bf72d1a5d40aa..146649a7e2d548 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp @@ -65,10 +65,7 @@ static const Function *getCalleeFunction(const MachineOperand &Op) { assert(Op.getImm() == 0); return nullptr; } - const GlobalValue *GV = Op.getGlobal(); - while (auto *GA = dyn_cast(GV)) - GV = cast(GA->getOperand(0)); - return cast(GV); + return cast(Op.getGlobal()->stripPointerCastsAndAliases()); } static bool hasAnyNonFlatUseOfReg(const MachineRegisterInfo &MRI,