[llvm] FunctionAttrs: Remove redundant cast to Instruction (PR #179907)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 5 02:49:05 PST 2026


https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/179907

No point in casting to Instruction before casting to CallBase.

>From bf445a7431d4311757876eb575dc6c001e352304 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 5 Feb 2026 11:43:53 +0100
Subject: [PATCH] FunctionAttrs: Remove redundant cast to Instruction

No point in casting to Instruction before casting to CallBase.
---
 llvm/lib/Transforms/IPO/FunctionAttrs.cpp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index 50130da01c7ba..855692db006f9 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -2394,10 +2394,7 @@ static bool addNoRecurseAttrsTopDown(Function &F) {
   // also detects if F is directly recursive as F is not yet marked as
   // a norecurse function.
   for (auto &U : F.uses()) {
-    auto *I = dyn_cast<Instruction>(U.getUser());
-    if (!I)
-      return false;
-    CallBase *CB = dyn_cast<CallBase>(I);
+    const CallBase *CB = dyn_cast<CallBase>(U.getUser());
     if (!CB || !CB->isCallee(&U) ||
         !CB->getParent()->getParent()->doesNotRecurse())
       return false;



More information about the llvm-commits mailing list