[llvm] [ArgPromotion] Remove redundant logic from recursive argpromotion code (PR #98657)

Vedant Paranjape via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 12 10:29:55 PDT 2024


================
@@ -640,16 +640,18 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
     }
 
     auto *CB = dyn_cast<CallBase>(V);
-    Value *PtrArg = cast<Value>(U);
-    if (CB && PtrArg && CB->getCalledFunction() == CB->getFunction()) {
+    Value *PtrArg = U->get();
+    if (CB && CB->getCalledFunction() == CB->getFunction() &&
+        CB->getCalledFunction()->getReturnType() ==
+            CB->getFunction()->getReturnType()) {
       if (PtrArg != Arg) {
         LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "
                           << "pointer offset is not equal to zero\n");
         return false;
       }
 
       unsigned int ArgNo = Arg->getArgNo();
-      if (CB->getArgOperand(ArgNo) != Arg || U->getOperandNo() != ArgNo) {
+      if (U->getOperandNo() != ArgNo) {
----------------
vedantparanjape-amd wrote:

I don't think so, as I need to check the position of the argument in the call matches the position in the caller function.

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


More information about the llvm-commits mailing list