[PATCH] D22202: Let FuncAttrs infer the 'returned' argument attribute
Hal Finkel via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 10 15:03:28 PDT 2016
hfinkel added inline comments.
================
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());
----------------
majnemer wrote:
> Hmm, should we skip the function when `RetArgs.size() > 1`?
Yes, because we can only mark one attribute as returned (i.e. it is otherwise uncertain which argument will be returned, so we can mark neither).
http://reviews.llvm.org/D22202
More information about the llvm-commits
mailing list