[llvm] r366009 - [Attributor][Fix] Never override given argument numbers

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 13 10:01:01 PDT 2019


Author: jdoerfert
Date: Sat Jul 13 10:01:00 2019
New Revision: 366009

URL: http://llvm.org/viewvc/llvm-project?rev=366009&view=rev
Log:
[Attributor][Fix] Never override given argument numbers

Modified:
    llvm/trunk/include/llvm/Transforms/IPO/Attributor.h

Modified: llvm/trunk/include/llvm/Transforms/IPO/Attributor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/Attributor.h?rev=366009&r1=366008&r2=366009&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/IPO/Attributor.h (original)
+++ llvm/trunk/include/llvm/Transforms/IPO/Attributor.h Sat Jul 13 10:01:00 2019
@@ -182,8 +182,8 @@ struct Attributor {
     // Determine the argument number automatically for llvm::Arguments if none
     // is set. Do not override a given one as it could be a use of the argument
     // in a call site.
-    if (auto *Arg = dyn_cast<Argument>(&V))
-      if (ArgNo == -1)
+    if (ArgNo == -1)
+      if (auto *Arg = dyn_cast<Argument>(&V))
         ArgNo = Arg->getArgNo();
 
     // If a function was given together with an argument number, perform the
@@ -232,10 +232,13 @@ struct Attributor {
                   "'AbstractAttribute'!");
 
     // Determine the anchor value and the argument number which are used to
-    // lookup the attribute together with AAType::ID.
+    // lookup the attribute together with AAType::ID. If passed an argument,
+    // use its argument number but do not override a given one as it could be a
+    // use of the argument at a call site.
     Value &AnchoredVal = AA.getAnchoredValue();
-    if (auto *Arg = dyn_cast<Argument>(&AnchoredVal))
-      ArgNo = Arg->getArgNo();
+    if (ArgNo == -1)
+      if (auto *Arg = dyn_cast<Argument>(&AnchoredVal))
+        ArgNo = Arg->getArgNo();
 
     // Put the attribute in the lookup map structure and the container we use to
     // keep track of all attributes.




More information about the llvm-commits mailing list