[NFC][InstCombine] Make check for sret in a vararg function clearer
authorArthur Eubanks <aeubanks@google.com>
Mon, 6 Sep 2021 20:02:36 +0000 (13:02 -0700)
committerArthur Eubanks <aeubanks@google.com>
Tue, 7 Sep 2021 18:19:27 +0000 (11:19 -0700)
We're trying to get the parameter index of sret and see if it's part of
a function's varargs.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D109335

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

index a05fe7a..c3fc5ea 100644 (file)
@@ -2884,7 +2884,7 @@ bool InstCombinerImpl::transformConstExprCastCall(CallBase &Call) {
     // that are compatible with being a vararg call argument.
     unsigned SRetIdx;
     if (CallerPAL.hasAttrSomewhere(Attribute::StructRet, &SRetIdx) &&
-        SRetIdx > FT->getNumParams())
+        SRetIdx - AttributeList::FirstArgIndex >= FT->getNumParams())
       return false;
   }