[llvm] [AMDGPU] Fix resource analysis crash on alias-to-alias function (PR #99034)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 16 11:26:22 PDT 2024


================
@@ -65,9 +65,10 @@ static const Function *getCalleeFunction(const MachineOperand &Op) {
     assert(Op.getImm() == 0);
     return nullptr;
   }
-  if (auto *GA = dyn_cast<GlobalAlias>(Op.getGlobal()))
-    return cast<Function>(GA->getOperand(0));
-  return cast<Function>(Op.getGlobal());
+  const GlobalValue *GV = Op.getGlobal();
+  while (auto *GA = dyn_cast<GlobalAlias>(GV))
+    GV = cast<GlobalValue>(GA->getOperand(0));
----------------
shiltian wrote:

Aha, I also learnt it today.

https://github.com/llvm/llvm-project/pull/99034


More information about the llvm-commits mailing list