[PATCH] D22202: Let FuncAttrs infer the 'returned' argument attribute

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 10 14:36:56 PDT 2016


majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM


================
Comment at: lib/Transforms/IPO/FunctionAttrs.cpp:506-515
@@ +505,12 @@
+    SmallPtrSet<Value *, 2> RetArgs;
+    for (BasicBlock &BB : *F)
+      if (auto *Ret = dyn_cast<ReturnInst>(BB.getTerminator())) {
+        // Note that stripPointerCasts should look through functions with
+        // returned arguments.
+        Value *RetVal = Ret->getReturnValue()->stripPointerCasts();
+        if (RetVal->getType() == F->getReturnType() && isa<Argument>(RetVal))
+          RetArgs.insert(RetVal);
+      }
+
+    if (RetArgs.size() == 1) {
+      auto *A = cast<Argument>(*RetArgs.begin());
----------------
Hmm, should we skip the function when `RetArgs.size() > 1`?


http://reviews.llvm.org/D22202





More information about the llvm-commits mailing list